As a web developer, you’ll need to use JavaScript one day. There’s no escaping it, eventually you or your client will want a feature that can only be done with JavaScript. I know, I’ve been there. For a long time, I’ve avoided JavaScript like the plague, but you can ignore it only for so long before you have no choice but to sell your soul and get into the language. As I learned JavaScript, I found things that are good that I liked, and things that aren’t so good that I dislike.
I like the language: JavaScript is Lisp is C’s clothings. I like that JavaScript is a small, orthogonal language and that it doesn’t have a gajillion features (though it seems JavaScript 2.0 will not continue on this path), but instead has few limitations of what you can do with the primitives of the language and how you can combine them together. This makes for a language that is simple to learn, but that has more power than a lot of other more complex languages such as Java or C#. The heavy use of higher-order functions and closures is probably the best part of JavaScript.
JavaScript also has problems, Douglas Crockford pointed some out in his Yahoo! videos: unless explicitly specified, variables are global, some keys in an object need to be quoted (reserved keywords), the globbing into one namespace of all the imported scripts, the weak typing, etc. But the language still remains nice.
I dislike the standard library: the JavaScript standard library really sucks. The function getMonth() of the Date object returns the month with a 0 offset instead of a 1 offset like in any other language (and like in the real world.) Strings are missing a lot of useful function such as trim() or sprintf(). The childNodes property doesn’t only return elements, but also strings of blanks. The parseInt() function tries to guess the base of the string to convert, so you always need to specify the radix to prevent possible errors with numbers starting with 0. Generally, I’ve found the standard library to be incomplete and weird.
I also dislike that because there is no module system, everything is in the same global namespace. It’d be nice if the DOM manipulation and the Date manipulation methods could be cleanly separated. Maybe in JavaScript 2…
I dislike the implementations: JavaScript has a reputation of being slow, and I think it deserves it. The interpreters in the browser are no speed horses, and they make the language look bad. Too much JavaScript makes a page very slow and no fun to use. We can hope that the Tamarin project will accelerate JavaScript to bearable speeds.
There’s also the inter-browser compatibility fun: Internet Explorer 6 and 7 use JScript which implements the version 1.5 of JavaScript, Firefox 2 implements JavaScript 1.6 and Firefox 3 implements version 1.7. It would be fun to take advantage of the cool new features of JavaScript such as generators and list comprehensions, but we can’t, because we need to think of the people who use the Microsoft browsers.
There are also slight differences between browsers that one needs to be aware (and wary) of. For example, Firefox allows you to have a trailing comma after the last element of an array literal and all will work normally; this also works in Internet Explorer, but the length of the array is one more than the number of elements ([1, 2,].length will return 3 instead of 2.) These bugs are always fun to hunt down (although I guess I should be using JSLint.)
JavaScript seems to be the opposite of many programming languages that enjoy a good implementation and library, but with a lacking language: the language is good, but the rest isn’t so much. Fortunately, I believe it’s easier to get a better library and implementation than making a new and better language, so JavaScript is on the right path.
Posted by gnuvince