Monday, April 20, 2009

Book Review: JavaScript for Programmers

Authors: Paul J Deitel and Harvey M Deitel Format: Paperback, 448 pages Publisher: Prentice Hall PTR; 1st edition (March 26, 2009) ISBN-10: 0137001312 ISBN-13: 978-0137001316 When I saw the title, I assumed that this was a somewhat advanced book and not for the reader who was learning JavaScript for the first time. I work for a company that develops web applications, and they make extensive use of JavaScript. Each of the developers is well versed in JavaScript and other web programming languages, and I thought this was a JavaScript book for the experienced programmer. With that assumption in place, I was surprised to see a comment on the back of the book state "One of the best introductions to JavaScript" (from a pre-publication review by Raymond Wisman, Indiana University Southeast). An "introduction" to JavaScript? Even a casual scanning of the back cover reveals that the book is supposed present a vast cornucopia of JavaScript related topics. Deitel and Deitel have written quite a number of programming books, so I was interested to see if this indeed was a book where one could learn JavaScript from scratch. The Deitels have written a significant number of "How to Program" books for languages including C, C++, Java, and Visual Basic, but no "How to" book appears on their website (until this one apparently) for JavaScript. Why not "JavaScript How to Program" instead of "JavaScript for Programmers" if this is a beginner's book? Despite the title, the book is structured for the "extreme" beginner, starting with the history of the Internet, the World Wide Consortium (W3C), Web 2.0 and so on. Going through the Preface material, I found a lot of information, especially about Deitel and Deitel, as well as Deitel and Associates, Inc. (apparently, they like to promote themselves a lot, but after all, business is business), but nothing that specifically stated the identity of the target audience. Since the book is structured to present XHTML and CSS first, I could only imagine that the book would be suitable for someone who didn't know those technologies. The majority of the book (eight chapters) is devoted to JavaScript (as it should), while the two ending chapters contain content on XML, RSS, and Ajax. That's quite an ambitious mouthful to teach the newcomer to web development. Anxious to try out the book, I dutifully followed the Before You Begin instructions and attempted to download the source code from the listed link: www.deitel.com/books/jsfp/. That's when I got a big disappointment in the form of a "The page cannot be found" error. I rechecked the URL and I had typed it as printed in the book. I went to the Deitel site to see if I could just navigate to the source code, but not only was the code not present, there was no mention of the book at all. I went to the publisher's site to see if perhaps the source code was there. I did find it and I could download the source code for chapters 2 through 13, I'd need to download the files for each chapter as individual zip files. I looked for an errata page at InformIT to see if a change had been made regarding the stated location of the source code, but there was none. The errata page at the Deitel site didn't mention the book at all. I don't mind doing my research when I'm learning something, but I wouldn't expect the reader to have to work this hard when they're not even in Chapter 1 yet. I skipped the Chapter 1 history lesson and opened the book to Chapter 2, since I'd downloaded the sample code for the chapter. The zip file contained a number of rather simple HTML files. Nothing to write home about, but I guess you'd expect that if you were starting from the beginning. Actually, Chapter 2 is a crash course on HTML, including how to create lists, tables, forms, and links. The information was compressed, but entire books are written on basic HTML, and I wondered if the complete beginner was supposed to "get it" in one brief chapter. The very last entry in the chapter though, was a link to a page on the deitel.com site containing all kinds of external links to information and tutorials on HTML. Apparently, the Deitel site is supposed to provide serious support to this book (lack of code samples or even a mention that the book exists aside). Chapter 3 was the other bookend to Chapter 2 and offered up a quick and intense course in CSS to the reader, with another link at the end to a web page packed with external links to all things CSS, including books on CSS by other publishers such as O'Reilly. I was beginning to see that, depending on the reader's level of experience and how quickly they learned, it might take awhile to work through this book. If I knew nothing about HTML and CSS and I only had 2 chapters in a book to teach me those languages, I might end up spending some time on the recommended links pages on the Deitel site, doing a bit of self study before tackling the JavaScript section. I rather expected the JavaScript chapters to be more self contained than the others, since its the main focus of the book. While that's true, I did find that the end of each JavaScript chapter did include a link to a JavaScript resources page on the Deitel site, so the book is written with the general philosophy of the web containing everything the book can't. As I continued to move through the book, I was taken on a path using more "baby steps" as bit by bit, the JavaScript tutorial began to unfold (if you'll pardon the mixed metaphor). I will admit, I didn't download each of the chapter's code examples (I may later and, if what I find is significant, I'll publish an update to this review), but what I saw did seem to work. That's important, since one of the common complaints I hear from programmers, is that sample code often doesn't work as advertised, as if the code were never tested and debugged prior to the book being published. The good side of this book is that it is written to take the very beginner from basic XHTML and CSS and gently help them through the process of learning how to program in JavaScript. The bad side is that the reader has to work up front to even find the sample code, and it's as if Deitel and Deitel didn't think enough of their latest work to even mention it on their site. For a company that creates training material for a living, that's not a very good way to back up their book. Good thing the support pages were accessible with all of their external links to a wider collection of tutorial material. They say a first impression is a lasting impression. If that's so, no matter how good the later parts of this book are written, getting past the first bits didn't help my first time experience with a Deitel book.