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.
Please considering sponsoring [1] LuaJIT so that Mike can continue working on it.
Lua Fun looks like a wonderful addition to the Lua ecosystem.
> 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.
openresty is getting a lot more attention with web developers. and I think its actually strongest in the "other" category but a lot is not very public.
Yes, but usually in the context of web development as these are common server side languages for web apps.
pjmpl just meant we don't see a lot of game developer content on here, which is largely a C++ dominated area (with Lua game scripting becoming a lot more common).
It's quite interesting to see essencially the ideas used in stream fusion [1] to produce practically the same results produced in Haskell, avoiding allocations and often making it much easier for the compiter ro produce vectorised code. At least that's what it looks like to me, correct me if I'm wrong.
Edit: [3] has a good exlanation of how stream fusion works, and it should make it clearer why the linked code appears to be doing the same thing.
see also here[2] for a further paper on stream fusion being used to produce vectorised code. I've linked to the reddit comments because there's some useful discussion there too.
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.
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.
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.
Yeah, the library has some common functions with "itertools" Python's module [1]. fun.range syntax was even copied from Python's range. What is more, you can also take a look on Haskell's Data.List [2] or StandardML's List [3] packages.
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.
Do you think the performance is really going to be that bad in the regular Lua interpreter? I wonder if its going to be better or worse than the underscore.lua approach of using arrays instead of iterators.
Also, are you using lots of 5.1 specific stuff (setfenv, ...) or would this also be easily ported to 5.2?
The library code is Lua 5.1 compatible (except bitwise functions in "operator" submodule, but it can be easily replaced with "bit32" or even removed).
Some high-order functions heavily use recursion just to support multireturn iterators (yes, you can use multireturn with map, reduce, filter and so on). I plan to benchmark these parts and add optimized versions for non-JIT Lua if necessary.
I will try to make a patch in the next couple of days.
Thanks for your interest!
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).
Please considering sponsoring [1] LuaJIT so that Mike can continue working on it.
Lua Fun looks like a wonderful addition to the Lua ecosystem.
[1] http://luajit.org/sponsors.html