on November 9, 2006
If, like me, you know a few programming languages, but nothing about JS, and wanted a crash course so you could understand what all the fuss about the likes of Ajax or the Google Web Toolkit is, this is just what you need. So why am I only giving it three stars?
First, I thought some of the features weren't very well explained - the writing lacks clarity when describing important points. Compounding this, a few of the examples are poorly chosen. Some of my quibbles may seem picky, but the feel of the book is that it's pitched at an inexperienced programmer, and a lot of the time I only followed the discussion because I was already familiar with the material from other languages. Some particular points follow.
i) Accessing the length of various parts of a multidimensional array is illustrated with:
alert(threedPoints.length); // prints out 3
alert(threedPoints.length); // prints out 3
alert(threedPoints.legnth); // prints out 3
ignoring the error on the third line (more on that later), as can be seen from the comments, a three dimensional array has been created where every dimension is of length 3 - surely making them of unequal size would have been more illustrative.
ii) The example of the associative array manages to be even worse:
assocArray["one"] = "one";
assocArray["two"] = "two";
I struggle to think of an example that could be more misleading.
iii) While the author recognises the importance of regular expressions, and goes into reasonable detail, the material is not terribly well organised, and the examples become complicated too quickly.
iv) The section on chained constructors, and the use of call and apply is also unclear - disappointing, given I was most interested in the prototype style of object creation that JS uses.
v) The callback functions of Array are not well described. The function Filter, apparently, "ensures that elements are not added to any element unless they pass certain criteria". So, elements are not added to any element - huh? wha? Those familiar with the likes of Lisp, Python, and especially the iterators in Smalltalk and Ruby will be able to pick up what's going on, but newcomers may be baffled.
vi) The attempt to explain recursion is weak. Admittedly, most programming books do a bad job, but what's here is far too short to be useful. An illustrative quote is: "think of each iteration of the function call as pushing the string and numeric sum onto a stack, and when the numeric array has been traversed, the string and number have to be popped up through the stack to the top". I'm not saying this is wrong, but I do not believe that someone who's just been introduced to recursion would find this description helpful.
vii) Not all the programs have their output shown. This wouldn't be easy for some of the more complicated examples, but a lot of them are text-based.
Second, there are lots and lots of typos in the book. When even a JS noob such as myself spots them, you know there's something up. Fortunately, they're only minor, and they generally aren't sufficiently bad to mislead. As an example, when function literals are introduced, the rather vital keyword 'function' is missing, but the examples quickly clarify the matter. However, elsewhere, some of the code won't actually run as presented (as early as the second example, alas), and it does take the shine off the production. Either the technical reviewers were asleep, or the editors at O'Reilly ignored them. Someone ought to be embarrassed, at any rate.
on March 10, 2009
I am familiar with Shelley Powers' work, having read Unix Power Tools, a book that holds a special place on my shelf for its usefulness and depth. She is obviously someone who knows what she is doing.
This book states in the preface that, "Readers of this book should be familiar with web page technology, including Cascading Style Sheets (CSS) and HTML/XHTML. Previous programming experience isn't required, though some sections may require extra review if you have no previous exposure to programming."
My first exposure to programming was in 1981, using BASIC on a Radio Shack TRS-80 Color Computer. Over the years, I have studied (and often forgotten, but can certainly read a bit and understand the concepts of) LISP, C, Bash scripting, Perl, Python, and more. Lately I have spent more time using PHP and enjoying it, since that is the language of things like Wordpress, Drupal, vBulletin and other commonly used CMS and interactive web site software. The two sentences quoted above seem perfectly clear to me, but I can imagine what they must seem like to someone with no experience with programming languages. So, now you have been warned. Let's get to the good stuff for those who understand the jargon.
This book is clear, with enough detail to help you understand what is happening without bogging you down in the minutiae. The reader is expected to see how and why each facet of the language would be useful, so the examples given are simple and seem to be designed to help the reader get the feel for usage without pretending to be a cookbook of programming recipes, although some seem quite useful as they are, such as Chapter 6's code for browser detection, which allows you to modify content and/or how it is displayed based on the web browser being used to view your site.
on September 3, 2009
Other "beginning" O'Reilly books I have used relied on a tutorial model that starts with a "hello world" example and builds upon it to introduce more complicated concepts. Powers' book does indeed start with a "hello world" example, but does not build upon it. Instead, each chapter focuses on a particular facet and provides isolated examples that are not connected back to previous examples. It is arranged more like a basic reference text than a learning tool.
on November 13, 2009
The good part about this book, is that I am actually learning the material. The "test" questions at the end of the chapter range from simple to intermediate, and I can answer all of them correctly. I just wish it was a bit easier to read for us beginners.
on August 14, 2008
One does not read this book; one is tortured by it.
There are two major complaints I have with this book. The first is the number of errors in the text. (If you read another review of this book and it does not cite the problem with errors very early in the review, then you must be reading a review from Ms. Powers's fiance, sister-in-law, best friend, or cousin.) I have never seen anything close to this level of ineptitude in any other book I have ever read, programming-related or not. Just to tip-toe through this cow pasture:
- By my quick count, there are eighty-three errors listed on the book's errata web page. (It took me about two hours simply to go through the book and write in all of the corrections from the errata page.)
- Ms. Powers occasionally manages more than one error per page.
- Not only do the errors occur often, the arise early. There are errors in each of the book's first three Examples, with Example 1-3 alone mangaging to contain two errors.
- Beginning with Chapter 2, Ms. Powers concludes each chapter with a number of exercise questions - the answers to which are provided at the end of the book. Of the five Chapter 2 answers (i.e., the first five questions and answers in the book) there are errors in three.
- Page 11 is missing, well, two pages! The errata file contains ten paragraphs of text that is missing!
- Any number of errors are "simple" typos: the text uses a hyphen when there should be an underscore, variable names are misspelled, errant characters are enclosed, words are duplicated - that kind of thing. While this is sloppy and wholly unprofessional, one could argue that in The Grand Scheme of Things such errors are minor. However, a number of errors are more egregious. For example [all CAPS are mine]....
-On page 94 the book talks about how "the shift RETURNS the first element." Oops! The text should talk about how "the shift REMOVES the first element."
-On page 101 a sentence which begins "If a condition IS met...". Darn. It should read "If a condition ISN'T met..." (Details, details...)
-On page 127 a phrase "cascade means that the LOWEST..." should be (Anyone? Anyone? Class?...) "cascade means the HIGHEST..."
All in all, this is just shameful stuff. If you have a quasi-morbid sense of curiosity you might want to check out the Acknowledgments section which concludes Ms. Powers's Preface. There she thanks her editor, three "tech and content reviewers", a production editor, and a copy editor. I say "quasi-morbid sense of curiosity" because, presumably, all six individuals have since been, as the British like to say, "sacked."
All that said, let us gingerly put aside, for a moment, the stupefying number of errors in this book. How does it fare otherwise? (Or, to cite a quip I just love, "Other than that, how was the play, Mrs. Lincoln?")
Well, I come now to my second major complaint. Errors and typos aside, the book is just terribly written. The organization is dreadful and her grammar is rotten. In fact, the only thing I see Ms. Powers having done well is to compiled the epitome of how NOT to write a book on programming. The two essentials of a good book on programming are that the author:
1) Organizes the material in a logical, coherent manner. A GOOD author introduces essential concepts at the very beginning, and then steadily builds upon and expands upon what the reader has just learned.
2) Takes absolutely every pain to minimize 'jumping ahead' on topics.
Ms. Powers, however, repeatedly drags the reader into complex asides before bailing out by saying "but we will cover that topic later." She does this from the get-go, and it is maddening. Here are some examples from Chapter 1 ALONE...
- In a section about cross-browser incompatibility (p.4), Ms. Powers states most of these incompatibilities "are based on differences in the underlying Document Object Model (DOM) exposed by the browser...". She then goes on for a couple of sentences about why this is so. I, for one, knew next to nothing about the Document Object Model, and I bought the book, in part, because I saw that it contained a discussion of the DOM. Ms. Powers's in-depth discussion of the Document Object Model, however, occurs in Chapters 9 and 10! She should either have made these chapters, perhaps, numbers 1 and 2, or she should should avoid mentioning the DOM until the subject is covered.
- Later on the same page Ms. Powers goes through a discussion of how there used to be a language attribute for the <script> tag, and shows how this attribute was used to finesse the problem of writing script code that would work regardless of the browser being utilized to view one's web site. She then writes, "Eventually, though, the preference shifted to an approach called 'object detection' - a move only encouraged when the language attribute was depracated. We'll look at object detection more closely in later chapters, particularly those associated with Ajax. For now, object detection involves testing to see if a particular object or property of an object exists..." Argh!!! Once again Ms. Powers befuddles the reader. She throws out this new and confusing concept called "object detection", but then tells you she won't explain it until later in the book! It would have been much easier had she simply said something like "The language tag has been deprecated, so the approach just shown no longer works. The current method for dealing with cross-browser incompatibility will be discussed in full later in the book, in the section on Ajax." Much simpler, eh??
Ummmm.... I would recommend one NOT buy this book. (At least not for reading....)
on December 2, 2006
Though these chapters really give you a lot of detail on the technical aspect of the language such as: equality with strings and objects, ternary operator, FIFO queue array techniques, anonymous functions, function closure and memory leaks. These more advanced topics I've never seen before in basic introduction chapters before. It was really interesting re-learning the basics with reviewing some new techniques and ideas.
on December 2, 2010
While the author clearly knows what she's talking about, the way the information is presented in this book, it's very difficult to follow at times unless you are an experienced programmer. It reads less like a friendly instructor bending over your shoulder guiding you along, and more as someone standing at a podium reading from an encyclopedia using incredibly distilled language that gets quite tedious after a while. As others have already pointed this out, I thought I would include some specific examples to illustrate.
Here is a sample of text from Chapter 7:
"The XHTML transitional and strict DOCTYPEs trigger standards mode for most browsers, depending on whether the page is served up as XHTML with an optional XML prolog."
I had to read this several times to first find the verb. At no time is 'transitional' defined, nor is the concept of 'XML prolog'. It's mentioned once here and then dropped. Head swimming. I want to roll up this sentence and toss it back.
Not to belabor the point, but there was one needlessly complicated example (5-5) to illustrate embedded functions where a function is called from within a return statement from inside a function inside another function. This makes my head want to explode. I wish the author spent at least a paragraph trying to explain exactly how this would work, because it's not at all clear.
The book is broken into four sections:
Chapters 9 through 11 cover more sophisticated aspects of web-page development. These chapters cover the Browser Object Model and the Document Object Model, and show how to create custom objects. Understanding these models is essential for creating new windows and individually accessing, modifying, and dynamically creating page elements. In addition, with custom objects, you can then move beyond the capabilities that are prebuilt into either language or browser.
Chapter 1, Introduction and First Looks
Chapter 3, Operators and Statements
Chapter 5, Functions
Chapter 6, Catching Events
Focuses on event handling, including both the original form of event handling which is still commonly used in many applications, as well as the newer DOM-based event handling.
Chapter 7, Forms and JiT Validation
Chapter 8, The Sandbox and Beyond: Cookies, Connectivity, and Piracy
Chapter 9, The Basic Browser Objects
Chapter 10, DOM: The Document Object Model
Focuses on the Document Object Model, a straightforward, but not trivial, object model that provides access to all document elements and attributes. There are documents that are based in XML as well as HTML. Though the model is comprehensive and its coverage is fairly straightforward, there could be some challenging moments in the chapter for new programmers.
Chapter 12, Building Dynamic Web Pages: Adding Style to Your Script
Provides a general introduction to some of the more commonly used Dynamic HTML effects, including drag and drop, collapsing and expand page sections, visibility, and movement. Some understanding of CSS is required.
Chapter 13, Moving Outside the Page with Ajax
Chapter 14, Good News
Covers some of the more popular libraries you can download and use for free including Prototype, Sabre's Rico, Dojo, MochiKit, Yahoo User Interface, and aculo.
on January 13, 2007
on December 4, 2006
This is not a book for beginners. Let me repeat: this is not a book for beginners. Although the Preface states, "Readers of this book should be familiar with web page technology, including CSS and HTML/XHTML ... [p]revious programming experience isn't required, though some sections may require extra review if you have no previous exposure to programming," there is a strong assumption from the start that the reader at least (a) has some experience with current programming concepts and practices, (b) has some experience with web page coding and practices, or (c) has a lot of time to learn (a) and (b) while working through the book. That said, however, this really is an excellent resource.
The book seems fast paced, and often left me wishing there were more detailed explanations of some of the examples. But the concepts and examples are interwoven, so just working through the book brought some understanding. The end of each chapter has review questions, with the answers at the end of the book, for those who find that helpful. But what impressed me was that the errata sheet is already available at O'Reilly. There are a few errata, and they'll be handy to know if you're trying the examples given in the book. Additional resources are also sprinkled throughout the book which all appear to still be working.