11
fbus
10d

Who thought Lua was a good idea for extending gameplay functionality??

It's weakly typed, has no OOP functionality and no namespace rules. It has no interesting data structures and tables are a goddamn mystery. Somebody made the simplest language they could and now everybody who touches it is given the broadest possible tools to shoot themselves in the foot.

Lua's ease of embedding into C++ code is a fool's paradise. Warcraft 3's JASS scripting language had way more structure and produced much better games, whilst being much simpler to work with than Lua.

All the academics describing metatables as 'powerful extensionality' and a fill-in for OOP are digging the hole deeper. Using tables to implement classes doesn't work easily outside school. Hiding a self:reference to a function inside of syntactic sugar is just insanity.

Nobody expects to write a triple-A game in lua, but they are happy to fob it off to kids learning to program. WoW made the right choice limiting it to UI extensions.

Fighting the language so you can try and understand a poorly documented game engine and implement gameplay features as the dev's intend for 'modders', is just beyond the pale. It's very difficult to figure out what the standard for extending functionality is, when everybody is making it up as they go along and you don't have a strongly-typed and structured language to make it obvious what the devs intended.

If you want to give your players a coding sandbox, make the scripting language yourself like JASS. It will be way better fit for purpose, way easier to limit for security and to guarantee reasonable performance. Your players get a sane environment to work in and you just might get the next DOTA.

Repeatedly shooting yourself in the foot on invisible syntax errors and an incredibly broad language is wasted suffering for kids that could be learning the programming concepts that cross all languages way quicker and with way more satisfying results.

Lua is hot garbage for it's most popular application, I really don't get it. Just stop!

Comments
  • 8
    Because "simplicity"... I don't know why people can't stop doing this. First it was super slow BASIC on even slower home computers from the 80s, then JavaScript in the web, Lua in games, Python for number crunching,...

    What's so attractive about slow, clunky scripting languages??
  • 2
    @12bitfloat Probably ease of development from the game dev side. Really screams to me that the game devs have zero experience modding or desire to understand modders.

    Which is a whole 'nother rant in itself. Games aren't just a factory product you can push out without knowing what you're doing.
  • 3
    @12bitfloat To be fair, Python's number cruncher isn't slow because it's implemented in C under the hood.
  • 1
    @Fast-Nop Kinda true, still doesn't help much when you do a deep copy of a list each time
  • 0
    @12bitfloat True, but it doesn't matter in most cases, and where you find it does after profiling the code, you wouldn't implement that part in Python anyway. Just like with the number crunching.
  • 1
    @Fast-Nop But then there's not much point in using a scripting language if I have to program 50% of it in C anyways

    Might as well just use Rust for everything then
  • 2
    It is very, very easy to implement a Lua interpreter inside of a game coded in another language, and it's a fairly easy language to learn for a novice coder. Writing your own custom scripting language takes time that a lot of game developers don't want to bother with.

    To be fair, it's not always a bad choice, depending on how much functionality you want game addons to have. It works fine for MMO addons since those do not tend to be extremely complex and mostly just record, manipulate, and display data of various kinds. I actually don't know of any games that use Lua for some other purpose.

    I tried to look up info about metatables since I had no idea what they were. I've read several articles and watched a few YouTube tutorials and all I've confirmed is that they're absolute bullshit that would be unnecessary in a true object-oriented language.
  • 0
    @12bitfloat If you really have 50% of your code in speed critical paths AND can prove that through profiling, then Python isn't a good fit for that application, right. But that's often not the case.
  • 0
    @EmberQuill I just saw a lua tutorial from a novice programmer using tables of tables with weakly typed values as a "dictionary". Blows my mind. The line between working code and chaos is a tight rope with a very very wide falloff area.

    If that's considered learning how to program, then yeah I guess I agree, it's easy to learn.
  • 1
    I've looked at lua before but the only application of that was programmable computers in Minecraft...

    Don't know why you would decide to make a game engine in it (think that was called löve)
  • 1
    @LotsOfCaffeine Oh that brings back bad memories. I don't know whether it was the lack of a good Lua IDE (if such a thing even exists) or the framework itself because it really wasn't a whole lot of fun
  • 2
    I have developed simple WoW addons like Raid Consumable Reminder, onyxia cloak announcers(rats people who do not wear it during encounters) and Warlock Curse Assigner, enough with self advertisement:). I only had problem with WoW API documentation. Lua never was a problem, it did not need types, it already had documentation and kinda popular(what the hell is Jass?).
  • 1
    Lua is a remnant of a past time, and it's plug and play interoperability makes it the easy way for supporting modding. But the syntax is absolute dogshit.
  • 1
    Wube thought that and gave us LUA scripting for mods in Factorio - a game designed with modding in mind from the start.
    It works pretty well and there are an insane amount of mods available for that game even though once a year all mods which aren't maintained anymore basically get obsoleted by the main game version increasing.

    LUA in my opinion is a pretty ugly language. But somehow it seems to be fast, easy to learn for the average modder and easy to integrate into a game engine. Hard to beat that if your product actually is a game designed for high modability...
  • 1
    Lua is fine if you have a good IDE with autocomplete.
    Meta tables should not be bothered with and do everything in a functional style.
    Tables are useful as namespaces and object like Tables should be inplemented with Factory Functions in mind.
    Some good annotations and dummy Lua code from the developers is nice but no always nesscessary.
    I created them myself for the Open Computers mod and development works fine.
  • 0
    @aviophile Yeah I agree it works for UI stuff.
  • 2
    The great thing with Lua is, that the basic interpreter is quite restricted.
    As a game engine developer I can "open" a fixed set of calls, so even untrusted code can easily shared without endangering the users of that code (e.g. WoW addons or the Minecraft Mod's code, where the latter **is written by users but is executed on the server**). It is also quite lightweight (in contrast to e.g. a full blown JavaScript engine or Python).
    And creating an own Language is quite some work.
  • 0
    @Oktokolo Factorio's docs are amazing
  • 0
    @12bitfloat Javascript is not slow. Python is only slow if you don't use it properly. You have to push to the internals, or like you say, write a module if its really critical.
  • 0
    I have found modding Avorion to be quite straight forward using Lua.

    Other scripting I have used in modding has been "interesting". I don't find the scripting for TES games to be particularly intuitive.
  • 0
    @Demolishun Yeah but the only reason JavaScript is fast is because some of smartest people on this planet have poored thousands of man hours into making it fast

    With that amount of effort you can make *any* language fast, and it's not like there aren't any downsides (apart from the time investment). v8 is a massive, bulky VM like the JVM

    Would you really wan't to include that in a game engine? Probably not so effectively it's still a slow language

    But that's beside the point anyways. The real question is why even design scripting languages this way. Why not design them with efficiency in mind in the first place so we don't have to put up with this farce. I don't get it
  • 0
    @12bitfloat I think a lot of it is because "it is there". Then critical mass occurs and it becomes "the only thing there". Javascript is an example of this. Python is used because everyone is using it. It is like all software development. It is organic and gets ugly over time until someone gets fed up and rewrites it. Rust would be an example of this.
Add Comment