Live data from Hacker News

Lua Fun: A high-performance functional programming library designed for LuaJIT

github.com

21–30 of 34 posts

Re: Lua Fun: A high-performance functional programming library designed for LuaJIT

#23

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?

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?

"--" 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 library designed for LuaJIT

#24
post #5

Underscore Lua is a lib I have been using for quite a while. http://mirven.github.io/underscore.lua/

Looks cool, but hasn't been updated in four years.

mirven does seem to have gone quiet (on Github & Twitter).

Two more up-to-date forks can be found here....

- https://github.com/jtarchie/underscore-lua

- https://github.com/mark-otaris/underscore.lua

NB. The jtarchie fork seems best because its got 59 stars & 5 contributors.

Re: Lua Fun: A high-performance functional programming library designed for LuaJIT

#25
post #14

it would be nice to have this or underscore library inside redis

according to antirez, redis does not (and will not) support LuaJIT. Even though at one point there was someone who had got it working. From experience I know that replacing Lua with LuaJIT, even in a statically compiled project, is quite easy. The reasoning is of course that lua code for redis shouldn't have to do a lot of processing, and thus won't benefit from the extra performance (it also shouldn't run long enough for the JIT to come into action).

Re: Lua Fun: A high-performance functional programming library designed for LuaJIT

#26

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?

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?

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.

Re: Lua Fun: A high-performance functional programming library designed for LuaJIT

#27
post #12

Earlier quoted context omitted.

> Even though we occassionally talk about Lua on HN, it frankly still doesn't get enough attention - nor does Mike Pall and his fantastic work on LuaJIT. Because most HNers are web developers and care only about the browser. Lua is really strong in the game developer community.

Most? I'd say far from most. I see just as many articles about Go, Scala, Clojure, etc. as I do Javascript.

> Go, Scala, Clojure

All of them languages which are mostly used for web.

Re: Lua Fun: A high-performance functional programming library designed for LuaJIT

#29
post #5

Underscore Lua is a lib I have been using for quite a while. http://mirven.github.io/underscore.lua/

There is a BIG difference between Lua Fun and Underscore. Lua Fun is based on iterators. High-order functions such as map, filter, etc. don't create temporary tables and don't allocate extra memory. Since all operations are performed on the fly during iteration, most expressions use constant amount of memory to evaluate.

Re: Lua Fun: A high-performance functional programming library designed for LuaJIT

#30
post #4

> Reference Lua may not work and is not supported Any particular reason for that?

The initial idea was to make a functional library that works best with tracing JIT compiler. Functional paradigm on tracing JIT is the core innovation in the project.

Lua 5.1 can run fun.lua after minor changes (I'll make patch soon), but I am not sure that performance will be good enough.

Post reply on HN