by markus2012 · 13y ago · 0 comments
Take this example containing functional composition and higher-order functions:
reduce(operator.add, 0, map(function(x) return x^2 end, range(n)))
LUA converts this into 10 lines of assembler (2 jumps). Also, the LUA compiler is directly generating SSE.
Anyone have any good benchmarks comparing simple functional examples in LUA with Clojure or Common Lisp?
Is -- calculate sum(x for x^2 in 1..n) a comment or is it the output of a code transform?
The point is not about expressiveness; it's that while this code composes several higher-order functions, it's compiled into the kind of assembly code you'd expect from a fully optimized C routine.