Live data from Hacker News

If Hemingway wrote JavaScript

byfat.xxx

21–30 of 88 posts

Re: If Hemingway wrote JavaScript

#22
post #19

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.

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

Re: If Hemingway wrote JavaScript

#23
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 
}

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/

Re: If Hemingway wrote JavaScript

#25
post #19

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.

Re: If Hemingway wrote JavaScript

#28
post #25
post #19

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

Re: If Hemingway wrote JavaScript

#29
post #13

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 an…

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.

Re: If Hemingway wrote JavaScript

#30
post #3

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.

website automatically blocked in mid-east countries. sad.

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