Skip to Content

Once Upon A Bookshelf

Where Fiction and Reality Meet

If Hemingway Wrote Javascript

Author: Angus Croll
Originally Published: 2014
Publisher: No Starch Press
Source: Received from Publisher

The Story

If Hemingway Wrote JavaScriptFrom the back of the book:

What if William Shakespeare were asked to generate the Fibonacci series or Jane Austen had to write a factorial program? In If Hemingway Wrote JavaScript author Angus Croll imagines short JavaScript programs as written by famous wordsmiths. The result is a peculiar and charming combination of prose, poetry, and programming.

The best authors are those who obsess about language – and the same goes for JavaScript developers. To master either craft, you must experiment with language to develop your own style, your own idioms, and your own expressions. To that end, If Hemingway Wrote JavaScript playfully bridges to worlds of programming and literature for hte literary geek in all of us.

The Response

Okay, so I had mentioned that I wasn’t going to be accepting any more books from publishers, but when I was contacted about this one, I couldn’t really turn it down. A book that takes famous authors and crosses them with JavaScript functions? It’s like my hobbies have collided with work. Say what?

The author, Angus Croll is an Engineer at Twitter, and he co-authored the Flight framework that Twitter uses. This book is actually based on a blog post that he wrote back in 2012. So I knew going into this that he definitely had an idea what he wrote about, and that he had some time to really hone what he thought the functions written by each author would really look like.

I really liked how Croll broke the book into different parts, and within each part having five authors write the same function. It allows for readers to realize how differently each person can get to the same answer, with none of the functions appearing at all similar. It also provides a lot of variety, as reading the same(ish?) function for 25 authors would’ve gotten boring.

Croll’s broken the book down in this way:

  • Fibonacci, where the created function returns numbers in the Fibonacci sequence (with functions written by Ernest Hemingway, William Shakespeare, André Breton, Roberto Bolaño and Dan Brown)
  • Factorial, where the function returns the factorial of a number supplied (with functions by Jack Kerouac, Jane Austen, Samuel Johnson, Sir Arthur Conan Doyle and James Joyce)
  • Happy Numbers, where the function determines if the number supplied is a happy number (with functions by J.D. Salinger, Tupac Shakur, Virginia Woolf, Geoffrey Chaucer and Vladimir Nabokov)
  • Prime Numbers, which returns a list of prime numbers (with functions by Jorge Luis Borges, Lewis Carroll, Douglas Adams, Charles Dickens and David Foster Wallace)
  • Say It, which is a chainable function that accepts one word per function call until it is called without an argument, and then returns all of the words previously passed to it in order (with functions by Sylvia Plath, Italo Calvino, J.K. Rowling, Arundhati Roy and Franz Kafka)

This was definitely an amusing book – though, I will admit that I enjoyed the portions about authors I was familiar with better than the portions about authors I didn’t know anything about. However, that said, each section on different authors takes the time to familiarize the read with each author and their style of writing before providing the JavaScript function they had “written” and breaking down what they’ve done and how (or if at all) their function works.

If Hemingway Wrote JavaScript felt like it would have been a great playground for Croll to explore and have fun with some of JavaScript’s idiosyncrasies. Goodness knows, it’s got a lot of them. It was definitely interesting to see how completely differently the same thing could be accomplished.

The Bottom Line

While I definitely enjoyed this book, it’s not going to be a good fit for everyone. Those who are going to enjoy it are people who have at least an intermediate knowledge of both JavaScript and literature.

Posted by Courtney Wilson @ 8:12 am December 8, 2014.
Category: Humour
Book Author(s):