lua-users home
lua-l archive

[ANN] Lua Fun - a functional programming library for tracing JIT compiler

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm happy to announce the release of Lua Fun [1] - a high-performance functional
programming library designed for superb LuaJIT tracing just-in-time compiler.
The library provides a set of more than 50 programming primitives like `map`,
`filter`, `reduce`, `zip`, etc. to help you writing simple and efficient code.
Lua Fun takes the full advantage of the innovative tracing JIT compiler [2] to
achieve transcendental performance on functional compositions and high-order
functions. Functional expressions can be compiled into efficient asm code!
An example:
 require "fun" ()
 n = 100
 ans = sum(map(function(x) return x^2 end, take(n, tabulate(math.sin(x)))))
 -- calculate sum(sin(x)^2 for x in 0..n-1)
 print(ans)
LuaJIT 2.0 translates code above to:
 -- some initilization code --
 ->LOOP:
 394cffd0 movsd [rsp+0x8], xmm7
 394cffd6 addsd xmm4, xmm5
 394cffda ucomisd xmm6, xmm1
 394cffde jnb 0x394c0028 ->6
 394cffe4 addsd xmm6, xmm0
 394cffe8 addsd xmm7, xmm0
 394cffec fld qword [rsp+0x8]
 394cfff0 fsin
 394cfff2 fstp qword [rsp]
 394cfff5 movsd xmm5, [rsp]
 394cfffa mulsd xmm5, xmm5
 394cfffe jmp 0x394cffd0 ->LOOP
 ---- TRACE 1 stop -> loop
Simple, Efficient and Functional.
In Lua. With JIT.
Lua Fun is fully documented [2] and tested. A Rockspec is available [3].
This is the first public release. Feedback is very welcome!
[1] https://github.com/rtsisyk/luafun
[2] http://luajit.org/luajit.html
[3] http://rtsisyk.github.io/luafun
[4] https://raw.github.com/rtsisyk/luafun/master/fun-scm-1.rockspec
Thank you for your attention!
Have Fun!
-- 
WBR,
 Roman Tsisyk <roman@tarantool.org>
 http://tarantool.org/ - an efficient in-memory database and a Lua application server

AltStyle によって変換されたページ (->オリジナル) /