News for hackers. Stuff that matters.
Re:Lua Fun: A high-performance functional programming librar... by markus2012 on Thursday November 21, 2013 @12:00AM (#6773132)
In case you skipped the article it contains this nugget:

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?

Re:Lua Fun: A high-performance functional programming librar... by justincormack on Thursday November 21, 2013 @02:50AM (#6773549)
probably not. this is the first time I have seen the outcome of optimising this type of code. I knew it was possible as it optimises my tail recursion.
Re:Lua Fun: A high-performance functional programming librar... by matthiasl on Thursday November 21, 2013 @04:00AM (#6773739)
I know nothing about LUA syntax, so I also have no idea which part of this is new and which part is ordinary LUA.

Is -- calculate sum(x for x^2 in 1..n) a comment or is it the output of a code transform?

Re:Lua Fun: A high-performance functional programming librar... by thelinked on Thursday November 21, 2013 @04:36AM (#6773835)
"--" are comments in Lua, also, sorry for being pedantic but its Lua not LUA. Its Portuguese for moon.
Re:Lua Fun: A high-performance functional programming librar... by fab13n on Thursday November 21, 2013 @05:40AM (#6773999)
The code is perfectly standard plain Lua.

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.