lua-users home
lua-l archive

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


On Thu, Nov 6, 2008 at 4:01 PM, <darrenjones@warpmail.net> wrote:
Hello! I've been reading and learning about Lua for a bit and have a
question:  When is it appropriate to embed Lua, instead of extending it?
 I ask because for most scripting languages (Perl/python/ruby), the only
real option is to extend the language, by writing a binding to the
target library through the language's FFI (foreign function
interface)... so the entire concept of embedding a language is foreign
to me. The way I see it, it makes more sense for the higher-level
language Lua to be the 'host' language from which you make calls to
foreign libs, than to have the lower-level language (C) be the 'host'
and embedding Lua. I *think* I am missing something cool here, but I
can't really put my finger on it... can anyone give me an example where
embedding Lua was a better option than extending it?
darren

Hi Darren,

The way I see it, it's just situational. There's no magic that becomes available doing it one way or the other. Is it a Lua program that needs some binary libs to get extra functionality (in which case the main logic of your app is in Lua), or is it, say, a C program which you'd like to let users script in Lua? You could even have a C app run a Lua script for most of its logic. There are reasons for doing it either way, you just have to make a choice to fit the problem you want to solve.

One example is when you've got an application already sitting around, which you'd like to be able to script. Then you could extend it with a Lua scripting interface.

Evan