Noah Meyerhans

The weblog

Fun With JavaScript

Somewhere along the lines recently, I took an interest in JavaScript programming. I wrote some bad JS code way way back in 1999 while working for a small, long gone ISP, but had spent very little time in it since. When I last wrote JS, there was no XHR, JSON, FireBug, JQuery, prototype.js, etc. Netscape was pushing some new “layers” thing that was supposed to be the basis of their DHTML implementation, and Microsoft was doing something completely different. At the time, the standard approach was generally to implement most functionality on the server and interact with it via CGI forms. JS was used to implement some UI stuff, but not to do any real work. It was a miserable experience.

Writing JavaScript today is still a pretty miserable experience, but several things have changed. The industry has a lot more experience with the language, so it’s pretty easy to learn what aspects of it are to be avoided and which ones embraced. The tools and libraries are much more mature and generally better. The implementations (browser-based and otherwise) are much better. And, maybe most significantly, I’m a much better programmer than I was in 1999.

Today I watched the first part of Douglas Crockford’s “Javascript: The Good Parts” talk on Safari via my ACM membership. It’s been an entertaining and informative review of the history of the language and made me feel a little better about having avoided it for so long. There really are lots of major issues with the language design, and it’s sort of amazing that it’s been so successful. The environment in which it was born, in the bad old days of the Netscape/IE browser wars, was not condusive to success. The haste with which it was shipped, the weird relationship between Netscape and Sun. These were all major obstactles to its success. But the features that make the language interesting (notably, in my opinion, first-class functions and the prototypal object system), are really neat and keep programmers just happy enough that they’re able to overlook some of the uglier areas, or in some cases avoid them completely.

In any case, I’ve had fun hacking on the simple photo gallery application I’ve been working on, and look forward to whatever my next web programming project turns out to be…