"JavaScript: The Good Parts" by Crockford is excellent. It convinced me to minimize the use of JavaScript and thereby avoid the perils of the programming cutting edge (e.g., node.js). He also showed me how, in JavaScript, to add two numbers by calling a function that passes back another function that I can then call to add the numbers - just what I needed!8-))
But seriously, I used JavaScript with abandon years ago and found it laughable then. Crockford's book taught me that JavaScript hasn't changed much in the intervening years - still a hoot as a programming language. You can get just enough done with it if you stay minimal: try to do too much and you'll end up down the creek without a paddle.
Plus, the book was available before we had all the different resources on the web. I read a few years and rarely refer to it anymore but I especially liked the parts on browser inconsistencies.(my edition is dated now, but served its purpose at the time i bought it)
The version I bought in 2008/9 was already bit outdated (the 5th edition?), and I agree - I haven't really used it very much. I've learned a lot more from the other resources tlrobinson suggests. I find the Flanagan book rather reminiscent of the JS state of the art, circa 2004. I don't think it places enough of an emphasis on understanding techniques like using closures and other methods of working with scope.
That list is way too long. JavaScript isn't that big or complicated, even if you include DOM and cross-browser issues (which by virtue of continuous browser changes, you will never learn about from a book).
Also, I wouldn't recommend either of Resig's books, despite not reading them. Look at Peter Michaux and David Mark's posts on comp.lang.javascript for criticisms (actually, comp.lang.javascript would be the fourth thing on my list if it was a book).
The posts about Resig that I can see by Peter Michaux and David Mark seem to be mostly empty of content and filled with petty namecalling. Do you have any specific review/critique that you think is helpful?
For what it’s worth, Secrets of the JS Ninjas is one of the most illuminating JavaScript resources I’ve seen anywhere – I don’t know anyone who wasn’t able to learn something from reading it, including skilled, seasoned JS developers, and several of its insights can’t be found anywhere else so far as I know – and it’s at this point still a half-written draft.
I can't find the criticisms of Resig's you mention. Can you provide a link?
I did find an encyclopedia's worth of ranting.
Conclusion: don't read Resig's books because two guys who spend a lot of time hating jQuery have criticised the books harshly somewhere on a gigantic website about javascript.
Both are experts on JavaScript and while David Mark is controversial, Peter Michaux is not. If he is hating jQuery (and he is not the only one, about 75% of that JSMentors list considers jQuery bad), that must be for a reason. Google for "browser sniffing" vs. "feature detection" to make your own opinion.
If you want to see other criticisms for them, search c.l.j archives on Google Groups (I admit it's not easy ever since Google ruined Groups search).
The thing with jQuery is it's not as simple as "I hate jQuery." The basic idea behind jQuery (selectors) is a great way of doing stream processing over the DOM. This is a really convenient way of working with existing HTML pages.
The main reason David Mark dislikes jQuery is that (at least at the time) it was poorly implemented. Before I ever came across his posts, I tried reading jQuery code and thought it was very hard to understand, but bought the conventional wisdom excuse that JavaScript programming was special because of cross-browser hacks and people like Resig were "ninjas." Then I came across Michaux's code, read Mark's posts, and realized that the "JavaScript ninjas" were really just writing bad code.
But that doesn't change the fact that jQuery is very convenient to use for manipulating existing HTML pages. But there's another problem there - jQuery does stream processing eagerly at run-time. This is extremely inefficient, and there's no reason to do it for pages where you have control over HTML.
A lot of work has gone into caching in jQuery to avoid duplicated selector search, by far the biggest overhead (conceptually, you're doing an exhaustive search over the entire DOM every time you execute a selector).
But that still doesn't address the fact that the results of the selectors are produced eagerly, and processed by every operator eagerly. There are two optimizations that can be made here: map fusion and lazy evaluation. The latter is possible, but would require rewriting jQuery and changing its interface. The former is impossible without a preprocessing step.
But like I said, there's really no reason to even bother using jQuery with pages where you have control over your HTML and can put the objects you need into arrays and hash tables to be there when you need them. That, and the move of web applications to canvas (at this point I'm convinced it's inevitable) make jQuery irrelevant at this point in time IMO.
You selection is good but I can't believe that in the "if I could only get three" section, Crockford's the good parts is not #1. I mean it is the seminal work for JavaScript, it should be the first or second book anyone considering doing serious JavaScript should read.
The thing about Crockford's book is that it's short and direct, and gives you the straight dope on how you program in JavaScript. It would be a terrible book for someone first learning to program, but if you know a few programming languages already -- especially something that supports lexically-scoped anonymous functions -- then JS:tGP is something you can read through in an hour or two, and then just start writing JavaScript.
@kls: Thanks. Crockford's book is certainly good which is why it was part of the bigger list. For me personally, I much preferred the 3 books I listed because I've found more value to them.
Appreciate the feedback though and thank you for reading the post.
Try to separate the JavaScript language from the additional bindings that the platform gives to you.
If you learn client-side JavaScript for use inside the browsers, differentiate what's a language feature and what's part of the DOM.
If you learn server-side JavaScript, start by looking over the CommonJS standards as they tend to be the common denominator across the server-side JS implementations.
And... experiment. Write a .html on your desktop which references a sample.js and use your browser to check it out and modify the code. Don't rely on technical knowledge for more than a couple of hours without trying out the things in practice. Or, for server-side JavaScript, you can get a free hosting account and browser-based editor at http://erbix.com (+), using just OpenId (i.e. your Google account) to sign up.
Not a book and not a blog, but if you want to keep up with the latest JavaScript stuff on a weekly basis through e-mail: http://javascriptweekly.com/
Yes, it's mine but it's had kudos from folks like Steve Souders and Amy Hoy and almost at 3000 subscribers so I don't feel too bad pimping it. Latest issue is at http://javascriptweekly.com/archive/5.html if you want a preview.
Eh, in my opinion, unless you're doing server side javascript, the thing you need to learn most about when doing javascript is dhtml. The actual javascript language isn't the hard or strange part of the experince.
Most of his links seem to point to actual language esoterica. Only 1 seems to really point at DOM interactions.
I think people coming from most other languages that have objects get very confused about prototypal inheritance. The significance of first-class functions is also not obvious to people who don't come from a functional programming background.
I think you're right insofar as it's easy to "get going" with JS and see things happen in a web page. But if you're looking to actually learn how to build non-trivial apps, a solid grounding in the language is pretty key.
I think one beginner and one advanced book maybe. True, I did come from a different background than most (having learned both those features in other languages before ever doing javascript), but do you really need 7 more books to tell you about it?
I think the post is bordering on book affiliate spam.
I don't disagree with you on that point. Two books should be plenty. I'm only pointing out that there's a lot of utility in learning about JS as a programming language, completely divorced from DOM stuff.
That's because DOM interactions are one of the least interesting aspects of Javascript and not where the current innovation is happening. JQuery has pretty much taken care of that. Buy a JQuery book for that.
The newer javascript frameworks - the ones that are driving interest in Javascript as a language - are flexing the language features to the point where having good books help. The javascript language is pretty hard and strange when you really start getting in there.
No where on the page does it discount the normal case (using Javascript as page display and animation language) and point out these are mostly for the server side/complicated framework people.
Note that I included a JQuery book in there. Any more, it's not enough to know just Javascript, you should also know JQuery (and just as importantly you should know when to use it and when not to use it)
These are ordered, so the top 3 are the best (in my opinion). The others are really good, but with a topic like this it can easily spin out of control, with hundreds of books getting recommended. Stick to 2-4.
I wish there were more posts like this, explaining which books are suitable for each "knowledge level."
My biggest issue has always been that most books assume you know nothing about programming, and so become boring and repetitive, and I learn nothing new.
Videos:
* YUI Theater talks by Douglas Crockford: http://developer.yahoo.com/yui/theater/ especially:
* The JavaScript Programming Language
* Advanced JavaScript
Websites:
* "A Re-introduction to JavaScript": https://developer.mozilla.org/en/a_re-introduction_to_javasc...
* Advanced tutorial from John Resig: http://ejohn.org/apps/learn/
* MDC Reference: https://developer.mozilla.org/en/javascript
Books (you can borrow my copies of these if you want):
* "JavaScript: The Good Parts"
* "JavaScript: The Definitive Guide" is a good reference for both the language and browser/DOM APIs