lua-users home
lua-l archive

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


On Sat, Mar 11, 2017 at 9:46 PM, Daurnimator <quae@daurnimator.com> wrote:
Why would you want all lua libraries to be written in lua?
Leveraging existing libraries, whether they be written in C, fortran,
rust or whatever is a great choice.
Using developer time to reimplement things in another language "just
because" is a huge waste of time (and money).

I don't want them all written in lua, just the ones that I'd like to use :)

Yes, re-implementing can be a waste of time, but if I have a choice between something with a dependency that requires a separate package in another language and something that doesn't I'll often prefer something that doesn't because my applications are cross platform and I haven't been entirely happy with the ecosystem for getting packages compiled, especially in a Windows environment.  Maybe luarocks or luadist have gotten better in the last few years but the last time I used them it was either not straightforward or impossible to get the native modules that I wanted installed through those tools.  In the calculus of "which package can I get started with right away" the answer is almost always the pure Lua package, and the native extension always involves some amount of additional frustration just getting the darn thing built, and that always happens again the next time you move your app to a new environment.  It adds complexity to your build and installation.

So there is a lot of value in having a pure Lua module, for me at least.  In general I'd say that if you are already working in a C/C++ environment and there's not a pre-existing module, it's often easier to make your own binding to a C/C++ library because of the ease of interfacing Lua and C/C++.  That's usually my first inclination when there's no existing Lua package.

But if I'm looking at different options for an off-the-shelve solution, I'll prefer the pure lua module everytime unless e.g., there's a reason to think the native package may offer a critical performance advantage or something.  In terms of the complexity of using the component a pure Lua implementation always wins on build and packaging requirements.  

I don't think I'm alone in not being entirely happy with the ecosystem for native extensions.  Compared to ruby gems or something it's a much less consistent experience.  Regardless of what the reasons are for that, it certainly factors into the preference for a pure Lua implementation vs. a compiled extension.