Hacker News new | past | comments | ask | show | jobs | submit login
If Hemingway wrote JavaScript (byfat.xxx)
218 points by federicoweber on Oct 3, 2012 | hide | past | favorite | 84 comments



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?


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.


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


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


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.


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.


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


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


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.


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.


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.


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


website automatically blocked in mid-east countries. sad.


I can't access a lot of posts in China but this one works great \o/


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


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


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.


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.


This is fun. Remember fun?


"I had fun once, it was horrible."


I thought fun wasn't allowed on HN


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

See: IOCCC, Esoteric Languages, etc.


PROGRAMMING IS NOT FUN


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


Even if you see that it is a joke you can find it a bad, pretentious joke.


  return result;
    }
That happy ending is not Hemingwayesque.


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


I was actually really hoping to see a Vonnegut.


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?


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.


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.


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


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.


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.


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


It worked for the Beatles.


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.


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


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.


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.


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


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.


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.


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


Now I see, yeah that would improve it.


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


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.


Vonnegut. Beautiful except for this omission. Anyone?


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.


Like this?

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


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.


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.


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


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.


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


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


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


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.


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


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.


Angus Croll's own website points to it.


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/


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.


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?


I highly recommend: The Sun Also Rises (1926)


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

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


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.


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


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


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/


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.


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.


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


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


TLDR; Doing javascript like Douglas Crockford is boring.


..it would be Scheme.

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


Of course, writers would all consume linear space.


What is that CMS i see more and more often?


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


The Hemingway snippet is genius. Spot on.


Can anyone provide a SFW link for this?


Wow, I really enjoyed this post.


this guy needs more xxx ...


Christ, what an asshole.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: