Hacker News new | past | comments | ask | show | jobs | submit login

I’ll stick my neck out there and praise Lua. While I will admit the stack is tedious to work with, all C binding bridges I’ve worked with are tedious. (With exceptions of languages that use compilers and architecture/platform specific tricks to pull off transparent bridging. LuaJIT and and LuaFFI would be one example. Swift would be another.)

Lua’s design is at least very clean and avoids allowing developers from accidentally creating nasty lifecycle design issues. It is very clear with Lua about ownership and visibility, which propagates cleanly through all aspects of Lua, such as working seamlessly with Lua’s garbage collection system. The design+code is also 100% portable to any processor/platform that has a C compiler (i.e. not requiring platform/arch specific #ifdefs, which is really useful when bringing up on a lesser-used platforms/chips.) And the design has very clear performance implications. In contrast, there was a recent talk at Google I/O about Android Dalvik vs. ARTs with respect to JNI bindings and performance. The results were non-obvious to say the least.

There is a research white paper that compared the C binding design tradeoffs of several different languages. http://www.inf.puc-rio.br/~roberto/docs/jucs-c-apis.pdf




I have embedded Ruby and Python before so I found that paper interesting to read. Wish there were mentions of languages I'm unfamiliar with (eg: squirrel, javascript). Anyway, I appreciate the design decisions and no doubt Lua has merits, but my personal experience is I haven't found it to be a pleasant language to use or embed.

Garbage collection is a controversial topic too, and if I understand correctly, a part of the reason Lua has a stack based API (with how its GC works). I somewhat liked the level of control I had with reference counting from working with CPython. Some applications may even go out of their way to disable the GC and use weak references to guarantee determinism similar to Apple's ARC. Squirrel, born as a competitor to Lua, looks to use a GC approach similar to Python at a glance..




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: