lua-users home
lua-l archive

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


March 12, 2017 4:12 AM, "Soni L." <fakedme@gmail.com> wrote:

> I want most Lua libraries to be written in Lua because I use sandboxed environments a lot. Having
> the libraries written in Lua seems to help with that.

I prefer pure Lua libraries too, when possible, for two reasons.

The first one is portability to sandboxed environments, or to environments where the C compiler is very
limited, or to environments where hot code reloading is necessary...

The second one is for teaching / human accessibility purpose. I want some developers who do not know C
code to be able to read and understand the source code of the libraries.

Finally, pure Lua libraries can be faster with LuaJIT sometimes. I don't really care about that
since I use 5.3 myself though.

The best solution is probably to have modules which support both: a pure Lua implementation and a compatible,
faster C implementation with the same API, which can be used if available. That's what I did with my
lua-chacha module, for instance: https://github.com/catwell/lua-chacha

I actually have a semi-stealth project to write a collection of pure Lua 5.3 libraries for network protocols,
file formats and modern cryptographic schemes. I do not intend to include YAML in it for now, though.

-- 
Pierre Chapuis