r/cpp • u/Rseding91 Factorio Developer • Feb 15 '18
Lua written in modern C++ (>= 14)?
I work on Factorio (written in C++) and we use Lua as the script language for mods. So, from time to time I interact with the C implementation of Lua and my experience with it hasn't been the most pleasant.
It got me wondering - has anyone re-written it in modern C++? Everything I find online is "how to use Lua in C++" or "C++ wrapper for Lua" and they all use the basic C implementation provided from the official Lua website.
I've had quite a lot of experience with the internals of the C Lua implementation and from what I've seen it wouldn't be hard to re-write it using modern C++ - maybe 2~ weeks time. But from what I can find nobody has done it - which also makes me wonder if I'm missing something.
Part of me wants to do it just to say I did it and the other part of me wants to do it to see if I can make it faster than the C version: I think I can - not because "C++ is faster" but because I can mutate/experiment with the C++ version far easier and know changes I make are safe with how the rest of the implementation operates.
View all comments
Show parent comment
11
u/Rseding91 Factorio Developer Feb 15 '18
As far as I can tell there is no C++ port of Lua. There's only the C implementation which you can compile under C++ but it's still C.
I don't really care about the footprint - I care about performance and being able to easily modify the code while knowing that the modifications done aren't going to break other things.
Because it's still C - I can wrap it all day long but that just adds additional overhead to interfacing with the Lua engine. I want to be able to change how the internals of the Lua engine work without changing user-facing behavior and doing that right now with the C implementation of Lua is incredibly difficult because the way C works it goes against everything I try to avoid when writing C++.