Hacker News new | past | comments | ask | show | jobs | submit login

I read TGP, and then I started using Google's Closure compiler. What I found was that Crokford recommends a lot of his own special ways of writing JS, and that they really aren't that great. To me Crokford's book is living in a pre-Closure-Compiler world, one where JSLint was the best tool to help you write good JS code, but in a CC world, Crokford's functional inheritance and use of JSLint are bad in the former, and unnecessary in the latter.

EDIT: Inheritance Patterns in JavaScript by Michael Bolin:

http://www.bolinfest.com/javascript/inheritance.php




Can you give some other examples of Crockford's advice that you'd disregard or how the Closure Compiler affects the way you write JavaScript?


I don't have his book in in front of me, but I remember him introducing and using helper function on the Object prototype to aid in inheritance.

I read his book because it holds such an authoritative place in JS literature. Last year, I began writing an application which has grown to over 6K lines of JS. At this level, pure JS become unwieldy, IMO. I went looking for a technology to help my code stay organized, optimized, and well documented. Closure Compiler was it. But since I had created my inheritance structure following Crokford's functional methodology, CC wouldn't work with it. Also, the only game in town for documenting JS, is jsDoc, in it's various incarnations. At 7K LOC, I wanted good docs for future developers. jsDoc doesn't work with functional inheritance either, strictly prototypical.

The bottom line for me is: Read the book, for sure, but if you plan on writing a large JS application, and go looking for help from a technology like CC (or maybe even DoJo), beware, that Crokford's recommendations (and they do come authoritatively) might put you in a place where you have to do a lot of refactoring down the road.


Writing JS for a framework is not the same as writing JS from scratch. Satisfying the Closure compiler is not what TGP sets out to do, nor should it.

TGP will give you a sound understanding of the possible techniques you can employ to form a JS application.

A book on Closure will give you a sound understanding of how to use that specific framework.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: