All I Want for Christmas: If Hemingway Wrote JavaScript

Originally published at: http://www.sitepoint.com/want-christmas-hemingway-wrote-javascript/

We asked SitePoint authors what developer toys they would want for Christmas, then managed to source them — without relying on Santa.

If Hemingway Wrote JavaScript is exactly what it sounds like: A thought experiment as to how 25 well-known literary figures would tackle various JavaScript problems.

From the titular Ernest Hemingway (whose solution is terse and effective, as you’d expect), to post-postmodern darling David Foster Wallace (whose solution is long, discursive, and references his background in mathematics), pretty much everyone famous for writing in the last few centuries takes a stab at coding their way to a solution for a given problem.

The book is written by Angus Croll, on Twitter’s UI team, who knows a bit about JavaScript.

If Hemingway Wrote JavaScript

Angus Croll / No Starch Press

Why I Wanted This Book

Given I work on the content side of a technical publication like SitePoint, something that fell in the middle had an instant appeal. I know a bit about literature, and I like the idea of knowing a bit about JavaScript, although I haven’t quite gotten there yet. This seemed like a way to indirectly learn a bit more about the language while indulging my literary side.

The Experience So Far

I hadn’t expected to laugh so much at a bunch of code. This is a very clever, impressive book, full of amusing examples that show the versatile (or is it chaotic?) nature of both JavaScript and the English language. I haven’t covered every author yet, but some unexpected delights came from Tupac’s solution, incorporating rhyme and flow, and J.K. Rowling’s magical code.

Unsurprisingly, Kafka’s solution leads (Metamorphizes?) to a crushing bug, leading his code to recur endlessly. As Croll says, “very Kafkaesque”. A fitting end to a worthwhile read.

Which author, lyricist, stand-up comedian or orator would you want to see code? Answer in the comments, we’ll pick the best answer and send you a copy of the book!

Continue reading this article on SitePoint

I’m looking forward to reading the book. But from my experience of trying to learn JavaScript, if Hemingway had learned JS I expect he still would have killed himself … only earlier.

Which author, lyricist, stand-up comedian or orator would you want to see code?

I think maybe Thomas Hardy. It would be beautiful to read, picturesque and romantic, but at the same time utterly pessimistic and defeatist … which more corresponds to how I usually feel. (Those upbeat authors are insufferable!)

5 Likes

Be interesting to see J.R.R Tolkien slinging code across the 5 kingdoms. How would the orcs deal with such power?

It would be orcward, indeed.

2 Likes

I would love to read Douglas Adams’ javascript style, full of nonsensical characters and situations, even though we all know there will be only one answer in the end, “The Answer to the Ultimate Question of Life, the Universe, and Everything.”

2 Likes

Samuel Beckett’s would probably be like this:

(function()
{
	return;

})();
1 Like

I am loving the sound of that book, I might just gift it to myself.

I think I would love to read musings on coding from someone like Nietzsche. Such pearlers as “You have your way. I have my way. As for the right way, the correct way, and the only way, it does not exist.” sound like something I’d hear from my front-end friends. I’d expect to see something like;

[quote=“Coding with Nietzsche”]Whoever fights monsters should see to it that in the process he does not become a monster. And if you gaze long enough into an Javascript, the Javascript will gaze back into you.
[/quote]

Or

[quote=“Coding with Nietzsche”]Coding is the proper task of life.
[/quote]

1 Like

Neither of your examples look anything like JavaScript code - which is what the book is about.

I realise that - but I assume the whole book wouldn’t be simply written code. There would be some discussion and writing about it.

Examples of the type of code being used in the book can be seen at http://byfat.xxx/if-hemingway-wrote-javascript

For example, Charles Dickens:

function mrFibbowicksNumbers(enormity) {
  var assortment = [0,1,1], tally = 3, artfulRatio = 1.61803;

  while(tally++ < enormity) {
    //here is an exceedingly clever device
    assortment.push(Math.round(assortment[tally-2] * artfulRatio));
  }

  //should there be an overabundance of elements, a remedy need be applied
  return assortment.slice(0, enormity);
}

which is followed by some discussion afterwards about him and aspects about him that affect how he would write the script.

I am familiar with this, thanks - I understand there is written code in the book. I was simply twisting it to discuss if x author (in my case, Nietzsche) wrote a tutorial-esque book on code (like the ones SitePoint puts out), how they might discuss the topic.

Whoa, your tone is a bit off the mark here @felgall
I think @katja_bak’s take on this is both interesting and entertaining, which is the kind of thing we like to encourage around here. :wink:

2 Likes

Yes it is nice. What was asked in the original post was just for who we’d want to see in code, not for examples of code itself.

We must ensure that we’re not giving the impression of putting people down. Good job @katja_bak on your efforts here.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.