Few thoughts on Crockford’s “JavaScript: The Good Parts”

I’ve just finished reading Crockford’s book and decided to drop a few lines before I put it back on company bookshelf. In my opinion this is MUST READ for anyone who ever touches any JS code. Especially that JS T.G.P. is actually a very quick read, just a few days of reading if you want to be honest to yourself and grasp all the concepts. Very, very precise book which tells you exactly the things you want to know. In essence – no fluff, just stuff. Another good thing about this book is that it doesn’t say anything about dreaded browsers or DOM manipulation. You devote just a tiny bit of your time and you get rewarded with comforting feeling that you now know all the essentials. I also started googling to check out what people say about Crockford’s idea of encapsulation and information hiding using functions lexical scoping. He even proposes to drop JavaScript pseudo-classical inheritance pattern in favor of functional inheritance pattern to promote information hiding. This is something I personally feel skeptic about. Information hiding is one of the pillars of OO but you need to ask yourself how much you’re willing to pay to get it. In my opinion, when you need to use functions which create functions you sacrifice code verbosity and clarity and that’s a bit too much. My skepticism got even stronger when few days ago I started reading source code for SmartClient – JS library made by Isomorphic. Guys who made this software are pros, no doubt about it. They created their own inheritance mechanism which only supports Crockford’s statement that native JavaScript pseudo-classical inheritance model should not be used. But they use naming conventions instead of real information hiding. If they want property to be private they prefix their names with “_” character and then they pretend it’s private. The same with private methods. Technically you can access it from anywhere , but why? What’s your excuse? You can’t say you didn’t know underscore means private. When I look at SmartClient code written using this convention it looks more natural, more intuitive and easier to read than even small examples which use functional scoping for information hiding. For me that is more important than feeling that my code can’t be tampered with by my team mates or other scripts. Just to sum up, let me make it clear that those facts do not change my overall feeling about the book I’ve just read. If you do JavaScript, even occasionally, you must read it. I think this book is one of top 3 most recommended books on the web. Thank you Douglas Crockford, keep up the good work. Łukasz Kucharski PS. Read English version of the book. Polish translation is simply too much to handle.

You May Also Like

Read emails from imap with Spring Intergration

What's the easiest way to read emails from IMAP account in Java? Depends what your background is. If you have any experience in Apache Camel, ServiceMix, Mule, you already know the answer. If you don't, and your application is using Spring alr...What's the easiest way to read emails from IMAP account in Java? Depends what your background is. If you have any experience in Apache Camel, ServiceMix, Mule, you already know the answer. If you don't, and your application is using Spring alr...