Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror

+ - Eloquent JavaScript: A Modern Introduction to Programming

Submitted by Michael Ross
Michael Ross (599789) writes "Eloquent JavaScript: A Modern Introduction to Programming Marijn Haverbeke 3 February 2011 978-1593272821 No Starch Press 224 pages A concise and lighthearted tutorial on this popular web programming language. 9/10

Of all the computer programming languages, JavaScript may be enjoying the most unprecedented renaissance ever. Once derided as a toy language suitable only for spawning bothersome popups in browser windows, JavaScript is rapidly developing into a first-choice web technology on both the client side and the server side. One way to get started learning this ubiquitous language is the book Eloquent JavaScript: A Modern Introduction to Programming.

Written by Marijn Haverbeke, the book was published by No Starch Press on 3 February 2011, under the ISBN 978-1593272821. On the publisher's page for the book, visitors will find the table of contents and some reviews. (My thanks to the publisher for a review copy.) The author's book website offers much more, including HTML versions of the book (whose content differ from the print edition), errata (applicable only to the first printing of the paper edition), and an interactive code sandbox where you can run the examples (or at least some of them).

At a slender 224 pages, this volume might at first glance appear inadequate for covering such a sizable and rich language as JavaScript — and yet the table of contents suggests otherwise, with a dozen chapters covering language basics, functions, objects, arrays, error handling, functional programming, object-oriented programming, modularity, regular expressions, web programming, the DOM, browser events, and HTTP requests. In addition, readers may be reminded of how much information Kernighan and Ritchie were able to pack into the 228 pages of the first edition of their classic The C Programming Language.

Following a pleasant introduction, the first three chapters present the basics of JavaScript. In the first one, the author presents the language's fundamental grammar, specifically: values, data types, arithmetic operators, expressions, variables, control statements, the JavaScript environment, and program structure. The material assumes no prior knowledge of computer programming or even data representation.

In the second chapter, the author does a thorough job of explicating all aspects of functions, including definition form and order, variable scope, arguments, the call stack, closure, and other topics. The subsequent chapter addresses an area important to any programming language, namely, data structures — which in JavaScript are of two varieties, objects and arrays. The author illustrates some best practices, such as modularizing code.

Most programming books underemphasize or even completely neglect the critical topic of error handling, and thus it is encouraging to see the author of this book address it, as early as Chapter 4. He focuses on exception handling, and also touches upon the value of unit testing (incorrectly termed "automated testing"). The subsequent chapter describes functional programming, which is not to be confused with procedural programming, but rather refers to combining functions in order to achieve higher levels of abstraction in one's code, thereby reducing its size and better exposing its functionality amidst the syntactical clutter. One apparent technical flaw is the claim that, in HTML documents, the special characters <, >, and & always must be replaced by their entity values, even when surrounded by whitespace characters (page 78). (Incidentally, any book that mentions the KGS Go Server can't be all bad.)

Object orientation is the subject of the sixth chapter, the longest in the book. Despite the author's efforts, this material will likely prove to be the most challenging to readers, given the numerous idiosyncrasies of JavaScript's objects and their built-in methods. The next chapter explores a related topic, modularity, which unfortunately is not supported natively by JavaScript; the author presents some ideas to work around this limitation.

Of all the data processing performed by web sites and apps, a significant portion of it is text manipulation, where the use of regular expressions can be extremely valuable, despite the potential pitfalls. This is tersely covered in Chapter 8, which, in my opinion, should instead be located far earlier in the book, after the discussion on strings. The next chapter is a fast-paced examination of just some of the key aspects of client-side scripting using JavaScript. The only confusing portion is the reference to "the document tag" (page 155), with no explanation as to what that is. The last three chapters continue the discussion of in-browser programming, focusing on the Document Object Model (DOM), browser events, and HTTP requests. Some of the material feels dated, but it is a decent survey of relevant information.

The narrative is well written, aside from the use of long dashes when semicolons are called for and the occasional strange phrasing, such as "two backslashes follow each other" (page 12). Also, the book contains several erratum, most of them a simple mismatch of singular and plural forms: "The example show" (page 11), "executing a statements" (20), "is a special kind of objects" (46), "special type of objects is" (68), "with is em" (89; should read "is em"), "than of an" (90; should read "than an"), "new type of objects" (123), "used as to map" (146), "on [the] current field" (185), and "touched on [in] Chapter 9" (190).

The author wisely makes use of numerous examples, which are of two types: Most if not all of the fundamental concepts are illustrated with pithy examples — particularly in the first half. In Chapters 3, 5, 6, and 11, the author utilizes extended, fictional examples. Some readers may argue that these longer ones are excessively so — especially the terrarium — but there are many nuggets to be found in those pages. In fact, the book overall is largely free of fluff.

In terms of technical information, the book does not attempt to cover all the details of the language itself. Readers will appreciate that the author does not shrink from pointing out the weaknesses in JavaScript, as well as explaining the problems they may cause. One blemish is that many of the small sections of code contain a mixture of complete lines of code as well as standalone expressions (in bold), and usually those expressions are terminated with semicolons, giving them the appearance of lines of code. No doubt some readers will be confused by this convention.

From a production standpoint, the text is quite readable, except for the quite annoying and obvious problem that the font to indicate in-line source code looks almost identical to the non-code text font. There are few diagrams and even fewer screenshots, but that poses no difficulties.

At times this book is even fun to read, partly because of the use of non-silly humor, especially in the two examples of the eccentric (and cat-centric) aunt, and an unsocial reclusive programmer (imagine that).

If you choose to start your JavaScript journey with this book, it can quickly teach you a lot of technical information (relative to its size), and also programming wisdom.

Michael Ross is a freelance web developer and writer."
This discussion was created for logged-in users only, but now has been archived. No new comments can be posted.

Eloquent JavaScript: A Modern Introduction to Programming

Comments Filter:

Memory fault -- brain fried

Working...