I’ve been trying to decide how to embed Lua into my application for scripting and extension purposes.
I have a class which handles objects that have structures which resemble Lua tables. (specifically a hash map of boost::any)
Lua scripts would interact with these objects and their hash maps.
It is becoming clear to me that I could write the entirety or a large chunk of this class in Lua (and access it from C), but I am uncertain of the consequences of doing so, particularly memory usage with regard to creating the many tables to represent the hash maps.
The reason for coming to this conclusion is that I would like to store high-level structures from Lua in these C objects, but doing so would require an explicit table serialization every time a table is stored into or retrieved from a C object. Theoretically, this approach would offer less memory usage in a trade-off for higher latency per access.
What are the possible courses of action in this situation and their advantages and disadvantages?
I eventually decided to settle on programming the majority of my application in Lua using LuaJIT, for a number of reasons, including:
I feel that I am losing a little of “power-user” control over my project by doing this, but I consider this to be due to my inexperience with the intricacies of Lua versus my knowledge of C++.