Settings

Theme

If Hemingway wrote JavaScript

byfat.xxx

218 points by federicoweber 13 years ago · 87 comments

Reader

monatron 13 years ago

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?

  • glesica 13 years ago

    First, I sympathize with you.

    However, I personally love the idea of polluting .xxx with non-pornographic (and interesting) material because I think the entire idea behind .xxx is flawed and goes against the spirit of the Internet.

    Freedom, and the assumption of freedom, should always be the default. If you choose to associate with people who seek to restrict your access to information (your freedom), then it is your responsibility to be vigilant.

  • breakall 13 years ago

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

    • klausa 13 years ago

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

jrockway 13 years ago

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 13 years ago

    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.

    • nicholas_tuzzio 13 years ago

      It was automatically blocked by my work filter as porn. First time I've even noticed a .xxx extension, and I didn't notice it until I noticed it was blocked.

    • eevilspock 13 years ago

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

      • chanux 13 years ago

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

        • freehunter 13 years ago

          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.

    • loeschg 13 years ago

      Yup, still hesitant to click .xxx links at work even if it's not filtered. Didn't see any repercussions after the last time I accidentally clicked one at work (another HN article)... though I didn't get promoted this time around... correlation? I'm going to make myself feel better and say yes.

    • RossM 13 years ago

      Oddly enough, not blocked by SonicWall (at least in our config, which I would assume is fairly default-ish).

  • onurozkan 13 years ago

    website automatically blocked in mid-east countries. sad.

  • federicoweberOP 13 years ago

    I do agree, the .xxx domain is not an excellent choice, but at the end it doesn't really bother me.

  • becojo 13 years ago

    Indeed. It's blocked by my college's proxy.

    • RobAtticus 13 years ago

      Is this like on a public computer at your campus? Or is it your personal machine connected to the college network? If it's the latter, it seems odd to me that a college would filter your results for your personal machine.

lmm 13 years ago

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 13 years ago

    This is fun. Remember fun?

  • dmorgan 13 years ago

    >Am I alone in finding this ridiculously pretentious?

    No, but you must be among the few not getting the joke or not being stuck-up to see that IT IS a joke post.

    I mean, "it's downright insulting to put words in the mouth of someone like Hemingway to try and make yourself feel better."

    Really?

    >Javascript is not a better language than others (in fact it's a far worse language)

    Even if that was true (which is highly debatable, because a language is not just it's syntax, or even it's semantics), it doesn't have anything to do with the post (besides it being about Javascript).

brudgers 13 years ago

  return result;
    }
That happy ending is not Hemingwayesque.
angusC 13 years ago

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

DanI-S 13 years ago

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 13 years ago

    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.

  • adamgray 13 years ago

    If public transportation is an option for you, I find that I get about an hour (30 minutes each way) of dedicated reading / people-watching time every day while I ride the Chicago L.

JasonFruit 13 years ago

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!"

  • freehunter 13 years ago

    I love coding with emotion. As someone who is not a professional developer, I write mainly scripts or small, single purpose programs. Most are command line, some others only have the most basic GUI that would make everyone at HN cringe. This is fine for me. Reading my code, many times you can tell what mood I was in while writing it.

    Unfortunately, finding new languages that allow me to write how I feel is sometimes difficult because no one talks about raw emotion in code, or single-developer and one-off projects. I love Lua for this.

  • dyeje 13 years ago

    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 13 years ago

      "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.

  • anonymous 13 years ago

    It worked for the Beatles.

    • JasonFruit 13 years ago

      They also had (in addition to abnormal amounts of talent) a producer who not only knew the rules but had the knack of knowing how much could be applied without squashing their music.

andrewcooke 13 years ago

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 13 years ago

    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 13 years ago

      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.

    • ritchiea 13 years ago

      Perhaps but having only read Savage Detectives it still felt like Bolano to me.

ajuc 13 years ago

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 13 years ago

    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 13 years ago

      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)).

  • t_lark 13 years ago

    agree, one step is better, but extra points for bounding for what values of n the floating imprecision kicks in

Charlesmigli 13 years ago

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 13 years ago

Vonnegut. Beautiful except for this omission. Anyone?

  • RyanMcGreal 13 years ago

    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 13 years ago

      Like this?

          function fibs(size) {
            return f();
            function f() {
              ... implementation here ...
            }
          }
Void_ 13 years ago

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 13 years ago

    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 13 years ago

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

  • jrajav 13 years ago

    I disagree. I think the best writers work precisely like the best coders. They don't compromise on a single letter, they ruthlessly rewrite and refactor their own work as many times as they need to, and they value simplicity, elegance, and effectiveness.

    The main difference isn't the method, it's that writers usually get a lot more time to do their work.

    Tangentially, I believe that learning to write better will make you a much better coder and communicator.

    • tomchristie 13 years ago

      > They don't compromise on a single letter

      +1. I think that's why the Hemingway snippet works so perfectly. The tone both perfectly captures Hemingway's voice, and the design qualities of beautifully engineered code.

      > I believe that learning to write better will make you a much better coder and communicator.

      And again, yes.

  • wisty 13 years ago

    > Great writers can just sit down and write amazing text.

    Very few great writers can. Dickens wrote prolifically because he was paid by the page (actually, he published in 32 page installments, so he was paid for each 32 pages); which may be why he's so controversial. They often edit a lot to improve the structure of their work (unless they publish in instalments).

  • morisy 13 years ago

    > 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 second sentence sums up 95 percent of advice professional writing instructors give.

  • russelluresti 13 years ago

    I think comparing coding to writing works because they both show a flow of thought. How you write and how you code depends on the way thoughts flow from you. I feel that things like verbosity, word choice, sentence structure, etc. are very similar to logic choices and order of operations.

    Also, both writers and programmers do a ton of refactoring. Most authors will go over their writing 2 or 3 time, eliminating words and sentences that are unnecessary, combining and shortening sentences to make them more readable, etc. A lot of refactoring happens in both.

  • mcantor 13 years ago

    Go read "On Writing" by Stephen King. It will make you a better programmer and a better writer.

Ygg2 13 years ago

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.

nadam 13 years ago

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 13 years ago

    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.

  • jrajav 13 years ago

    Maybe I'm alone in thinking this, but I find the article version to be much more faithful to "no elaborate logic or clever variable names." Most programmers are intimately familiar with for loops and the 'i' index variable convention by now, and also wouldn't have trouble deciphering a simple one-liner like that push, but it's still more obscure than the original.

    To single out for loops in particular, they've always struck me as a little too obfuscated and messy compared to the benefits they provide. It's a large, awkward word that nevertheless remains a dependable part of everyone's vocabulary, so we let it stick around. But should we?

  • devgutt 13 years ago

    I highly recommend: The Sun Also Rises (1926)

habosa 13 years ago

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

http://en.wikipedia.org/wiki/Shakespeare_(programming_langua...

pron 13 years ago

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 13 years ago

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 13 years ago

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

richardofyork 13 years ago

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 13 years ago

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 13 years ago

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 13 years ago

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

russelluresti 13 years ago

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

thomasfl 13 years ago

TLDR; Doing javascript like Douglas Crockford is boring.

dschiptsov 13 years ago

..it would be Scheme.

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

leif 13 years ago

Of course, writers would all consume linear space.

stylewalker 13 years ago

What is that CMS i see more and more often?

tomchristie 13 years ago

The Hemingway snippet is genius. Spot on.

calvin 13 years ago

Can anyone provide a SFW link for this?

suprawsm 13 years ago

Wow, I really enjoyed this post.

frenchfries 13 years ago

this guy needs more xxx ...

atdt 13 years ago

Christ, what an asshole.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection