Brian's Waste of Time

Tue, 18 Apr 2006

No ApacheCon EU For Me =(

No email yet, but the schedule is up and neither of the proposals I submitted is on it. Ah well, I'll just have to do them via blog instead of as talks, though it will be sad not getting to see folks in June -- will just have ot hope the Europeans all make it over to ApacheCon US this autumn.

3 writebacks [/apache] permanent link

Embracing JavaScript

I've, lately, had the opportunity to do a lot of JavaScript and Ajax hacking in anger. Summary, holy crap, JavaScript hacking has come a long way =)

The biggest thing, I think, is to embrace JavaScript. It has such a dirty feel from ten years ago that this sounds anethema to many, but it is worth it in the same way that you are better off embracing SQL, or HTTP rather than trying to shove them under a lossy abstraction layer.

The vast majority of tools available, even the really sexy ones, try hard to shield you from JavaScript. While I do, at the moment, much prefer hacking Ruby and Java (and I am so damned happy that Ruby is blazing a fiery trail across the sky as it makes it a much easier internal sell ;-) to JavaScript, it really does you a disservice.

The main disservice it does you, I think, is to force you to think in terms of the classic web. This is the wrong model. JavaScript doesn't buy you visual effects, it buys you a better way of building big web-based systems. Welcome to the top of the line scaling problem #2, you just got promoted.

JavaScript is a weird little language, squirrely, but really rather powerful (meaning expressive and useful). Use it. Embrace it. Go buy Professional JavaScript for Web Developers -- it is the best guide to the language I have found.

Tool wise, I have been extremely impressed by Dojo. For one-off effects, or for use with Rails (because of the tight RJS integration) I'd probably still use Prototype, but my tool of choice has definately become Dojo -- when working in JavaScript.

Alongside Dojo, I have been getting great mileage out of TrimPath's JavaScript Templates. This is a great little templating system for Javascript, which combined with JSON (which rocks, forget XML for JavaScript hackery), lets you push most of your work out onto the client. This also rocks. I haven't used their "Rails in JavaScript" thing, nor the SQL liek bit, those seem a bit too much of trying to be something they are not, and I think taking a Model2 approach in JavaScript is the wrong way -- you can do NeXT/Cocoa style MVC very easily, why go to Model2?

JST is easy to hook into dojo, add a line to the JST source:

dojo.provide("trimpath.template")

Tell dojo where to find the trimpath stuff:

// path is relative to dojo
dojo.setModulePrefix("trimpath", "../trimpath");

And you can treat it like any other Dojo bit:

dojo.require("trimpath.template")

Transitive dependency management is fantastic. Sure, for production you will probably compile up a file with everything you need, but during development this rocks, and for exporting services (if you happen to be building a platform for social software, for instance) and want to make life easy for your users (developers), it is even more useful.

Anyway, lots of fun JS hackery, probably going to be writing a lot more about it.

2 writebacks [/src/javascript] permanent link