JavaScript recommendations?
2009 August 20
OK, OK, it’s time. I’ve been avoiding learning JavaScript properly for over a decade now, but I’m going to buckle down and do it.
I’m starting with Douglas Crockford’s JavaScript: The Good Parts, at James’s recommendation. But where next?
For context:
- Most of my JS development is hosted server-side stuff on Freebase Acre.
- I strongly prefer Test Driven Development and would like to write JS that people look at and go “ooh, this is nice!” — if there is any such thing.
- I’m not much good at, and not very interested in, front-end stuff, but I get the impression I should learn JQuery. Yes? No? Maybe? What else along those lines should I look at?
19 Responses
Comments are closed.












There are people who lobby for YUI or Dojo, and Prototype is trying hard to catch up, but yeah, jQuery is essentially the language Javascript should have been to begin with. You have a DOM tree; you select elements from that tree with an expression; and you perform chained operations on the set of those elements, all just-in-time after the tree is parsed but before the page is rendered. It makes JS much easier to read and actually fun to write.
I found Manning’s jQuery in Action useful.
It’s a little above your current level, I’d guess, but you might be interested in our Javascript class if you don’t mind traveling to DC:
http://www.jumpstartlab.com/courses/javascript/
Email me if you’re interested and we can work something out.
It looks like a great course, Jeff, but I don’t think I’m up for the travel. I do notice you cover unit testing — can you recommend tools/frameworks/libraries I should be looking at for that?
I don’t know if you’ve run across them, but the Yahoo Developer network has a bunch of videos, many of which are very good. Crockford has a series of 4 that serve as a comprehensive introduction to Javascript. I found them very useful. Here’s a link to the first one: http://video.yahoo.com/watch/111593/1710507
Crockford’s book is the best place to start. It’s a thin book and tells you everything you need to know about the language. Then you can start getting into actually using it, which isn’t covered in Crockford — browser interactions, DOM manipulation and all that.
jQuery hides all the horribleness that gave JS a bad name in the first place. Only problem is, the examples in the online docs are horribly contrived and weird — they’re not a very good introduction, with every example attempting to flex every muscle jQuery has, rather than clearly explaining one or two features. I’ve got “Learning jQuery 1.3″ by Jonathan Chaffer which is okay, but I’d prefer something referency with good examples.
For unit testing, you should look at Test.Simple.
This is one of the core parts of the JSAN ( openjsan.org ) and it’s a direct port of Test::Simple/Test::More to JavaScript.
Works brilliantly.
@Adam yup, was planning to. Just wondering what else is out there.
After chatting with John Resig for FLOSS Weekly (twit.tv/floss55), I can see why jQuery feels so natural… John is an old-school Perl hacker. Yeay.
If you don’t find yourself manipulating an HTML/XML tree then you won’t have much need for jQuery. I’d say to hold off on that part and learn it on demand. It’s fantastic at what it does, but you often don’t need it on the server side.
Rhino – and thus Acre – supports a bunch of nice js features that we client-side folk have to do without: https://developer.mozilla.org/en/New_in_JavaScript_1.7
The most major of these are probably generators/iterators and array destructuring.
take a look at
Prototypejs.org
and Scriptaculous ( which contains http://wiki.github.com/madrobby/scriptaculous/unit-testing as well )
There are actually several ways to test in JavaScript. The two most interesting to me are:
http://www.jsunit.net/ (which is a port of JUnit)
http://code.google.com/p/js-test-driver/
YUI includes a unit tester and a good video introducing Test Driven Development: http://developer.yahoo.com/yui/yuitest/
You really need to try a couple of the frameworks (jQuery, YUI, etc) and decide which one fits best for you.
I’ve been meaning to get Resig’s book: http://jspro.org/ and he’s working on a new book: http://jsninja.com/
He’s javascript ninja book isn’t quite done yet but you can purchase early access to the first 12 chapters: http://www.manning.com/resig/
I went to his OSCON class 2 years ago and liked it (or were there 2?). In any case those are the three books at the top of my “learn javascript” book list (that I haven’t purchased yet but all signs point to “buy them yesterday”)
If you’re interested in backend JavaScript, you could try out MongoDB (www.mongodb.org). It uses JavaScript for server-side scripting, so you can write your whole query in JS. It comes with a JavaScript DB shell, and a couple people are working on stand-alone JS drivers.
For testing, we’re liking qunit right now. It’s the unit testrunner for jquery, which has good tests (I don’t like using projects without good tests), and the tests provide good docs for both qunit and jquery itself. My other personal preferences would pretty much add +1s to jquery and mongodb.
@gizmomathboy
Pro Javascript techniques wasn’t very useful to me. It reads like “what I learned writing jQuery” – very heavily browser focused, and if you’re already using a library like jQuery a lot of it is unnecessary.
Secrets of the Javascript Ninja is much better, even in its current half-finished state, especially for learning tricky parts of the language rather than just doing common web scripting tasks.
One last tip: I like to have an interactive prompt when I’m developing. There’s a decent one in Firebug, and a quite good one in Safari (enabled in preferences). However if you’re developing for a rhino-based environment like Acre then the best is having a local rhino interpreter on the command line. To run rhino as an interactive prompt the invocation is: java -cp path/to/js.jar org.mozilla.javascript.tools.shell.Main
@Peter Burns
Thanks for the Pro Javascript tip. My tech book budget is rather tight and any good reviews are helpful.
Crockford’s book is good if you already know JS and want to write better code. For starting out in JS, I recommend Object-Oriented JavaScript by Stoyan Stefanov which assumes no JS background.
Sorry that I just saw this now, and I hope it’s not too late…
If at some point we do end up planning a F2F and you’re still interested at that point in learning more JavaScript, just remind me about this—I’ll bring along my JavaScript book + my JavaScript Essential Training video + my Ajax Essential Training video for you (i.e., does bribery work to encourage a meeting to happen? ;-) ).
My personal opinion of the books mentioned above: they’re all great titles from experts geared towards other experts. Which means, sadly, that if you’re not already a JavaScript Expert™ like the authors, they aren’t a good fit. That is, they’re not the place to start learning JavaScript.