
If Hemingway wrote JavaScript - federicoweber
http://byfat.xxx/if-hemingway-wrote-javascript
======
monatron
Top post HN (check), interesting title (check), innocuous title (check) --
_click_ \-- "Blocked by Security Policy" (huh?)-- .xxx domain? wtf! damnit!
now i have an xxx domain logged to my corporate login... EXCELLENT. thanks.

Really though... Is there some sort of clever reason why this person's blog is
on a xxx domain aside from annoying people like myself stuck behind corporate
proxies?

~~~
breakall
I am immediately suspicious of a .xxx link. Any professional writer should
avoid this TLD.

~~~
klausa
Then it's great that fat isn't a professional writer, but a developer.

------
jrockway
Excellent use of the .xxx domain name. If people start using .xxx for normal
writing, the concept of "one place to conveniently censor" will not work out.
Heh.

~~~
citricsquid
I don't think that is true, what will happen is people browsing hackernews
from work (in not particularly liberal work places) will not be able to read
posts. Even if people choose to (incorrectly) use the .xxx extension I don't
think it's going to push people to stop assuming .xxx is pornographic.

edit: assuming you're not being sarcastic, can't tell.

~~~
eevilspock
Some people don't give a fuck about page views. I highly suspect that @fat is
one of those.

~~~
chanux
He may not be a guy who doesn't give a fuck about people _reading_ the article
though.

~~~
freehunter
It reminds me of bands who have offensive names, or developers who name their
software after offense words.

They might not care about "rules" or "society" or this and that they might
say, but it's inconvenient for me. Even though I am not offended easily, some
of my coworkers, bosses, classmates, people on the bus, etc might be. If it's
inconvenient for me to view the site, use the software, or have the album art
showing on my iPod/computer, I'm going to avoid it even if I like it.

That's their choice, I understand. They made the determination that there are
people who could appreciate their work but aren't willing to take the same hit
to their reputation. It just disappoints me as a fan.

------
lmm
Am I alone in finding this ridiculously pretentious? I got as far as the
mocking olde-worlde "shakespeare" comments before giving up.

Javascript is not a better language than others (in fact it's a far worse
language), and it's downright insulting to put words in the mouth of someone
like Hemingway to try and make yourself feel better.

~~~
PuerkitoBio
This is fun. Remember fun?

~~~
lmm
I thought fun wasn't allowed on HN

~~~
waterlesscloud
Fun that requires some effort is fine. Mindlessly copying the meme of the week
is not.

See: IOCCC, Esoteric Languages, etc.

------
brudgers

      return result;
        }
    

That happy ending is not Hemingwayesque.

------
angusC
If anyone wants to add Vonnegut or anyone else please feel free to fork my
original code. No reasonable pull request refused :-)

<https://github.com/angus-c/literaryJavaScript>

~~~
russelluresti
I was actually really hoping to see a Vonnegut.

------
DanI-S
This brings up a sore point, for me.

I love to read. At some points in my life I have been able to read two or
three books every week. I have spent years of time drifting through the
endlessly multiplicating realities of prose.

However: since moving to the Valley, working full time whilst attacking
various business and development side projects, I can usually manage 2-3 pages
(immediately before bed).

Where do you find the time to read?

~~~
Scriptor
At some point you have to relax a little with the side projects and just sit
down with a book and read. Maybe go to a park or coffee shop to get a change
in scenery so you're not tempted to open the laptop and start coding again. If
you take public transportation, your commute's a good time as well.

------
JasonFruit
If the "Closing Thoughts" express the _point_ of his amusing and mostly well-
executed exercise, then for all his skill it's a wasted effort. It's precisely
"doctrine and dogma", "rulebooks and boilerplate", that make JavaScript work
for group development and long-term maintainability.

This is the coding equivalent of the garage musician who says, "Don't bother
me with rules — I'm playing pure _emotion_ here, man!"

~~~
dyeje
Who says everything has to be suitable for group development or long term
maintainability? What's wrong with just coding for the sake of expressing
oneself? I love these kind of things precisely because of this. Programming is
an art, and I feel we need to be reminded of that every now and again. You
don't always write a song or picture to maximize their appeal to others,
sometimes you just have something in you that needs to get out.

~~~
JasonFruit
"Fat" says that rules are "the enemies of good JavaScript." That is what I'm
arguing against, not occasionally writing something a given way just because
that's how you like to code.

------
andrewcooke
the code for the bolaño one is not so good, although the explanation improves
it (i think all the others snippets give you a fair idea of what to expect in
a book by the author; that really doesn't).

when i first skimmed the article i got down to that section, read the code,
with a list of names, and expected something french and post-modern. was
really surprised when i checked back to the title to see bolaño.

(if you haven't read him, i wouldn't start with 2666, but with the savage
detectives, which is a really sweet, funny, smart novel. also, if you speak
spanish as a second language, he's very easy to read in the original - a
modern, simple, colloquial style, just like you're used to speaking.)

[edit: huh; i don't even remember the dream sequences at the start of 2666, so
maybe my bad. will have to go back and re-read. edit2: oh, yeah, i do
remember. ok... but there's nothing like that in any other book of his i have
read. hmph. you might as well characterise his writing as a list of murders.]

~~~
christensen_emc
It seemed like a pretty obvious reference to 2666 to me. The first part of the
book has a number of dream sequences where its characters will just list off
philosophers and put them into groups and connect them with lines. Definitely
took me a few days to get through that book.

~~~
omegant
It´s very well written but I can´t stand(nor understand) the way writers
expand the thickness of the books just adding nonsense parts to the stories.
And they get rewarded by that!

Pamuk´s "Black book" is a 2 inch thick book of Istanbul streets descriptions,
and... that´s it. I forced myself to finish it because I thought:"there should
be something else, is not possible that all this is for nothing". I was wrong.

------
ajuc
Great post, but I don't agree with the critique of "Dickens'" solution.

Using one-step equation to solve iterative problem is IMHO better (obvious
speed benefits for large n, the only drawback is floating point imprecision),
and deriving the equation requires deeper understanding of the problem than
simply modeling the iterative equation with a loop.

~~~
relix
I'm not sure I understand how a speed benefit would be had here, since to get
number N+1 they still need to retrieve (and/or calculate) number N-1. The
difference between getting (N and N-1) or only N-1 is negligible, especially
for large n, unless I'm missing something? It's not really more parallelizable
either.

~~~
ajuc
Ah, yes, I've read the part about multiplying, and skipped over the real code.
My bad.

The benefit would be there, if Dickens went one step further, and used
Math.pow to get the result instead of loop (that is - assuming calculating the
power is faster than doing a loop (but it should be - you can square a few
times to get near the result instead of multiplying "by one factor" each
time)).

~~~
relix
Now I see, yeah that would improve it.

------
Charlesmigli
Very well written article. Conclusion is very sharp, I like it. I tried to
make the tl;dr version but it's definitely worth reading the full article
<http://api.tldr.io/tldrs/506c2f7991598c0f55000098>.

------
eevilspock
Vonnegut. Beautiful except for this omission. Anyone?

~~~
RyanMcGreal
Vonnegut would tell you the return value in the first line and then spend the
rest of the function showing you how he got there.

~~~
jpolitz
Like this?

    
    
        function fibs(size) {
          return f();
          function f() {
            ... implementation here ...
          }
        }

------
Void_
This is cool as a joke, but I don't think code should be compared to writing.

For example I am an engineer, so this comment is written like code. It
contains just enough words to express my point, it's clearly structured and my
goal is to make it easy to read.

That's okay writing, but far from great. Great writers can just sit down and
write amazing text. I could never do that. I have to go back, read after
myself and refactor.

I wonder if other engineers feel similarly.

~~~
arnsholt
Writing prose is actually quite similar to writing code. I don't think any
author writes in linear, unidirectional process. Just like coding, you solve
some subproblems (chapters, sections, etc.) before moving on to somewhere
else, you go back and refactor so that the text flows better, or the ordering
of points is better. And there are bugs. Stuff that's wrong, a dropped word
and so on.

My experience with writing is mainly with academic prose, but I think most
literary authors work like this as well. Besides, I do think that different
programmers will have different styles in the same way different authors have
styles. In part it'll probably influence your choice of language, but there'll
be variation within a single language as well.

~~~
andreasvc
> I don't think any author writes in linear, unidirectional process.

Yes, people do. On the extreme end you have the stream-of-consciousness style.
E.g., on the road was written on a typewriter with a series of sheets of paper
joined together to avoid interruptions. I also think I remember Neal
Stephenson saying in a talk that the writing should come out naturally, not
sculpted word for word. When it doesn't, it's called writer's block; a
programmer's block on the other hand is not really a thing.

Text is typically read linearly, so it's also easier to write that way. Code,
except for the very simplest, jumps around from function to function so it's
going to require some additional planning.

------
Ygg2
My antivirus has found Mal/HTMLGen-A virus on this page. Has anyone verified
this is legitimate? The domain .xxx doesn't inspire much confidence either.

~~~
eevilspock
Angus Croll's own website points to it.

------
nadam
I don't know Hemmingway, but given this description:

"No surprises here. Code reduced to its essentials with no word or variable
wasted. It’s not fancy; maybe its even a little pedantic - but that’s the
beauty of Hemingway’s writing. No need for elaborate logic or clever variable
names. It’s plain and its clear and it does what it has to - and nothing
more."

I am not sure why he did not choose this style:

    
    
        function fibonacci(size) {
    
          var result = [0, 1], i;
    
          if(size < 2)
            return "the request was made but it was not good"
    
          for(i=2; i<size; i++)
            result.push(result[i-1] + result[i-2]));
      
          return result;

}

Perhaps because Hemmingway would care about performance?

\-----

Slightly related: One year ago Javascript inspired me to write the javascript
version of genesis:

<http://nadamhu.wordpress.com/2011/09/29/javascript-genesis/>

~~~
DougBTX
Just pulling quotes from the Wikipedia page, "he avoided complicated syntax
and about 70 percent of the sentences are simple sentences — a childlike
syntax without subordination."

Subordination is the key word, ie, limiting the amount of nesting. That's why
the for quoted above is out, since there are two statements and an expression
nested inside the for statement (i=2, i<size, and i++), and there are two sub-
expressions nested inside the push call (result[i-1] and result[i-2]).

Going out on a limb, I'd say Hemmingway's writing is building up complex
narrative using simple building blocks. The body of the for loop above is a
single line, which does simple arithmetic, array indexing, and a method call
all together. In contrast, each line in the while loop body does roughly one
thing: first addition, then assignment, assignment again, then a method call.

------
habosa
Pretty sure Shakespeare would not use JavaScript at all, but rather this:

[http://en.wikipedia.org/wiki/Shakespeare_(programming_langua...](http://en.wikipedia.org/wiki/Shakespeare_\(programming_language\))

------
pron
_Even as a long-time Hemingway nut, I’d be the first to admit that Papa would
probably have loathed programming (and programmers)._

You got that right.

------
syaz1
How were you able to repost this? I see similar URL. I know because when I
tried to post this before I got redirected to a submission... probably this
one: <http://news.ycombinator.com/item?id=4336148>

------
timje
I love this post, it reminds me a bit of the Mark Crick's 'Sartre's Sink'
series of books.

------
richardofyork
I love Literature as well as JavaScript, too. Here is a literary JavaScript
post that is a fun read: <http://javascriptissexy.com/javascript-is-super-
sexy/>

------
Fletch137
As a book nerd myself (and a lover of JS), I really enjoyed that.I think the
criticism of Dickens was undeserved, even if it was a quote - but the
Shakespeare iteration was spot on, loved it.

------
Millennium
My problem with the Hemingway one is that there's not nearly enough function
call chaining going on. Hemingway would be all over that particular construct.

------
tnuc
Dickens got paid by the word. I would expect a lot more code that does
nothing.

------
russelluresti
I'm gonna go with the Bard's. Not for the solution, but for the comments.

------
thomasfl
TLDR; Doing javascript like Douglas Crockford is boring.

------
dschiptsov
..it would be Scheme.

or, well, Arc, which, I think, is already obese.)

------
leif
Of course, writers would all consume linear space.

------
stylewalker
What is that CMS i see more and more often?

~~~
jrnkntl
<http://svbtle.com/> but it's for an exclusive group of writers.

------
tomchristie
The Hemingway snippet is genius. Spot on.

------
calvin
Can anyone provide a SFW link for this?

------
suprawsm
Wow, I really enjoyed this post.

------
frenchfries
this guy needs more xxx ...

------
atdt
Christ, what an asshole.

