Search code examples
scriptingprogramming-languagesembeddedlua

Alternatives to Lua as an embedded language?


I am working on an embedded system running Linux on a DSP. Now we want to make some parts of it scriptable and we are looking for a nice embeddable scripting language. These scripts should integrate nicely with our existing C++ code base, be small and fast.

I understand that Lua is the industry choice for problems like this. We will probably go with Lua because it is tried-and-true and proven to be stable and so on. However, as a programming language it has some rather quirky corners.

So, what alternatives are out there for embeddable languages?

EDIT:

This is about a year later.

We actually used Lua on our embedded system and it performs marvelously well. Over time, we added more and more scripting support to more and more parts of the project and that really helped to bring it along.

Performance is outstanding, really. Even rather complex operations that involve searching through long arrays or fancy string operations perform surprisingly well. We basically never ran into Lua related performance problems at all.

Interfacing with C functions is very straightforward and works really well. This allowed us to grow the scripting system painlessly.

Finally, we were astounded at how flexible Lua proved to be. Our Lua interpreter has to run on a system with a nonstandard memory allocator and without support for the double data type. There are two well-documented places in one header file we had to modify to make Lua work on that system. It is really well suited for embedding!


Solution

  • Since you say "embedded system" and "small and fast" and "integrate nicely" I would say you are correct that Lua is the number one if not the only choice. But I no longer agree that the programming language has "quirky corners". Firstly, the book Programming in Lua is simply splendid, one of the best books I have ever read. Secondly, some of the "quirky corners" come from the fact that the language is very orthogonal and clean, which in the long run is an asset, not a drawback. I find for example JavaScript much worse. If you read "Javascript the good parts" the author explains in length why some constructs in the language are design mistakes and why one should avoid the new operator. Not so in Lua, the bad parts have been removed, for example the quirky upvalue stuff was replaced with standard syntactic scoping in version 5.x.

    My view is actually that Lua is a language with far less quirky corners than most other languages! We use it in a commercial project and we are more than happy with it.