w5d4 - Ruby, my one true love
Oh Ruby, how I miss thee! Your simple methods… your casual nature… your descriptive variables and liberal underscores… the way you verbosely yell at me when I do something wrong… I took you for granted, and now you’re gone! The only left to fill the void is javaScript…
Sigh… The official first day of javaScript was a little rough. I thought I was ready after all of the CodeAcademy prep, but I’m still trying to get used to this fickle mistress of a computer language. It’s jarringly littered with braces and semicolons, and I think the thing that bugs me the most, is how permissive it is. Unless you do something blatantly wrong, javaScript just sort of lets things happen and you’re left to figure out where you went wrong. My favorite example is that javaScript has a value called NaN, which stands for “Not a Number”. When it comes across some weird calculation, like 7/”chair”, it doesn’t throw any kind of error, it just assigns it the value NaN and continues on it’s merry way. This might sound great, except for the fact that this will screw up any other calculations that may have depended on that value, turning EVERYTHING into NaN. Since there was no actual error, it can be difficult to backtrack through your code to see where things went awry. In the coming days, we’ll be exposed to better debugging tools, which should prove to be immensely useful for seeing what is going on at any point of your JS program.
Of course, it makes sense that JS is so lenient. The internet is basically built on JavaScript and it HAS to be very flexible to work so widely, so we will just have to deal with the quirks of JS as we go along, and hopefully get used to them. It does have some cool things that Ruby didn’t (I hope Ruby isn’t listening right now…), such as callbacks and asynchronous functions. Callbacks are basically functions that you can set up, specifically to be called later. It seems that these are typically used alongside Closures, which are functions defined within other functions, and they handle the local variables of the original function… or something like that, I’m still trying to nail down the concept. Asynchronous functions are pretty cool, and I’m looking forward to dealing with those more in depth. Things that are asynchronous don’t hold up the rest of your program while they run. You can trigger one and continue running the rest of the program while the async function does it’s own thing. The tricky thing is grabbing any useful information back, and I think that’s where callbacks come in handy, but I’m not entirely sure. It will take some practice before I get used to these new concepts.
Despite the rocky start, I’m still excited to go deeper into javaScript. The things that I mentioned above are of particular interest to me, and I see how they might be powerful tools in the arsenal of any developer.