Eloquent JavaScript (2e)

Author: Marijn Haverbeke
Publisher: No Starch Press
Pages: 472
ISBN: 978-1593275846
Print: 1593275846
Kindle: B00QL616UU
Audience: Complete begiiners
Rating: 3
Reviewer: Ian Elliot


Is this the "modern introduction to programming" that its subtitle claims it to be? 

JavaScript is a much misunderstood and misused language so there really is a need for a book that teaches it right. This book, now in an extended second edition, goes someway towards this goal, but overall it is just another Java-style, object-oriented-style, book. JavaScript is special in that it doesn't use inheritance and its functions are objects and it deserves an approach which emphasizes these differences. 

The new edition is divided into three parts with the final part being mostly new. 




Part 1 is called Language and it is an introduction to the core language without much attention to its environment - e.g. the browser. 

Chapter 1 proper begins with a look again at the very basic things that a complete beginner would need to know. What's a value, what's a variable and flow of control. The chapter starts very slowly but the level starts to ramp up.  By the end of the chapter we are dealing with automatic type conversion, Boolean operators and lazy evaluation.

The treatment of program structure has been split out into a new chapter which is sensible but it is still a very fast introduction to some very brain changing ideas. The big problem is that if you program you think this stuff is easy because it is second nature to you - but not to your readers. The ideas are introduced in a logical order but with little help for the complete beginner. It almost reads like a manual listing each syntactic form. There is very little guidance about how to think about what is being taught. For example, the break and continue statements are introduced but there is nothing about why or when you should use them. 

Chapter 3 is about functions and it still attempts to start slow and be kind to the beginner, but the pace, level and language is getting tougher all the time. The introduction of "Nested Scope" on the fourth page of the chapter just after dealing with elementary topics should give you an idea of what I mean. We next have discussions of the call stack, returning values and closure. If the introduction of closure in a first look at functions doesn't convince you that the level is going well above the beginner, then perhaps recursion on page 50 will. At this point you also can't avoid the conclusion that this really is a Java-style programming book moved to JavaScript. The fact that functions are objects is completely ignored which means you get no idea that functions have a lifetime, just like any object and this is what closure is all about. 

From here on each chapter starts with an attempt to appeal to the beginner but rapidly spirals off into esoteric and difficult subjects. Chapter 4 is about data structures - objects and arrays.  This starts off as a complete beginner's intro to objects but after a few pages it is diving into mutability - in a way that makes it seem mysterious. It states that a string in JavaScript is imutable in the sense you cannot change it but doesn't really explain what this means. The beginner who identifies the idea of a string with the characters that make it up thinks that if course the string can be changed because I can write

mystring=mystring+" World";

See mystring has changed - its mutable! No it isn't but exactly how mystring was changed in this interaction isn't explained and its subtle. 

Chapter 5 delves into function more deeply into function but as higher order functions rather than functions as objects. The next chapter introduces objects in more detail. It does take a prototype approach at first but it just isn't deep enough. For example there is a brief mention of instanceOf but no discussion of how this gets set or how relying on it can go horribly wrong. 

Chatper 7 is a nice project - a simulation. One of the good features of the book are the very readable projects that are included in many of the chapters. 

From here we move on to error handling, regular expression and modules. In each case there is a competent account of the basic ideas. The section finishes with a another project - implementing a programming language. 




Part II is about JavaScript in the browser and this is essentially a long course on working with the DOM in raw JavaScript. This is something that most JavaScript programmers would get help with by using a toolkit like jQuery to smooth out browser differences. After a chapter on how the web works - HTML and so on we find out how to manipulate the DOM. Chapter 14 is all about event handling and it goes into a lot of detail about particular event types - key events, mouse events and so on.

Next we have a nice project - a platform game - but why put it just before Chapter 16 which is about drawing on Canvas and graphics in general? The following chapter is called HTTP, but it really should be called Ajax as it deals with using XMLHttpRequest. Again, this is done using raw JavaScript rather than a toolkit such as jQuery and nothing is said about browser differences. This is also the place that Promises are introduced in a way that suggests that they are really only useful for Ajax requests. when of course they are generally useful in dealing with asynchronous programming. Chapter 18 explains the client side of forms which is only half the picture and finally we have a paint program project.

The big problem with Part II is that it doesn't introduce any help from toolkits such as jQuery. You can say that it is good to have a raw JavaScript approach because it is more efficient and not every DOM manipulation needs a toolkit. However the issue of browser incompatibilities isn't touched on and you do have to cope with the fact that there are still older browsers in use. 

Part III is called "Beyond". What could be beyond? 

Chapter 20 is a short introduction to Node.js. Chapter 21 is a project a skill sharing website and the final chapter is on performance.  

I enjoyed reading this book. The author has a light style and there nice quotes at the start of each chapter and a few cartoons. The big problem is that this is not a beginner's book because it has too many advanced ideas jammed up against simple things. It isn't an advanced programmer's book either for the same reason. 

A more serious problem is that for book called Eloquent JavaScript it doesn't seem to get at the heart and soul of the language. It doesn't emphasize any of the unique aspects of this most different of languages. It gives an account of the language as if it was Java or C# with a few peculiarities. You don't get any flavor of functions as objects, the logic of "this", how prototype inheritance works, what closure is for and so on... If the nicer elements of JavaScript are missing so are the nasty bits. There is no discussion of hoisting, truthy/false and many of the techniques needed to keep JavaScript under control. There is also not much guidance as to the slightly different versions of the language and the way browser compatibility is a problem. 

This is a nicely written, nicely produced book, but it doesn't really do its subject justice. 



Principled Programming

Author: Tim Teitelbaum
Publisher: DateTree Press
Date: March 2023
Pages: 429
ISBN: 978-8987744109
Print: B0BZF8R467
Audience: General
Rating: 5
Reviewer: Mike James
Principled Programming - what else would you want to do?

Machine Learning with PyTorch and Scikit-Learn

Author: Sebastian Raschka, Yuxi (Hayden) Liu & Vahid Mirjalili
Publisher: Packt
Date: February 2022
Pages: 770
ISBN: 978-1801819312
Print: 1801819319
Kindle: B09NW48MR1
Audience: Python developers interested in machine learning
Rating: 5
Reviewer: Mike James
This is a very big book of machine le [ ... ]

More Reviews

Last Updated ( Saturday, 12 September 2015 )