4 ms·
Indeed, no other benchmark is: * so accessible to the naive -- anyone can understand fib! * has so many ways to implement it -- each in different complexity c
by dons 17y ago
Indeed, no other benchmark is:
* so accessible to the naive -- anyone can understand fib!
* has so many ways to implement it -- each in different complexity classes!
* is so perfect for language pissing contests on the intertubes.
Endless fun!
A much better idea is to contribute programs to the Great Shootout, http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=all http://shootout.alioth.debian.org/u64/benchmark.php?test=all...
- swannodette 17y agofib does present an interesting problem. Any language worth its weight should be able to express the problem in such a way that it can perform 1) quickly, 2) iteratively (tail-recursion) 3) succinctly. Not that many languages can do that.
- jrockway 17y agoTail recursion for two recursive steps per invocation? I don't think so. (Hint: the "naive" implementation of fib that I refer to above is "fib (x + 1) = fib x + fib (x - 1)".)
- swannodette 17y agoWhat are you saying exactly? That fib shouldn't be defined in terms of tail recursion? Of course it doesn't have to be. But it's also the moment that you realize that for loops are entirely unnecessary and broken since they aren't composable the way functions are.
- jrockway 17y agoIteration and tail recursion are orthogonal. Yes, you can implement iteration in terms of function application. But no, the results of benchmarking "fib" won't make your favorite version win.
- igouy 17y agoDoesn't seem that interesting - http://shootout.alioth.debian.org/gp4/benchmark.php?test=recursive&lang=all http://shootout.alioth.debian.org/gp4/benchmark.php?test=rec...