News for hackers. Stuff that matters.
Re:LFMs and LFSPs (Michael Vanier via PG) by palish on Monday July 09, 2007 @12:23PM (#33267)
I'm a game developer. At work, we use C++, C# and our own scripting language. Our language is embedded, so the communication protocols between C++ <-> our language are straightforward, and C++ <-> C# happens through function callbacks.

At home, I use C++ plus Lua. I tried to use Lisp, but the CFFI had problems interfacing with certain foreign libraries.

To get around C++'s constraints, my solution is to move all of my game engine code to Lua with only a lightweight wrapper in C++. Lua is extremely powerful - for example, functions are first class objects, so it has closures. It's dynamically typed, so I'll spend less time convincing a compiler I should be able to run my code. It's very fast, because it has a JIT compiler which uses DynASM to generate assembly code, so it's about 1/10th the speed of C - huge for a scripting language. But most importantly, the communication protocols between Lua and C are extremely clearly defined, and work. Communication between Lisp and C is much more vague, and only sometimes works - Calling Lisp from C, for example, don't work on all platforms.

So I'd guess what influences me in my choice of multiple languages is how well two languages can communicate with one another. Can all constructs from Blub translate into Floob? How does Blub call into Floob, and vice-versa? Is it supported on all platforms? Is there a lot of example code?

You can certainly have a language mashup and solve problems in elegant ways, but it all hinges on how elegant the communication is.

If you use several different languages, and if they don't share resources (Window handles and such), and if communication between them is not speed-critical, then you can write a networking layer which each language uses to communicate with every other language. But that option seems pretty rare.

Shawn

There are no comments on this comment yet.