A fifth approach is to use third-party bindings for standard Lua (no stuck-in-5.1 LuaJIT needed) like Sol2.
From: Dirk Laurie [mailto:firstname.lastname@example.org]
Sent: Thursday, December 21, 2017 8:34 PM
To: Lua mailing list
Subject: Re: Guide for Lua bindings
2017-12-22 2:54 GMT+02:00 Gregg Reynolds <email@example.com>:
> A humble suggestion for Roberto (or anybody else): a thorough guide to Lua
> as extension and extending Lua.
> I just finally paid good $$ for PIL 4, and am glad I did. However, it's main
> focus, naturally, is Lua programming. The material on the C interface is
> good as far as it goes, but it leaves me hungry for more.
> I would pay good Bitcoin for a Guide to writing Lua bindings that covers the
> hairy bits - like dealing with coroutines, strategies for organizing code,
> etc. - in a little more detail, with examples, maybe covering multiple
> There's plenty of info along these lines on the web, but it sure would be
> nice to have an authoritative Guide.
There are at least four approaches:
1. Use a tool that generates bindings for you directly from the headerfiles.
2. Use LuaJIT which has an FFI built in.
3. Do it neatly by hand but stay so close to the the original that the C documentation can be used as is. Most of the better contributions to LuaRocks do this.
4. Hide all the details under a level of abstraction so that the user need not even know which library is being bound. This approach sits underneath Love2D.
Each of these has advantages that in certain situations makes it more approprate tham the others.
I think it is a good thing, and typical of the Zen of Lua , that the Lua team does not enshrine any of the above.
 Less is more.