lua-users home
lua-l archive

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


I'll throw my $0.02 of experience in here.  This is from a couple of years ago so sorry if anything's out of date.

I wrote a testing tool a few years back that had some unusual requirements.  It had to have a web front-end, database integration, data storage and retrieval, some code that ran in (reasonably) hard real time, integration of user-supplied scripts in the real-time segment and a limited tendency to crash.

We ended up with a python application with a portion written in a C++ library, which in turn integrated Lua for user scripting.  The C++ library kicked off a new thread that contained all the hard(ish) real-time stuff and used the Lua library for user scripting.

Lua was almost the only choice for scripting in the real-time context because it's about the only scripting language that has a non-stop-the-world garbage collector.  It is also one of fairly few languages where it is relatively easy to run a user script in a locked-down sandbox.  It would have been very difficult or impossible to meet either of these requirements in Python.  We could have done the scripting in Python or C# or Java, but the garbage collector would have ruined the timing every now and then.  We could have done it in C but the thought of compiling user-supplied C code and running it on our device made me want to chew my own leg off.

On the other hand, we chose python to do all the housekeeping, web front-end, database integration and data retrieval.  It's a little bit harder to say exactly why, but this still feels like it was the right choice.  Partly it's that it's just easier to find people who know Python and we already had some Python experience in-house whereas we all had to learn Lua from scratch.  Partly it's that it's really easy to install Python libraries to do everything we wanted - and again familiarity counted here.  We all already knew Python web frameworks.  Yes, Lua has them too, but that would have meant learning and there was no compelling reason to do all that in Lua.

Perhaps the biggest difference is that integrating C++ code with Python is light years easier than integrating C++ code with Lua.  Boost::Python makes it all so, so easy, while trying to keep a ten-deep stack straight in your head on the Lua side was an endless source of defects.  Again, there might be something out there that does all this for you in Lua too, but we didn't know about it or find it.

Regarding some of the accusations of "bloat" against the Python libraries above - of course this is perfectly true.  But I'm not sure why it matters.  That "bloat" doesn't cost you at runtime unless you use it - when it becomes useful library, not bloat.  So unless you're trying to install this on decades-old computer where disk space is a serious issue, what is the cost of that bloat?

Regards,
Tom



On Sat, 15 Jul 2017 at 13:50 szbnwer@gmail.com <szbnwer@gmail.com> wrote:
> I don't miss arrays at all. Lua does a good job. What I do miss are
> tuples, i.e. constant arrays (not the same as Lua tuples).
>
> In Lua, x[{1,2,3}] is legal, but not equal to another x[{1,2,3}.
> In Python, x[[1,2,3]] is illegal, but x[(1,2,3)] is legal and
> equal to another x[{1,2,3}].

that can be implemented with a function that returns an identity