|
|
Subscribe / Log in / New account

Lua and Python

Lua and Python

Posted Feb 13, 2020 4:46 UTC (Thu) by Kamilion (subscriber, #42576)
Parent article: Lua and Python

Huh. Generally the place I encounter lua the most is game engines. And to be quite honest: Nobody wants 'batteries' there, at worst they're a security vulnerability waiting to happen (Starbound's lua interpreter can't even do file I/O for example, it has to go through the C++ engine code to do so) and at best they're just excess baggage if they're not already incredibly performant. But for "simple" AI routines, NPC dialog trees, and other tasks, what good is amiga AIFF audio support? (one of the python stdlib batteries scheduled to be dropped)

Factorio's lua support for modding exposes a lot of helper functions that will never exist in any other lua interpreter.

Prison Architect's engine blacklists network functions from running. Teleglitch and TOME/Tales of Maj'Eal both expose engine state to the interpreter using structs incompatible with the lua-struct type identifiers.

Fivem's lua injector for Grand Theft Auto 5 allows completely arbitrary network and file I/O and there's been at least three instances of malware being spread.

Heck, I even have a repo stuffing lua5.1 into the .NET process of Terraria and enumerating and exposing all of the internal functions.
https://github.com/kamilion/WraithModRevival/tree/master/...
It even patches the game to create and enable a quake-like console when you press `/~.

NONE of the lua scripts above are compatible with each-other in any way. Every single one of them relies on implementation specific bridge functions that do not exist in the others.

And honestly? Lua's really the only interpreter that does things this way.
S'why I constantly have to tell all the tweenaged gamers on discord utilizing my server hosting, "There's no books to learn lua for this task. All you can do is experiment."

For non-gaming uses, look at OpenRESTY, embedding lua into the nginx service. Quite nice if you don't want to run uwsgi+python for a simple microservice endpoint.


to post comments

Lua and Python

Posted Feb 13, 2020 11:03 UTC (Thu) by excors (subscriber, #95769) [Link] (2 responses)

As another gaming example, Civilization 4 used Python, but Civ 5 switched to Lua. Presumably their experience with Python was less positive than they hoped for. I don't see any official comments explaining why they switched, apart from a complaint about Boost.Python's effect on C++ build times (https://games.slashdot.org/story/05/10/27/059220/answers-...), but it does suggest Lua is the better choice for this use case.

Personally I'd prefer that Lua remain tightly focused on that kind of embedded use, rather than aiming to be a general-purpose language that can compete with Python, because Python already exists and is alright, and it seems inevitable that a widening of scope would result in compromises that make Lua less good in the embedded niche where there is currently no good alternative.

Lua and Python

Posted Feb 13, 2020 18:29 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link]

Lua interpreter is single-threaded, but it doesn't have any global state. So you can easily run it concurrently on multiple threads, even with LuaJIT if needed. CPython is always single-threaded and global.

Lua and Python

Posted Feb 15, 2020 11:21 UTC (Sat) by togga (subscriber, #53103) [Link]

Well. As numerous comments suggest, with a packet manager you can have it both way. And while Python has drifted towards the moon in bloat/features and has dropped the embedded case (both embedding and communicating with embedded devices) I'm thrilled to see a scripting language adding batteries while keeping everything lean and mean.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds