DEV Community

Cover image for Book Review - If Hemingway Wrote Javascript
Cameren Dolecheck
Cameren Dolecheck

Posted on • Originally published at imago.dev on

3

Book Review - If Hemingway Wrote Javascript

What would computer code look like if it was created by history’s greatest writers? How would some of the most creative linguistic minds take to writing Javascript? Angus Troll attempts to answer those questions in “If Hemingway Wrote Javascript”.

This is a cross-post from the blog I run, Imago Dev.

This book takes an entirely different approach to coding and style. Croll solves a handful of common programming challenges, such as finding Fibonacci or prime numbers, in a matter fitting a wide variety of famous writer’s styles. Some solutions, like the first example by Hemingway, are down right elementary; however, some like Italo Calvino turn functional programming on its head.

Often times, comments in the code work to tell a story more so than simply describe the lines of code. Some authors throw out form all together, combining code and comment into one string of thought. For instance, the beat generation writer Jack Kerouac’s solution to factorial, writes the whole program as essentially a single line.

/*...the only numbers for me are the mad ones, take forty-three like a steam engine with a talky caboose at the end*/ (n = 43), /*and that lanky fellow in a cocked fedora*/ (r = 1); /*then back to our number, our mad number, mad to become one*/ while (n > 1) /*mad to descend*/ n--, /*mad to multiply*/ (r = r * n); /*and at the end, you see the blue center-light pop, and everybody goes 1.4050061177528801e+51…*/
r;
Enter fullscreen mode Exit fullscreen mode

It’s so wonky that I had to turn off my Prettier VS Code extension just to save the snippet properly. You’ll also notice that he totally disregards any factorial except for that of the number 43.

Croll does an excellent job of providing a brief bio on each writer in order to set up the reasoning behind a given solution. Even if you hardly understand Javascript, you’ll walk away with a greater understanding of 25 brilliant writers. If you’re like me, this book will probably stuff up the urge to dive into some of the authors’ actual literary work.

When most folks who create code are the technical engineering types, having an artist play with the “language” part of “programming language” truly provides a fresh take on coding style. That is not to say you should emulate the topsy-turvy nature of these authors when starting the next project, but it certainly will push you to think outside the box.

Overall, this book is an excellently playful read that is worth your time.

Have you reader this book? What were your thoughts?

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay