6 ms·
I've heard that a major use case for Lua is to enable scripting in game engines - for something like that, it sounds perfect, because the entire runtime is just
by Analemma_ 6y ago
I've heard that a major use case for Lua is to enable scripting in game engines - for something like that, it sounds perfect, because the entire runtime is just a couple thousand lines of C with few dependencies, that can be literally copy-pasted into your codebase if need be.
But honestly, I can't recommend Lua for any other use case. You'll be chugging along and then run into a brick wall when you need e.g. real regexes instead of Lua's comparatively crippled pattern matching, or a networking library that isn't hosted on one professor's personal web page that hasn't been updated in years. Take it from someone who had to throw out and port a bunch of Lua scripts when they just couldn't keep up with new business requirements: Python or Perl or Ruby is almost always a better choice.
- anonymoushn 6y agoI'd probably use PCRE there. Every C library becomes a Luajit library when you run the relevant header through the C preprocessor and paste the result into your code. Sometimes you have to do this yourself, which makes it more work than you'd need in Python though.
- sago 6y ago> I've heard that a major use case It was. At peak perhaps 10 years ago. It is telling that the game engine citation in that article is from 2009. Now the ecosystem of game engines is very different. Very few games are written in raw C/++ and have to have their own tiny scripting language packaged. They are mostly based on more established engines. 'Small studios' have gone, niched out of end-to-end dev, or re-invented as the 'indie game' world, and pretty much none have their own multi-game engine. In fact, I've only come across Lua used in Pico-8 gamejam games in the last 2 yrs, personally. (Though I'm retired now.) It was a phenomenal language for gamedev. I commissioned a Lua consultant to extend the language in a small way for a game, I ended up paying for about half the hours I expected.
- deleted 6y ago[deleted]
- pansa2 6y ago> It was. At peak perhaps 10 years ago. Yeah, I wondered if that was still the case. Most of the examples I can find of “games that use Lua” are indeed around 10 years old. Are more recent games using different scripting languages, or are they designed to not use a scripting language at all?
- anonymoushn 6y agoSome more recent titles I know of are Pocket Rumble and Blue Revolver. A lot of game devs use frameworks or engines that strongly encourage or require the user to use C#, javascript, gdscript, or gml. Solar2d and love2d use Lua but don't seem very popular. Fewer people are throwing together their own thing in C++ and putting Lua inside.
- spc476 6y agoDon't tell my coworkers this---we use Lua to process SIP messages for the Oligarchist Cell Phone Company. I found LPEG to be way nicer than Lua's patterns (or even regex) for parsing, and there are other networking modules besides that one professor's version (which one is it, by the way?). It's also used in Redis, and there's at least one major network router that uses it.
- corysama 6y agoLua is not designed to be used standalone. Many people get frustrated assuming that it's a Python alternative. Or, by trying to make it into one by writing stuff like socket libraries for it. Lua is designed specifically to be embedded within a larger program to manipulate only the features of that specific program. It is for scripting your program. Not, for scripting-up a program in Lua. Trying to do the opposite, embed Python as a scripting language inside of a larger program, is certainly possible. But, it is much, much larger endeavor that almost certainly drags in 100 pieces of functionality that you do not want inside your program for every 1 that you actually want to use. Sounds like for your situation Python/Ruby/Perl are much better matches.
- throw_m239339 6y agoSo what are the alternatives to Lula in the specific use case you just described, that are not Python? (embeddable languages).
- fanf2 6y agoTcl and Guile are aimed at the same area as Lua.
- Pxtl 6y agoIirc there are JS engines that can fit this bill too.
- corysama 6y agohttp://chaiscript.com/ http://chaiscript.com/ http://www.squirrel-lang.org/ http://www.squirrel-lang.org/ https://micropython.org/ https://micropython.org/ https://docs.racket-lang.org/inside/embedding.html https://docs.racket-lang.org/inside/embedding.html I've heard that some of the new WebAssembly implementations are actually nice to embed. But, that just moves the problem to "What language to compile to WebAssembly?" ;)
- samatman 6y agoYou chose a bad example, because Lua has lpeg as a "blessed" library. lpeg is leaps and bounds beyond regex. When I have to work with mere regex, I miss lpeg, the same way someone who is used to regex would feel when stuck with Lua patterns. Networking isn't a problem for me personally, I just use luv and I'm very happy with it. But it's true that this is under-documented, and you do have to do more thinking and less Stack Overflow copypasting than you would with a language with a larger user base.
- otabdeveloper4 6y agoLua is probably way more popular as a scripting language for web servers than for games.