Leave things as is? I ask you, have you attempted a large-scale project using the Lua bindings? A full game, start to finish, written in Lua? My game, Goblinson Crusoe, is just such a beast, though I am slowly but steadily reimplementing every script object as a C++ component due to the issues with the tolua++ bindings. These problems have been intermittently documented through issues raised by myself over the years, and outside of the ugly generated code (ironic that you argue for things to stay “as is” the later argue that generated bindings are verbose and ineffective; I wonder if you’ve even looked at the generated bindings now) there are issues with garbage collection that rear their ugly heads if you do things in certain ways. One such degenerate case crops up for me all the time when doing procedural generation of a map.
When generating a map, it is common to iterate in X and Y across some range, say 0 to 128 in each dimension for a moderately sized map. In the current system, if you generate any kind of garbage bound through tolua (ie, any Urho3D object, even ones returned by value) inside the inner loop, then God help you. I believe it was established that tolua internally creates tables to hold these tolua-managed objects, and these tables can grow to unwieldy sizes when objects are generated in this inner loop. Even after the garbage is collected, these tables are never resized, causing huge performance issues during later garbage collection duties as these large tables are iterated.
I may be misremembering the exact nature of the issue, since it’s been a long time since I tried to fight with it, but the effects are noticeable and unpleasant. In my game, they manifest as periodic intervals of extreme stuttering as LuaGarbageCollection spends an increasing amount of time churning its wheels for awhile. I can see frame drops from an average of 43 fps to an average of 8 fps while the profiler shows skyrocketing LuaGarbageCollection time for a period of five or six seconds, before returning to normal. While these massive allocations of garbage can be mitigated by moving any nested-loop generation structures into a C++ module of some sort, that’s not really a fix for the problem.
The Lua bindings need to be redone. That’s been known for quite awhile. There was some hope when aster started his branch, but that is long dead. I’d venture to say that as they stand, the Lua bindings are actually detrimental to the health of Urho3D, possibly conveying an impression of poor performance on the engine as a whole.
“Anyawy, I don’t want toscare you - if you carefully prepare a set of macros and templates, this still be better than generated binding.”
What do you think a third party binding generator is? It’s usually a set of macros or templates. I’ve written bindings using the raw Lua API, I’ve written them using various third party generators, and I can say that you’d have to be insane to forgo the convenience of a binding library in favor of raw Lua API, especially in an engine as large and complex as this is becoming. And I’d rather leave the maintenance of that “set of macros and templates” in the hands of a third-party developer devoted to their project, than put maintenance of those onto the Urho3D team. Ideally, the binding generator should be stable, relatively bug-free right from the start, and usable in a manner similar to the AngelScript bindings.
There are a small handful of different libraries that fit this mold: sol2, Kaguya, lua-intf, etc… These are among the more elegant and easy to use; there are other, frequently uglier, usages. The thing that sets most of the more elegant solutions apart is a reliance upon features provided either by boost or by language features introduced by later C++ standards, C++11 and beyond. sol2 wants C++14 or better, so that’s probably out. But trying to write our own set of templates and macros to match functionality with one of these libraries seems like a waste of effort to me.