The Programmer as Author in 'If Hemingway Wrote JavaScript'

This inventive and engaging book imagines what JavaScript might look like in the hands of 25 writers, including William Shakespeare, Jane Austen, Tupac Shakur, and J.K. Rowling.

If Hemingway Wrote JavaScript

Publisher: No Starch Press
Length: 192 pages
Author: Angus Croll
Price: $19.95
Format: Paperback
Publication Date: 2014-10

Imagine you have Ernest Hemingway in a room, and you can ask him anything you wish. I’d probably want to know if Heaven had turned out to be the big bull ring he’d hoped for. But when Twitter engineer Angus Croll encountered the author in a dream one night, he took a different approach. Croll challenged Hemingway to turn his talents to JavaScript and write a function that would return the first number of the Fibonacci sequence. To Croll’s surprise, Papa Hemingway did it -- and it worked.

Well, what if Hemingway wrote JavaScript? What would that look like? A master of the economy of words, he might develop programming language that would meet the industry standard of function and efficiency. His imagined answer to the Fibonacci problem Croll provides is simple and direct but undeniably effective. “Hemingway’s JavaScript is plain and clear,” Croll explains, “and it does only what is necessary -- and then it gets out of the way to allow the full glory of the Fibonacci sequence to shine through.” Croll doesn’t limit himself to Hemingway, however. His inventive and engaging book imagines what JavaScript might look like in the hands of 25 writers, including William Shakespeare, Jane Austen, Tupac Shakur, and J.K. Rowling.

Each author is brought back to life by Croll’s text and tasked with an assignment. Kerouac jazzes up factorials, and Salinger lets Holden Caulfield muse on unhappy numbers ("Only five numbers are really happy, that kills me"). The result of these thought experiments is clever, quirky, and absolutely executable code. If Hemingway Wrote JavaScript deftly explores the creative possibilities of programming through a series of such inspired imaginary scenarios.

Croll presents five different JavaScript tasks and assigns five authors to each. All of the authors are introduced by an encyclopedic sketch of their major works and Croll’s thoughts on them. After this, the program the author is tasked with coding is presented, upon which Croll proceeds to critique the code like one might a work of literature. He refers to Austen, for instance, as “nothing short of a well-mannered revolutionary,” describing how her fiction both emulated and ridiculed the dominant 18th-century genre of the sentimental novel. In this manner, his Austen critiques the conventions of JavaScript within her very response to Croll’s factorial assignment:

1 var factorial = (function() {

2 //She declared the ledger to be very plain. But with the happiest prospects!

3 var ledger = {};


5 return function reckoning(quantity) {

6 if (isNaN(quantity)) {

7 console.log(“I have not the pleasure of understanding you.”);

8 return;

9 }

10 //It is a truth universally acknowledged that two values an only be judged

11 //truly agreeable by means of the treble equal symbol…

12 if (quantity === 0) {

13 return 1;

14 }

And on it goes. Croll the JavaScript critic proceeds then to offer a close reading of Austen’s work, determining that while it initially appears “submissive, yielding to every overbearing commandment and pious proclamation set forth by the more pedantic leaders in our community,” it actually serves as a parody of the “social norms” of JavaScript. He provides just enough context and analysis to let the reader in on the joke, using Austen as a model of how to produce code that has fun with its own functionality.

In presenting five different takes on the same JavaScript challenge, Croll not only displays his understanding of and appreciation for the authors whose guises he adopts but also for the incredible diversity of programming language. He approaches this task with a certain joyful curiosity that proves contagious throughout the text. If Hemingway Wrote JavaScript talks back to Douglas Crockford’s JavaScript: The Good Parts, which sought to divide the programming language into its “good” and “bad” parts, emphasizing efficiency first and foremost.

JavaScript does not have to merely function; it must function, but the means to arriving at that point allot for individual technique, as Croll’s author portraits show. Programming possesses personality and style. While we have yet to see an anthology analyzing the quirks and creativity of individual programmers, this volume is perhaps a step in that direction, with Croll revealing the humanity in digital language in this conflation of famous literary figures with familiar programming idioms.

Compared to other programming, Croll considers JavaScript more creative than prescriptive. “The best authors and the best Javascript developers,” he writes, “are those who obsess about language, who explore and play with it every day and in doing so develop their own idioms and their own voice.” Every literary author Croll includes has their own recognizable style, allowing him to extrapolate that voice, translating its essence and idioms into another genre of writing. Just as we analyze the style of particular literary authors’ work, we should also consider the unique touch each programmer brings to their tasks. If you study open source code and repeatedly encounter the same person’s work, you might get a sense of their personality from how they code. Likewise, Croll demonstrates his familiarity with and affection for the authors he features by imagining what their programming would look like.

If you’re a Jorge Luis Borges aficionado, there’s a decided pleasure in judging if Croll’s interpretation of Borges-as-programmer reads as authentic. If you’re unfamiliar with the work of Arundhati Roy, on the other hand, and you find yourself drawn to her non-linear approach to Croll’s chainable function assignment, you might be inclined to pick up The God of Small Things after reading this book.

If you know next to nothing about JavaScript but love literature, this book might not be for you. To fully appreciate Croll’s portraits of famous authors as programmers, some familiarity with basic JavaScript seems, if not necessary, certainly more illuminating. If you know the most basic way to write a function that returns the first 15 numbers of the Fibonacci sequence, seeing the unique approaches that Hemingway, Shakespeare, André Breton, Robert Bolaño, and even Dan Brown take offers greater insight into the personality and styles of the authors as well as the diverse programming possibilities.

Croll may not have set out to write a "how to do JavaScript like Hemingway" textbook, but he does express a desire to create a bridge between the humanities and the technology industry. He notes that students of the humanities could be highly valuable in software development because they’re “more likely to have an inductive, open-ended approach to reasoning; they’re more likely to probe beyond the standard methodologies; and they’re more likely to question accepted practices.” I would be quite interested to see an additional volume from Croll more in this vein, one that seeks to engage the beginning programmer and, through drawing connections between literary language and programming language, teach JavaScript.

Croll effortlessly explains Shakespeare’s use of iambic pentameter, elucidating the structure and analyzing how the Bard both skillfully commands and breaks away from the poetic meter. In highlighting how Shakespeare is able to add dramatic emphasis by at key moments deviating from that poetic meter, Croll provides a useful connection between poetry and programming. Both languages have their formulas, and both can be experimented with once you’ve learned the rules.

While If Hemingway Wrote JavaScript will likely appeal most to those acquainted with coding and Kerouac, programmers who wish to approach JavaScript more creatively should find inspiration here, and even the non-programmer can likely appreciate Croll’s enthusiasm and literary humor. Miran Lipovača’s illustrations lend the book even more personality, providing portraits of the authors that capture their quirks just as much as Croll’s coding does. If Hemingway Wrote JavaScript encourages its readers to play with language and, like the authors whose guises Croll adopts throughout, find their own voices.

Splash image: Illustration of William Shakespeare by Miran Lipovača, in If Hemingway Wrote JavaScript.





Run the Jewels - "Ooh LA LA" (Singles Going Steady)

Run the Jewels' "Ooh LA LA" may hit with old-school hip-hop swagger, but it also frustratingly affirms misogynistic bro-culture.


New Translation of Balzac's 'Lost Illusions' Captivates

More than just a tale of one man's fall, Balzac's Lost Illusions charts how literature becomes another commodity in a system that demands backroom deals, moral compromise, and connections.


Protomartyr - "Processed by the Boys" (Singles Going Steady)

Protomartyr's "Processed By the Boys" is a gripping spin on reality as we know it, and here, the revolution is being televised.


Go-Go's Bassist Kathy Valentine Is on the "Write" Track After a Rock-Hard Life

The '80s were a wild and crazy time also filled with troubles, heartbreak and disappointment for Go-Go's bass player-guitarist Kathy Valentine, who covers many of those moments in her intriguing dual project that she discusses in this freewheeling interview.


New Brain Trajectory: An Interview With Lee Ranaldo and Raül Refree

Two guitarists, Lee Ranaldo and Raül Refree make an album largely absent of guitar playing and enter into a bold new phase of their careers. "We want to take this wherever we can and be free of genre restraints," says Lee Ranaldo.


'Trans Power' Is a Celebration of Radical Power and Beauty

Juno Roche's Trans Power discusses trans identity not as a passageway between one of two linear destinations, but as a destination of its own.


Yves Tumor Soars With 'Heaven to a Tortured Mind'

On Heaven to a Tortured Mind, Yves Tumor relishes his shift to microphone caressing rock star. Here he steps out of his sonic chrysalis, dons some shiny black wings and soars.


Mike Patton and Anthony Pateras' tētēma Don't Hit the Mark on 'Necroscape'

tētēma's Necroscape has some highlights and some interesting ambiance, but ultimately it's a catalog of misses for Mike Patton and Anthony Pateras.


M. Ward Offers Comforting Escapism on 'Migration Stories'

Although M. Ward didn't plan the songs on Migration Stories for this pandemic, they're still capable of acting as a balm in these dark hours.


Parsonsfield Add Indie Pop to Their Folk on 'Happy Hour on the Floor'

Happy Hour on the Floor is a considerable departure from Parsonsfield's acclaimed rustic folk sound signaling their indie-pop orientation. Parsonsfield remind their audience to bestow gratitude and practice happiness: a truly welcomed exaltation.


JARV IS... - "House Music All Night Long" (Singles Going Steady)

"House Music All Night Long" is a song our inner, self-isolated freaks can jive to. JARV IS... cleverly captures how dazed and confused some of us may feel over the current pandemic, trapped in our homes.


All Kinds of Time: Adam Schlesinger's Pursuit of Pure, Peerless Pop

Adam Schlesinger was a poet laureate of pure pop music. There was never a melody too bright, a lyrical conceit too playfully dumb, or a vibe full of radiation that he would shy away from. His sudden passing from COVID-19 means one of the brightest stars in the power-pop universe has suddenly dimmed.


Folkie Eliza Gilkyson Turns Up the Heat on '2020'

Eliza Gilkyson aims to inspire the troops of resistance on her superb new album, 2020. The ten songs serve as a rallying cry for the long haul.


Human Impact Hit Home with a Seismic First Album From a Veteran Lineup

On their self-titled debut, Human Impact provide a soundtrack for this dislocated moment where both humanity and nature are crying out for relief.


Monophonics Are an Ardent Blast of True Rock 'n' Soul on 'It's Only Us'

The third time's the charm as Bay Area soul sextet Monophonics release their shiniest record yet in It's Only Us.


'Slay the Dragon' Is a Road Map of the GOP's Methods for Dividing and Conquering American Democracy

If a time traveler from the past wanted to learn how to subvert democracy for a few million bucks, gerrymandering documentary Slay the Dragon would be a superb guide.


Bobby Previte / Jamie Saft / Nels Cline: Music from the Early 21st Century

A power-trio of electric guitar, keyboards, and drums takes on the challenge of free improvisation—but using primarily elements of rock and electronica as strongly as the usual creative music or jazz. The result is focused.


Does Inclusivity Mean That Everyone Does the Same Thing?

What is the meaning of diversity in today's world? Russell Jacoby raises and addresses some pertinent questions in his latest work, On Diversity.

Collapse Expand Reviews
Collapse Expand Features
PM Picks
Collapse Expand Pm Picks

© 1999-2020 All rights reserved.
PopMatters is wholly independent, women-owned and operated.