Prev: Limit of 4K
Next: Detecting Internet Explorer 6
From: kangax on 29 Oct 2009 21:08 Here's a review of "Professional Javascript" by Zakas (http://thinkweb2.com/projects/prototype/professional-javascript-review/) The book is pretty big and I didn't have much time, so the coverage is not as extensive as it could have been. However, it should serve as a pretty good overview, highlighting pros and cons, and warning about some of the errors/misconceptions I encountered. -- kangax
From: Garrett Smith on 30 Oct 2009 01:40 kangax wrote: > Here's a review of "Professional Javascript" by Zakas > (http://thinkweb2.com/projects/prototype/professional-javascript-review/) > Review review: From the review: | "Logically, a null value is an empty object pointer" Plainly false. Null is a primitive value. In java (not javascript) Reference Variables can have the value null, and what is written above is conceptually fine for programming in java, but the type of thinking might be better off abandoned for javascript programming. Javascript variables are untyped. Null is a primitive value in javascript. It is best to think of it this way (reality) rather than allude to concepts for other languages. | "Certain statements cause a temporary addition to the front of the | "scope chain that is later removed after code execution." There is a long standing bug in JScript (still in the latest in IE8) where the parameter in a |catch| block does not result in augmented scope for that block. Instead, the identifier is added to the containing scope. Is this not mentioned? | Chapter 5 is about reference types � Object, Array, Date, RegExp, etc. The terminology "reference types" is incorrect. Those are built-ins. The Reference type is a specification mechanism. | Another misleading assertion was � "Though ECMA-262 doesn�t indicate a | way to access the Global object directly [�]". Plainly false. In global context: var global = this; (and can be used as in the following: | It�s not clear why Mr. Zakas didn�t provide and explain rather | ubiquitous way of accessing Global object from within any context � | (function(){ return this; })(); ). | Unfortunately, it starts somewhat badly by making few erroneous | statements about function expressions Yep. The FAQ should really have a section on Functions. | when simulating private variables it uses undeclared assignment to | define variable as global one and does so on purpose! This is | especially bizarre, and | Quite shockingly, an example of document.createElement specifics in IE | is presented with blatant and completely unnecessary browser sniff. Not following his own advice, is he? | I wish there was more emphasis on the dangers and fragile nature of | browser sniffing in this part of the book. You already know where Nicholas stands on browser detection, so that should come as no surprise. <URL: http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/#comment-3121 > | It would be nice to see alternative example which would avoid run-time | try-catch in favor of single load-time test I see. The performance video "speed up your javascript" also has an example doing the same thing (against advice in that same video). | There were moments when I didn�t share same vision as Mr. Zakas, such | as the one where he recommends to use comments in places where there | are large amounts of code; I believe in a different approach � | breaking code into smaller, more understandable chunks, rather than | adding comments on top. Your review should recommend your influence on advice for writing such "clean code". > The book is pretty big and I didn't have much time, so the coverage is > not as extensive as it could have been. However, it should serve as a > pretty good overview, highlighting pros and cons, and warning about some > of the errors/misconceptions I encountered. > Your review is already quite long. Looks like "Professional JavaScript" needs more work. Sometimes, less is more. "7/10" is either something worth recommending or a C-. I'm not sure. -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Garrett Smith on 30 Oct 2009 02:51 kangax wrote: > Here's a review of "Professional Javascript" by Zakas > (http://thinkweb2.com/projects/prototype/professional-javascript-review/) > > The book is pretty big and I didn't have much time, so the coverage is > not as extensive as it could have been. However, it should serve as a > pretty good overview, highlighting pros and cons, and warning about some > of the errors/misconceptions I encountered. > typo: localStorage.setItemt('clear', 'foo'); Should be: localStorage.setItem('clear', 'foo'); -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Garrett Smith on 30 Oct 2009 02:54 kangax wrote: > Here's a review of "Professional Javascript" by Zakas > (http://thinkweb2.com/projects/prototype/professional-javascript-review/) > > The book is pretty big and I didn't have much time, so the coverage is > not as extensive as it could have been. However, it should serve as a > pretty good overview, highlighting pros and cons, and warning about some > of the errors/misconceptions I encountered. > Wrong wording: | I almost fully agree with everyone that�s being said here. s/everyone/everything -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: kangax on 30 Oct 2009 16:25
Garrett Smith wrote: > kangax wrote: >> Here's a review of "Professional Javascript" by Zakas >> (http://thinkweb2.com/projects/prototype/professional-javascript-review/) >> > Review review: > > From the review: > | "Logically, a null value is an empty object pointer" > Plainly false. Null is a primitive value. In java (not javascript) > Reference Variables can have the value null, and what is written above > is conceptually fine for programming in java, but the type of thinking > might be better off abandoned for javascript programming. Which is why I wrote "Some things in this chapter sound questionable". I suppose he tried to explain what `null` is from more general perspective. > > Javascript variables are untyped. Null is a primitive value in > javascript. It is best to think of it this way (reality) rather than > allude to concepts for other languages. Agreed. I would avoid use of "pointer" too. > > | "Certain statements cause a temporary addition to the front of the > | "scope chain that is later removed after code execution." > > There is a long standing bug in JScript (still in the latest in IE8) > where the parameter in a |catch| block does not result in augmented > scope for that block. Instead, the identifier is added to the containing > scope. > > Is this not mentioned? It is. Here's an excerpt: "There is a deviation in the Internet Explorer (IE) implementation of JavaScript, where the error caught in a catch statement is added to the execution context�s variable object, making it accessible even outside the catch block." > > | Chapter 5 is about reference types � Object, Array, Date, RegExp, etc. > > The terminology "reference types" is incorrect. Those are built-ins. The > Reference type is a specification mechanism. Yep, those are all of Object type of course. > > | Another misleading assertion was � "Though ECMA-262 doesn�t indicate a > | way to access the Global object directly [�]". > > Plainly false. In global context: > > var global = this; True. > > (and can be used as in the following: > | It�s not clear why Mr. Zakas didn�t provide and explain rather > | ubiquitous way of accessing Global object from within any context � > | (function(){ return this; })(); > ). > > > | Unfortunately, it starts somewhat badly by making few erroneous > | statements about function expressions > > Yep. > > The FAQ should really have a section on Functions. Or just a link to NFE article ;) > > | when simulating private variables it uses undeclared assignment to > | define variable as global one and does so on purpose! This is > | especially bizarre, > > and > > | Quite shockingly, an example of document.createElement specifics in IE > | is presented with blatant and completely unnecessary browser sniff. > > Not following his own advice, is he? Yes, it was weird to see that out-of-the-blue sniff. > > | I wish there was more emphasis on the dangers and fragile nature of > | browser sniffing in this part of the book. > > You already know where Nicholas stands on browser detection, so that > should come as no surprise. > <URL: > http://www.nczonline.net/blog/2009/09/15/iframes-onload-and-documentdomain/#comment-3121 Unfortunately, yes. > >> > > | It would be nice to see alternative example which would avoid run-time > | try-catch in favor of single load-time test > > I see. The performance video "speed up your javascript" also has an > example doing the same thing (against advice in that same video). YUI is doing it too. One could argue that it's a safer approach (testing features at run time) but I have yet to see an implementation where, say, one element would have certain property/method and another element (of the same type) � didn't. > > | There were moments when I didn�t share same vision as Mr. Zakas, such > | as the one where he recommends to use comments in places where there > | are large amounts of code; I believe in a different approach � > | breaking code into smaller, more understandable chunks, rather than > | adding comments on top. > > Your review should recommend your influence on advice for writing such > "clean code". Not sure what you mean here. > >> The book is pretty big and I didn't have much time, so the coverage is >> not as extensive as it could have been. However, it should serve as a >> pretty good overview, highlighting pros and cons, and warning about >> some of the errors/misconceptions I encountered. >> > Your review is already quite long. Looks like "Professional JavaScript" > needs more work. Sometimes, less is more. It does. Its foundation is good, but the book is definitely rough around the edges and could use some polishing. More importantly, though, it needs to get away from the mindset of supporting few modern browsers and, instead, employ a more defensive approach to cross-browser scripting. > > "7/10" is either something worth recommending or a C-. I'm not sure. If someone is looking for a book, this is the one I would recommend (and maybe Flanagan's too). However, nothing compares to reading specs, clj archives and constant practice. At least, this is how I grokked most of what I know about Javascript :) -- kangax |