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;
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.
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?