Thursday, December 2, 2004

Why didn't anyone tell me?

JavaScript isn't awful. Well, it isn't awful anymore. When
JavaScript first came out, freshly renamed from the less misleading
"ActiveScript", it was awful. It was ill-defined, clunky, full of
security holes, and awkward in a great many ways. I wrote it off as a
tool used to make web sites do things they really didn't need to or
shouldn't do anyway. At some point, seemingly around 1999, this changed.

JavaScript is a clever language with an interesting twist on the
"standard" object model of languages like Java or C++. It's got a
relatively clean and useful set of built-in libraries, including the
valuable DOM. It's threading/timing model is a bit bizarre but
surprisingly useful. It interacts with XHTML in powerful ways to
enable some very useful bits of web UI. Through the use of
"bookmarklets" it puts a lot of power back in the browser which, in
the interest of "interactive" web sites has been gradually leached
away.

JavaScript still has it's issues. The three biggest as I see it are:


  • It used to be bad. It really was bad. No DOM. No good documentation. No prototype inheritance model. Bad. First impressions make a big difference.
  • It's mostly used by non-developers. At some level this isn't bad, but it creates the problem that a lot of the JS code out there is awful because the people writing it don't really know what they're doing. It's horrible voodoo code which is unintelligible and barely functional, never mind maintainable or usable by others.
  • Most use of JavaScript is abuse. The most ubiquitous applications of JS are things like popup and popunder ads. Even image rollovers and other stupid UI tricks could be called abuse. Modern browsers (eg, Firefox) address the whole popup issue well, making this abuse less apparent. Unfortunately, a tool that is mostly used for bad things is often assumed to be a bad thing. JavaScript was used for a lot of bad things.


Now, though it's a nice language. It's being accepted more by
developers. It's being used in useful ways. So, if you're like me
and thought JavaScript was an atrocity deserving no attention, look
again. It's grown up a lot. The question remains: "Why didn't anyone
tell me, in the last 5 years, that it was so much better?"

For reference, I highly recommend the Rhino book by O'Reilly.

No comments:

Post a Comment