3 ms·
Please, I don't want to see any more benchmarks using fibonacci. NO FIB!!
by dons 17y ago
Please, I don't want to see any more benchmarks using fibonacci.
NO FIB!!
- kscaldef 17y agoNot only is it a silly benchmark, the implementation and methodology is awful. The Ruby code is at a huge disadvantage because it recomputes the whole sequence from scratch every time. The Ruby and Haskell programs print the answer, while the Clojure doesn't. And the LOC comparison is just completely useless. (The Haskell solution can be reduced to 3 lines without excessive golfing, which line up pretty directly with the Clojure, and it could be 1 "line of code" if you wanted.) And, there's no indication of how he's measuring or if he's measuring multiple iterations. In short, this article seems to combine just about everything bad about simple blog article benchmarking in one place.
- dons 17y agoAnd no description of which compilers, which versions, which compiler flags, what architecture/OS. We have the shootout to answer these questions, and it doesn't include fibonacci.
- jrockway 17y agoAgreed. As Haskell is the only language among the three that I know well, I had to say it was pretty strange looking. The "length w where w = ..." was especially strange. Why not, you know, just apply "length" to that expression? That's what functions do :) I won't comment on the single-expression do block or all the parens in the putStrLn expression or mention that "putStrLn . show" is just "print". Anyway, 6 lines of Haskell is just excessive. How about two lines: fibs = 1 : 1 : (zipWith (+) fibs $ tail fibs) main = print . length . takeWhile (< 10^999) $ fibs I think this is as readable as the example, and I didn't even have to line-break any expression.
- jules 17y agoHere's some Ruby golf: n,a,b = 1,0,1 n,a,b = n+1,b,a+b while b<10**999 p n 48 chars.