Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Developer Reading List

, August 20, 2013 New books on Windows internals, JavaScript, Groovy, Python, and P=NP
  • E-mail
  • Print

Functional JavaScript

by Michael Fogus

I first came across Michael Fogus's work in his book The Joy of Clojure, which we recently excerpted. I was struck by the clarity of the prose, the meticulousness of the presentation, and the light thread of humor that ran through the text. Unlike many books today, I constantly wondered how the authors could present so much information without triggering a feeling of saturation or of excess complexity. Fogus (and his coauthor Chris Houser) found a way by use of remarkably clear presentation and a very thoughtful choice of examples.

Fogus has applied the same approach in this book, which explains how to do functional programming in JavaScript, using the Underscore.js library. The book is squarely aimed at experienced JavaScript developers as there is hand-holding through language basics. In contrast, advanced features of JavaScript that are pressed into service to accomplish his aims are explained in considerable detail. It is in some ways an excellent tutorial on little-understood mechanisms of the language.

But the real appeal is the presentation of functional programming. I can say with little expectation of being disproven that this book presents one of the finest explanations of functional programming available today. This is in part because of Fogus's style, but also because the book lacks the doctrinaire viewpoint that undercuts so many other presentations. Fogus does not try to convince you that functional is better than what you do right now, but rather explains the techniques and lets you slowly come to appreciate the value of the approach by yourself. I expect most readers will find themselves folding aspects of his presentation into their JavaScript without necessarily adopting the entire functional orientation.

The book covers the things you'd immediately expect: first-class and high-order functions, currying, purity, immutability, recursion, and related topics. What it doesn't contain is any discussion — or even mention — of Alonzo Church or lambda calculus. For which we can all be thankful.

The text pushes beyond these topics into component programming or composition, which is an architecture that dovetails well with the functional style. I had never particularly thought of JavaScript in the context of composition, but Fogus makes an excellent case for it by laying out some good examples and demonstrating how earlier concepts lead naturally to this approach. 

One of the most popular features we've run this year has been our Reading List of Must-Have JavaScript Books: Had this book been available then, it would have taken up one of the slots — and whatever book it displaced, its presence would have upgraded the list. Highly recommended.

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.