Lua Fun: fifty iterator primitives that LuaJIT folds into one machine loop, on a master branch that may change its API
Lua Fun is a high-performance functional programming library for Lua designed with LuaJIT's trace compiler in mind.
At a glance
- What is it?
- Lua Fun is a functional programming library for Lua with map, filter, reduce, zip and more than fifty other primitives, written for LuaJIT's trace compiler. The README calls it early alpha and points production users to the stable branch.
- Who is it for?
- Use Lua Fun if you write Lua on LuaJIT 2.1 and want map, filter and reduce style chains that the tracer can compile into tight loops, particularly in a Tarantool setting. Skip the master branch for anything you ship: the README says the API may change without notice and tells production users to take the stable branch.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 66 days ago.
- What is it written in?
- Mainly Lua, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 26, 2026, and from our analysis. They are not legal advice.
Star history
- luafun/luafun2,266 ★ · +0
| Repository | 2026-10-11 | 2026-11-26 |
|---|---|---|
| luafun/luafun | 2.3k | 2.3k |
0 Stars in the last 46 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Two ways to write the same sum of squares
The README opens with one computation done in two styles. Both sum the squares of the numbers from 0 up to n minus one, and both print 328350 for n = 100:
> -- Functional style
> require "fun" ()
> -- calculate sum(x for x^2 in 1..n)
> n = 100
> print(reduce(operator.add, 0, map(function(x) return x^2 end, range(n))))
328350
> -- Object-oriented style
> local fun = require "fun"
> -- calculate sum(x for x^2 in 1..n)
> print(fun.range(n):map(function(x) return x^2 end):reduce(operator.add, 0))
328350The first style calls require "fun" () and puts the primitives into the global namespace, which is why reduce, map and range appear unqualified. The second keeps everything under a local fun and chains methods on the iterator. The choice matters in a larger codebase: the global form saves typing but injects names, while the local form keeps your namespace clean at the cost of longer lines. operator.add is one of the helpers the library supplies for use as the reducer.
More than fifty primitives borrowed from other languages
The README says Lua Fun provides more than 50 programming primitives of the kind found in Standard ML, Haskell, Erlang, JavaScript, Python and even Lisp. The named examples are map, filter, reduce and zip, with the list closed by an etc.
That is all the README itself says about the surface. It does not list the remaining forty-some functions, so a reader has to open the documentation at luafun.github.io to find out what exists. The repository's doc/ directory and the single source file, fun.lua, are the places to confirm it. The Getting Started page is linked from the README's reference list.
The library is one module. The top-level entries show fun.lua next to a rockspec called fun-scm-1.rockspec, debian/ and rpm/ folders, a tests/ directory and a HACKING.md. There is no sub-package structure to learn, so adopting it means vendoring or requiring a single file.
The performance claim depends on LuaJIT tracing the whole chain
The selling point is performance under LuaJIT's trace compiler. The README says functional compositions and high-order functions can be translated into efficient machine code, and invites you to run the example above with luajit -jdump. The dump it prints ends with a loop labelled ->LOOP and the line TRACE 1 stop -> loop.
The README's reading of that output: the functional chain was translated by LuaJIT into one machine loop containing just 10 CPU assembly instructions without CALL. The shown instructions are register moves, an add, a compare, a multiply and a jump back to the loop head.
Two cautions follow from the source. The result is for one chain over a numeric range, so it says nothing about chains over tables of objects or strings. And it describes LuaJIT only. The README makes a closing comparison to Python, Ruby and V8 as a rhetorical question and publishes no timing numbers. Treat the dump as a demonstration of what the tracer can do and measure your own code.
Runtime support: LuaJIT 2.1 alpha preferred, Lua 5.1 to 5.3 allowed
The README recommends LuaJIT 2.1 alpha. The reasoning given is that the library was designed with the fact in mind that LuaJIT traces tail, up and down recursion and has many byte code optimizations. It also states that Lua 5.1 through 5.3 are supported.
That means two tiers of experience. On LuaJIT you get the loop collapsing shown above. On plain PUC-Rio Lua the same code runs, but nothing in the README claims it is fast there, and the trace dump has no equivalent. If your deployment uses a standard Lua interpreter, you are using Lua Fun as a convenience library, not as a performance tool.
The README does not mention Lua 5.4 or later, nor LuaJIT 2.0. The support list stops at 5.3. Anyone on a newer Lua should test the library before relying on it, because the README makes no promise either way.
Master may break your code without a word of warning
The status section says Lua Fun is in an early alpha stage, and that the library is fully documented and covered with unit tests. The warning that matters follows: this is the master (development) branch, and the API may be changed without any special notice. For production deployments the README says to use the stable branch.
If you still want master, it asks you to grep git log for the message Incompatible API changes before updating. That puts the burden of change tracking on the user. There is no changelog file in the top-level listing, and no GitHub releases exist, so there are no tags to compare either.
In practice: pin a commit hash or take the stable branch, and read the git log before every update. A bare git pull on master could change a function signature underneath a hot code path. The README also claims full documentation and tests, but it does not state coverage numbers, and the build badge it links goes to Travis.
Getting the code: rockspec, RPM and DEB packages, or the single file
The README has no install command, so this article shows none. It lists these places under See Also: the documentation site, a RockSpec at raw.github.com/luafun/luafun/master/fun-scm-1.rockspec, RPM and DEB packages on packagecloud.io/rtsisyk/master, and the HACKING.md file. Contact points listed are the [email protected] and [email protected] mailing lists and an email address for the author.
The rockspec is named fun-scm-1, which means it tracks the master branch rather than a tagged version, and that ties it to the instability described above. The repository also carries debian/ and rpm/ directories for building native packages. Since there is also a single fun.lua at the root, copying that file into a project is the lightest option, though the README does not recommend it.
The README states the library was written to use with Tarantool, an efficient in-memory store and asynchronous Lua application server. That is the one named deployment context. Outside it, the README gives no example of integration with another host.
License wording differs from the repository metadata
The README says Lua Fun is distributed under the MIT/X11 License, the same as Lua and LuaJIT. The repository metadata reports no recognized license for it, listed as NOASSERTION, and the top-level entries include COPYING.md rather than a file named LICENSE. A tool that scans for licenses may therefore flag the project even though the README states MIT.
If compliance matters, open COPYING.md and confirm the terms before you ship the library in a product. The text of that file is not reproduced in the README.
On upkeep, the repository is not archived and the last push was on 2026-09-21. The branch you land on by default is master, the development line the README warns about. The project asks for a GitHub star to help it survive, and a CONTRIBUTING.md and HACKING.md exist for anyone who wants to send changes. The README names no maintainers beyond the author contact and gives no response-time promise.
Editorial conclusion
Use Lua Fun if you write Lua on LuaJIT 2.1 and want map, filter and reduce style chains that the tracer can compile into tight loops, particularly in a Tarantool setting. Skip the master branch for anything you ship: the README says the API may change without notice and tells production users to take the stable branch. Before adopting it, run your own hot chain under luajit -jdump and read the trace, since the README's loop result comes from one small example.
Frequently asked questions
Which Lua versions does Lua Fun support?
The README recommends LuaJIT 2.1 alpha and says Lua 5.1 to 5.3 are also supported. It does not mention Lua 5.4.
Is the Lua Fun master branch safe for production?
No. The README says master is the development branch, its API may change without notice, and production deployments should use the stable branch.
What license does Lua Fun use?
The README says Lua Fun is distributed under the MIT/X11 License, the same as Lua and LuaJIT. The repository metadata lists no recognized license, so check COPYING.md.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/luafun-luafun)Star history chart for your README
[](https://hysenlabs.com/projects/luafun-luafun)Was this useful?