Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) 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


In reply to Re: it's scripts all the way down! by perlfan
in thread it's scripts all the way down! by QuillMeantTen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-25 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found