|There's more than one way to do things|
Re: it's scripts all the way down!by perlfan (Curate)
|on Mar 15, 2016 at 14:40 UTC||Need Help??|
What is to be gained from embedding lua inside a perl script?
You can offer the users of your program a domain specific language (DSL); Lua is best know to provide support for this in particular. You mention Nmap and Snort, but mysqlproxy also uses it. It's used extensively to extend complex programs written in complex languages, e.g. C++ (WoW?). Redis is getting increasing support for Lua.
Do lua coroutines provide anything useful when used in a dominantly Perl context? (Useful could be something to gain in maintainability, performance, scalability...)
Sure, it can provide you with a way to manage many contexts by which you are doing work. Don't confuse this with multi-threading, but it can provide you with a cheap mechanism (i.e., context switching) to manage lots of unrelated blocks of work in the same execution thread. From what I've seen, I don't think Lua supports actual threads. http://www.qore.org is embeddable and supports threading, but I don't think it's as nice as Lua for this purpose.
Why isn't perl embedded in applications as often as lua is (especially since TinyPerl is the same size)?
Lua evolved to fit this explicit purpose. Perl is too heavy and doesn't provide the clean ways of binding a host program to the underlying Lua interpreter that make it a nice choice for building a DSL into your program.
Update - you mention FFI::Platypus, but that's primarily for creating wrappers around shared libraries. It might help you avoid writing an XS module directly, but it's not going give you the solid platform for a DSL like Lua.
PS: good reading on the history of Lua - http://www.lua.org/history.html