Monday, March 3, 2014

Thoughts on Javascript

Over the last few weeks, I have been learning Javascript. I am still somewhat inexperienced with it, but I have already found a number of features of the language that I really like, as well as some that are not so good.

I think my favorite thing about Javascript is the ability to alter objects on the fly. I like knowing that I have the ability to modify objects whenever I need to. However, this could make some really confusing code so I try to avoid the need to use this feature.

I also really like working in a language that isn't picky about types. Being able to put multiple types into the same array is really convenient. It is also makes testing code that depends on other code that hasn't been created yet easier, because I can substitute my own values for whatever input might be missing.

The last in my list of features that I like is the console. It allows the user to track all sorts of details about the state as the program is running. It also allows the user to inject code. This feature makes it possible to test code that isn't complete yet.

I have mixed feelings about the implementation of arrays. Javascript provides a number of convenient built in methods for accessing and modifying arrays, which is good. The problem is that these features come at the cost of speed. I could write my own functions to treat an array like a stack. I can't change the fact that Javascript chose to implement arrays in a less efficient way than other languages typically do.

I really don't like the way that Javascript likes to make variables global. In a large project like this, the last thing we need is to have every variable be a global variable. Javascript provides ways of dealing with this, but I find them counter-intuitive.

The last feature of Javascript that I will complain about is the way that objects are defined. An object can be the only one of its type, or it can be something that needs to be instantiated, depending on whether or not you define an object as a function. I find this to be kind of confusing.

No comments:

Post a Comment