In Praise of JavaScript

So there’s been, y’know, talk about JavaScript at work.  With JavaScript encroaching on the server-side more and more, I’ve seen chatter about unsuitable it is for server systems.

I was one of those guys.  I didn’t care if I could do it client-side.  Give me a post-back and a code-behind and I’ll get it done.  Or: hey, nice client-side implementation of that.  You know the next Gecko or WebKit or IE will mangle it, right?  Hope they don’t release a new version tonight.

My perspective today is that JavaScript is the language we’ve got.  If you hate it, well, there are lots of jobs working on systems and applications that don’t touch web browsers.  However, if web browsers are where your audience is, then you’d better get comfortable.  I’d bet that most of your beef with JavaScript (if you have beef) is actually with browsers.  They’ve been, well, inconsistent.  But JavaScript is good (as in “flexible” and “expressive”), and getting better.  (And I don’t see a real competitor for it.)

In terms of that encroachment, I think stacks like Node are really intriguing.  I think more traditional stacks will definitely catch up, but I think it says a lot that the first group to patch together something like that (a server that was light, event-driven, and I/O intensive) used JavaScript (and V8) to do it.

I’m reading Douglas Crockford’s JavaScript: The Good Parts right now.  It’s great.  I had the chance to see Mr. Crockford last year — he talked for a day at Front End Masters — but missed out.  I wish I’d been there.

Hanselman on CDN Fallbacks

CDNs fail, but your scripts don’t have to – fallback from CDN to local jQuery:

Even better, RequireJS has a really cool shorthand for fallback URLs which makes me smile:

    enforceDefine: true,
    paths: {
        jquery: [
            //If the CDN location fails, load from this location
require(['jquery'], function ($) {

With RequireJS you can then setup dependencies between modules as well and it will take care of the details.

Good insight on potential CDN problems, and great mitigation plan.