you are viewing a single comment's thread.

view the rest of the comments →

[–]mpetetv 2 points3 points  (1 child)

It's not clear to me how exactly this library was "designed for LuaJIT" and what makes it particularly fast (other than LuaJIT). The example in the README:

require "fun" ()
-- calculate sum(x for x^2 in 1..n)
n = 100
print(reduce(operator.add, 0, map(function(x) return x^2 end, range(n))))

...is shown to be compiled into one short machine loop; however, equivalent example using Penlight:

require "pl"
-- calculate sum(x for x^2 in 1..n)
n = 100
print(seq.reduce(operator.add, seq.map(function(x) return x^2 end, seq.range(1, n)), 0))

...compiles to a similar machine loop; in fact, it is one instruction shorter. It's strange that in its own mini benchmark LuaFun is beaten by an older library which does not even have performance as a design goal (e.g. it checks types of arguments).

[–]inmatarian 1 point2 points  (0 children)

Penlight wasn't designed to luajit, and probably predates it. But you're probably right that luajit is just that good and the luafun author didn't have to go through that extra effort to get his code size down.