lua-users home
lua-l archive

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


 On 9/27/2010 10:02 AM, Rob Kendrick wrote:

 On Mon, Sep 27, 2010 at 11:50:50AM -0400,
 mark@anticentertainment.com wrote:
 I'm investigating using LuaPlus instead of Lua. The features page
 on Lua plus.org sounds very compelling - but I'm concerned about
 the state of this project. Scouring the net there are only a few
 inklings of activity; they are years old. The luaplus.org site
 seems dead, no activity on the forums, no obvious set of tutorials
 or documentation and even the link to download the code is broken
 on the front page.

 Do many people here use LuaPlus actively? On this mailing list
 there doesn't seem to be much chatter about it.

 My immediate reaction is to avoid something that claims to be based
 on a version of Lua that does not exist.  My complaints on some of
 their 'improvements':

 "All the power of the core Lua 5.01 work distribution."


That page says "this information is old," and it means it. LuaPlus had a version based on 5.1.x, IIRC, last time I checked. Looks like they've migrated to a new site and haven't updated their info yet. I originally used LuaPlus in Playground 4.0 (casual game SDK), though I didn't use it to its full potential because it seemed that when I linked in all of the C++ wrappers it added a huge amount of overhead to my executable. The creator later told me that shouldn't have happened, but too late to make any difference for me.

 "An optional high performance reference counted garbage collector."

 Lua's GC is already high-performance.  And I bet this
 reference-counted one leaks.


I'm pretty sure that it does reference counting PLUS mark-and-sweep, but unfortunately when we turned it on, things crashed. Again, this is years-old information; for all I know they've fixed those crash bugs at this point.

 "An easy to use C++ interface"

 The C interface is already trivial and easy to use.


Sorry, but this is a completely wrong answer. The C interface is FAR from trivial for many developers. I can use it fluently, and I still wouldn't expose more than a few functions to Lua if I had to wrap every one in the standard C interface. Digging through tables from the C interface in any non-trivial way gives you a huge pile of ugly code, while doing the same with a good C++ wrapper (including LuaPlus) can be almost pleasant. :)

Using the C interface is like using assembly code: It's good to have direct access to a low-level interface when you need it, but it's also good to wrap it in a higher level abstraction when you don't need that level of control or speed. I write assembly code from time to time as well, but I still prefer to write as much as possible in C++ or Lua.

In Playground we used the LuaPlus bindings for exposing C++ functions to Lua wrapped in a macro so that I could expose any C++ member function (that took appropriate parameters) to Lua in a single line of code, complete with parameter validation. I exposed dozens of methods to Lua using this trick that I would never have bothered with if I'd had to code them all by hand.

There are other options available for calling Lua functions from C++ and binding C++ functions to Lua, but LuaPlus makes for a reasonable abstraction. Honestly, though, I'm experimenting with other options that can wrap C++ classes in Lua more directly (OOLUA and LuaBind are on top of my list).

The biggest problem(s) for me were around the departures from standard Lua. Wide string support is pointless, IMO; give me better UTF-8 support and I'll be happy. The additional metatables were a nice feature, and there was also an extension (IIRC) that allowed for an interesting object-oriented programming paradigm, but both of these are a drawback if you want to consider ever using LuaJIT for your code. THAT became far more important for me, so I dropped LuaPlus from the 5.0 release of Playground.

YMMV.

Tim