January 20, 2012

JavaScript. But not as we know it.

Javascript has taken over. The V8 engine makes it as fast as machine code. People are using it all over the place on the server-side as well as in web browsers. But the thing that many developers miss is that Javascript is actually a very different kind of language than its predecessors. Instead of being class-based, it is prototype-based and dynamically mutable, making it far more organic and wild. Instead of deferring to a strict hierarchical tree of class definitions like in Java, JS objects defer to other objects when calling a missing field. This makes for a structure that's more like a switching network of train lines than a branching tree limbs. (I'm a visual thinker.)

What's more, variables and functions can be easily added and removed at runtime, which has given rise to the notion of "mixins". You like the glow-in-the dark features of your jellyfish object and the hoppity-hop or your rabbit object? You can use the mixin pattern to blend these two objects into a new glowInTheDarkBunny object. It's not hierarchy, it's hybridity.

To get a sense of what all this means, check out this decent book on modern Javascript:


David said...

I love javascript now. I have finally taken to it now that it's really broken out.

Not that it's terribly relevant but to say that it's as fast as machine code is probably a stretch; depends what you are doing and well it's complicated... but I still find javascript fascinating right now and I'm learning all I can.

David said...

Forgot to say. Thanks for the link to that free online book. Should be a lot of fun to check that out.