Just A Summary

Piers Cawley Practices Punditry

Finally learning JavaScript 10

Posted by Piers Cawley Wed, 16 May 2007 22:17:00 GMT

For years I’ve managed to dodge learning JavaScript. People have told me it’s a fine language with some dodge implementations. Friends have built an entire business model in the language, and I’ve continued to treat as if it were The Sound of Music (I’m 39 now and I have managed to completely avoid watching that film).

Except, today I finally had a technical need that I couldn’t dodge by writing another .rjs file, so with the help of the Prototype docs, a helpful article or two and healthy dose of cribbing from others, I was off.

What do you know, it really is a fine language. I doubt I’m writing idiomatic code though – I’m leaning heavily on closures and private member functions, and I haven’t written a single for loop yet, but it seems to accommodate my style.

Now, if I can just get my head round the innards of keyboard events I shall be a great deal happier.

Comments

Leave a response

  1. Avatar
    brendadada about 2 hours later:

    The Sound of Music is a terrible waste of celluloid, on the other hand.

  2. Avatar
    Piers Cawley about 7 hours later:

    So I believe. I set my mind firmly against it when, at the age of 11 I joined the school choir and was obliged to learn the song Edelweiss – it was assumed I already knew it because everyone’s seen The Sound of Music haven’t they?

    The bloody song is still etched on my memory, and my opinion of it has not improved one jot.

  3. Avatar
    giles bowkett about 12 hours later:

    I had a similar experience with “Wizard of Oz.” I mean I’ve seen it, but a similar experience with a singing class.

    Anyway – just wanted to say, JavaScript is one of the only languages where I wouldn’t advocate idiomatic code. (Java is too, sort of.) Idiomatic code in JS often means reams of scattershot copy-paste. Crockford’s got a thing showing you how to do “The Little Schemer” in JS, iirc. Since the idioms are iffy in extremis and it’s basically Lisp with Algol-family syntax, you might as well just hack it Lisp-style rather than idiomatically.

    My JS always ends up looking like dumbed-down Perl, but it’s best to disregard my bad example in this case. The point is a language which is vastly underrated shouldn’t be programmed idiomatically. If a person’s covered in coffee stains, you don’t tell them to keep wearing the same clothes. Laundry is good.

    OK I’m way too tired to be blogging. Hope that came off semi-coherent.

  4. Avatar
    Pete Jordan about 15 hours later:

    Ah, JS event handling; you’ll find the implementation is nicely standardised across browsers ;)

    It’s not a bad language, as you say, though its grown-in-the-telling nature has left a few annoyances.

  5. Avatar
    Aaron Bassett about 15 hours later:

    Its all downhill from here ;) I started using Javascript heavily about 12 months ago and am now a self confessed Javascript Junky

    You might also want to take a look at shortcuts.js It makes working with keyboard events in Javascript a breeze

  6. Avatar
    Piers Cawley about 19 hours later:

    Giles: If I said I found myself thinking along those lines, but didn’t want to come over as an arrogant newbie, will I have blown my cover?

    Pete: I think you broke my sarcasm detector again. The needle’s bent.

    Aaron: I looked at shortcuts.js and it is indeed very lovely, and I shall almost certainly be using it, but I’m writing a clientside completion thingummyjig which needs a catchall action as well.

    When I get the tuits, I shall take a look at adding key aggregation and exclusion to it because the basic interface is lovely.

  7. Avatar
    Simon Wardley 1 day later:

    As you know, the business model is a utility based computing cloud (think EC2) which an application framework which enables you to develop entire applications in JavaScript.

    Of course the plan is much more ambitious. It is to create a distributed environment (federated grid) where you can build, transfer and release applications to the web without capital costs, without scaling, without all the set-up and without lock-in to one vendor or exit costs.

    That’s why we’re open sourcing Zimki at OSCON this year, having been running it now since before Mar ‘06.

    It’s just a combination of some old but good ideas – commoditisation of IT, P2P infrastructure, infrastructural goods & open source etc.

    Personally I like the idea of building without all the “yak shaving” and without all the waste – I know one company with over 10,000 servers who have a utilisation rate of less than 5%.

    You know me, reducing waste is good for ducks! (P.S. I’ve got about twenty new ducklings running around the forest at the moment … very cute)

    Oh, and JavaScript … I agree it’s a fine language.

  8. Avatar
    Chris 1 day later:

    I wandered here looking for the bread crumbs of perl 6… is that thing dead?

    But then I saw that you’re just tackling javascript after years of putting it off. Sounds like we’re in the same boat. Douglas Crockford has a series of lectures on the language that have some interesting historical insight along with good information: http://video.yahoo.com/video/play?vid=111593

    Cool blog, btw.

  9. Avatar
    Piers Cawley 1 day later:

    Perl 6 isn’t dead, I’m just not writing the summaries any more (and Ann Barcomb, who took over from me, has just dropped out over time pressure as well) but judging by the mailing list traffic and the Design group minutes that chromatic posts in his use.perl journal, things are certainly progressing; probably better than they have been doing in some periods of the project lifetime.

    I’m still a fully paid up member of the Ruby ‘til 6 club (with the occasional bout of yearning for Perl 5 and CPAN, specifically Date::Time).

    Thanks for the praise and the link.

  10. Avatar
    brendadada 10 days later:

    My mother took me to see it, we went to the cinema a lot together when I was a child. What redeemed the film to her as a musician and teacher, was the resurgence of tonic sol fa as a result of that bloomin’ awful ‘Doh a deer’ song, and that delighted her, since she was always looking for ways to make the teaching of music more accessible.

    There’s not always a silver lining. :)

Comments



Just A Summary