Monday, February 16, 2009

Potion for x86

Looking around, I stumbled on something interesting. Potion.
The source has an example:

fib = (n):
if (n <= 1): 1. else: fib (n - 1) + fib (n - 2)..
fib (40)

Interesting. Looks a bit like OCaml/Haskell. Sort of.
A microbenchmark for calculating fibonacci number in a very inefficient way :-)
Let's time it:

$ time ./potion example/
real 0m17.924s
user 0m17.909s
sys 0m0.008s

Now I'll try the similar-looking lua code:

function fib(n)
local ret = 1;
if (n > 1) then
ret = fib(n-1) + fib(n-2)
return ret

Timing it:

$ time lua fib.lua
real 2m18.566s
user 2m18.089s
sys 0m0.048s

Now, with all my non-love to microbenchmarks, this does look quite interesting.
If this baby has zero-based arrays, I might get seduced :-)

No comments: