JavaScript for Programmers

Author: Paul J. & Harvey M. Deitel
Publisher: Prentice Hall, 2010
Pages: 448
ISBN: 978-0137001316
Aimed at: Experienced developers new to Javascript
Rating: 3
Pros: Will suit programmers with a C background
Cons: Overlooks powerful features that make Javascript different
Reviewed by: Ian Elliot

Overall this book misses the mark by not focusing on the aspects that make Javascript special.

 

If you know any other books in the Deitel series you will know what to expect of this book. They are all very dry and very straightforward presentations of the material. In some cases this works better than in others.

 

Banner

 

In this instance what we have is a presentation of Javascript as if it were any ordinary language with loops, if statements, functions, objects and methods. However, Javascript is different. It is an interpreted language with many interesting features such as functions as objects, closure, dynamic typing, prototype based inheritance, dynamic execution, self modifying code and so on. There is also the fact that most of the time Javascript runs in a very special and rich environment - i.e. the web browser. Using Javascript is as much a matter of how it interacts with HTML and the DOM as it is about language details.

This book does deal with issues such as HTMl, CSS and so on but more as a distraction than a careful explanation of how Javascript interacts with its environment.

This is essentially a book on how to program in say C or basic C++ translated into Javascript. For example, space is devoted to explaining recursion but recursion isn't much used in Javascript except in very special situations. The reason is simply that most Javascript doesn't work with complex data structures - except of course for the DOM where the build in functions usually mean you can avoid recursion - always a good idea.

Chapter 1 is a waffley introduction, explaining the history of the Internet and web development in particular. You can skip straight to Chapter 2, where we have an introduction to XHTML, and Chapter 3, where we have an exposition of CSS. Of course you can skip both of these chapters if you know HTML/CSS as there is nothing new introduced.

Chapter 4 is where we first get to grips with Javascript  and we are soon building a Hello World type program using nothing but a text editor and embedded Javascript. The chapter ends with an attempt to introduce data types but only succeeds in saying that Javascript doesn't bother. Chapters 5 and 6 introduce the Javascript control structures. Almost at once we are thrown in the deep end with nested if statements and how to resolve ambiguities of nesting. If you are a beginner you simply aren't going to follow and you simply aren't going to care. You probably shouldn't be writing such deeply nested if statements anyway. Then when we get to logical expressions everything is presented as traditional truth tables with just a final mention of truthy and falsey. I'm not suggesting that this sort of subtlety should be early in a book, but it is the sort of thing that makes Javascript different and it deserves a prominent place if Javascript is to be written in a style that suits it rather than C.

Chapter 7 introduces functions, a core idea in any language. At first we are introduced to functions as chunks of reusable code, then as event handlers and finally the chapter ends with a consideration of recursion - which is too advanced a concept for an introduction to functions.

Chapter 8 moves us away from instructions to consider data structures in the form of the array and only then do we finally move on to consider Javascript objects in Chapter 9. Object are introduced in the classical way - classes, properties and methods - despite the fact that Javascript doesn't have classes. You could argue that it's good to see the wider picture and therefore explaining classical objects is better - but in this case it just seems lazy. After this introduction we are told about the supplied objects including objects normally regarded as part of the DOM. Chapter 10 is about using the DOM in detail and we find out how to navigate the DOM hierarchy.

Chapter 11 is a detailed look at events and writing event handlers and this is the point where the investigation of Javascript as a web programming language more or less comes to an end - without any discussion of creating objects, building object-oriented widgets, prototype inheritance, how best to load and manage scripts, dealing with browser incompatibilities and so on. Instead Chapter 12 takes is into XML and RSS - interesting topics but not core Javascript.

Chapter 13 is the obligatory chapter on Ajax with a tiny bit on the Dojo framework. When there is still so much more to say about Javascript it seems well off-track to discuss these more advanced and specialized facilities.

Overall this is, perhaps surprisingly, a good book if you want to learn how to write Javascript as if it was C and need an introduction to the language and its associated technologies. However, if you want to learn Javascript and make use of some of its unique features to create innovative scripts you need to find a different book. 

Banner


Python Distilled (Addison-Wesley)

Author: David Beazley
Publisher: Addison-Wesley
Date: September 2021
Pages: 352
ISBN: 978-0134173276
Print: 0134173279
Rating: 4
Reviewer: Alex Armstrong
Python isn't a big language but it's getting bigger all the time.



Python Programming with Design Patterns

Author: James W. Cooper
Publisher: Addison-Wesley
Date: February 2022
Pages: 352
ISBN: 978-0137579938
Print: 0137579934
Kindle: B09D2RKQB5
Audience: Python developers
Rating: 1
Reviewer: Mike James
There was a time that design patterns were all the thing. Not so much now. But Python - does it have [ ... ]


More Reviews

Last Updated ( Wednesday, 23 June 2010 )