Secrets of the JavaScript Ninjas

One of the early technology decisions we made on Stack Overflow was to go with a fairly JavaScript intensive site. Like many programmers, I've been historically ambivalent about JavaScript:

This is a companion discussion topic for the original blog entry at:

Ever wondered what all those people do with NoScript after they have downloaded it?

They run it to block all your shitty Java, that’s what.

jQuery rocks anyone’s world, although I’m finding it’s good also to learn the raw JS so that on the few occasions it doesn’t work you can at least get under the hood and see what’s what.

A few people mentioned the desirability of a cross-browser CSS framework - well, it’s not perfect yet but Dirk Jesse’s YAML (Yet Another Multicolumned Layout) is on the right track for sure.

Cover pic of that books shows a Samurai with too much espresso in its bloodstream.

Ninjas are just as pi$$ed off, but dressed in black and sporting shurikans.

I just had to go through the pain of trying to figure out which library/framework to use and reviewed some at

I was torn between the 2 finalists: YUI and jQuery… I made a decision and picked one but after reading some of the comments, I might use them both.

One more thing… I just donated to jQuery about an hour ago… My first donation ever to an open source project. That’s how much I love that library :slight_smile:

You can donate at

Wonderful!! Finally, SOMEONE agrees! Make the programmers actually THINK of rich and creative interfaces–instead of leaving it up to no talent, ugly scalable vectors, webs over-done and re-done in too much FLASH and XARA. Thank GOD for JavaScript! Great Post!

Jeff you forgot to put MS Ajax on the list. It’s a framework too.

Checked out Google’s Open Social API yet?

I just finished a Myspace App backed by the OpenSocial API:

If you want to know what the REAL javascript ninjas think about these frameworks, you should check out comp.lang.javascript

One comment, for example: Prototype was written by people who don’t know javascript for people who don’t know javascript

These frameworks lull people into thinking they know javascript, when the truth is they really don’t.

But I don’t expect it to change anytime soon. It’s just too hard to learn how to write javascript correctly. It’s so much easier to use these frameworks. And most employers don’t want REAL javascript ninjas, they want people who know their chosen framework, and they think that makes someone an expert.

Ninjas are wussies. Pirates are cooler. JavaScript is for ninjas. (aka wussies) Pirates use C# on the desktop because Web 2.0 is for ninjas.

now if I could just find a framework that ran on Facebook :frowning:

As others have already mentioned, if you’ve got a Java backend, the Google Web Toolkit (GWT) can’t be beat.

The biggest problem with GWT is it’s ability to integrate with existing Javascript, but it’s been more then a year since I worked with it so I’m pretty sure many things have gotten better. I was a big fan of being able to deal with my presentation objects in both the client code and the server code… it felt like I wasn’t doubling up on work which usually happens when you cross the language divide.

The website I was working on integrated the GWT with Google Maps. Even though it’s pretty obvious Google Maps is written with GWT, it would have been nice to see better integration - but I guess this gets into the difference between their internal API’s and their public ones.

the ninja is hiding behind the samurai.

thanks to john resig’s jquery. I love writing many thing in javascript. before, I hate and doing lot of thing on the server side … :wink:

With Javascript’s continued evolution, it’s definitely exciting to see where things are going. I’m currently developing a web-based app that has traditionally been in the realm of desktop-based apps only, but using ExtJS has changed all that - I get the look and feel of a desktop app with the portability and speed of a browser app.

It also does away with the tag soup you mentioned previously, Jeff. The app is downloaded into the browser in JS form, and all data is obtained using AJAX and delivered in JSON format.

I’ve been toying with a log of jQuery lately and I must say, there is no need to ever write custom JavaScript ever again. I got into an argument on this, but honestly: I’m fine with letting John and his team worry about all the browser specific behavior, I just want to write my (few lines of) code and have it work right out of the gate.

Might have to try one of these out… still writing Javascript by hand (and quite a bit of it) and struggling with getting things to work between IE and FireFox. Very frustrating that Microsoft has been so willing to go against web standards. Thankfully I develope for Intranet which means FireFox support is nice to have, but not required.

JavaScript use to bother me with its dynamic typing and treating functions as first class variables but I’ve finally come to grips with it now.

I think it would be worth mentioning base2 ( by Dean Edwards, which is my favourite choice if the amount of JavaScript we’re talking about is like 50 LOC. It is a layer in between nothing and a full framework: It just evens out the browser incompatibilities so that programming to the DOM specs actually works. It provides some generic goodies inspired by ECMAScript 4, but no fancy utilities or an own API, just plain standards-dictated DOM Level 2 (plus a bit of 3). IIRC, it even drives one of the bigger frameworks (either Prototype or jQuery, I don’t recall anymore).

While coding for the DOM isn’t that much fun (braindead standards body, really…), it’s lightweight and perfect for a small special effect on an otherwise static website.