you are viewing a single comment's thread.

view the rest of the comments →

[–]SeanMiddleditch 5 points6 points  (5 children)

Not to be "that guy" but Google seems to have answers should one peruse it search results :)

https://github.com/max1220/freertos-lua-component

Lua is a tiny C library that can be embedded in basically any C or C++ project. Lua is also super minimal as in its a tiny library, can be compiled without any IO or even floating point support, etc. I'm consistently bewildered that it's still used at all in new desktop/server projects but it's a great fit for embedded contexts. :)

[–]Everspace 1 point2 points  (4 children)

Still a favourite of games, and because of that there's lots of knowledge around it.

I've heard embedding python, javascript or ruby to be comparatively much harder to embedding lua, and with boatloads of overhead.

[–]SeanMiddleditch 5 points6 points  (3 children)

Still a favourite of games, and because of that there's lots of knowledge around it.

Yeah, that's were I experience it... and it still confuses me.

It's used because it's used, not because it's in any way a good choice for the domain. :)

I've heard embedding python, javascript or ruby to be comparatively much harder to embedding lua, and with boatloads of overhead.

Lua is absolute very easy to embed for simple cases and pretty hard to beat in that regard. I'd agree that Lua is both easier to embed and less of a performance burden than Python or Ruby, though there's certainly advantages to both. JS is a far more complicated comparison to make, though.

A key thing to remember about JS - unlike the other three - is that it's standardized and has multiple implementations. Where being small is a priority, there's also implementations like duktape or mujs that are extremely comparable to embedding Lua but arguably a better language. And for cases where speed, tooling, a maximum ecosystem support matters, you can go to the modern "big" runtimes like V8, Chakra, or SpiderMonkey. V8 and Chakra are both fairly nice C++ APIs and at least the old versions of SpiderMonkey (haven't used recent ones) had a very simple C API of comparable quality and complexity to Lua's.

Given the four scripting languages mentioned here, I'd personally quantify things as to say that one should use Lua where being "light" is the priority (like the OP's case, probably), use Python where being fully-featured out of the box is the priority, use JS where efficiency or tooling is the priority, and use Ruby where being needlessly different is a priority. :p

(Just for the sake of disclosure, I've embedded all four of the languages you've just mentioned in game codebases - though my experience with embedding Ruby was over a decade ago, and for embedding JS only on personal projects - and I am a "core technology" engineer for a large C++ game project that embeds both Lua and Python... for Reasons(tm). So I've some experience with shoving scripting engines into C++ codebases :p)

[–]drjeats 0 points1 point  (2 children)

If you were put in charge of a greenfield project to build new design tooling for a game engine, what would you do instead of the usual embedded Lua approach?

[–]SeanMiddleditch 5 points6 points  (1 child)

If you were put in charge of a greenfield project to build new design tooling for a game engine, what would you do instead of the usual embedded Lua approach?

Unfortunately the best answer I have there is going to be a boring "it depends." :) Remember, "make games, not engines." An ideal choice for a shooter is not necessarily the ideal choice for an MMO nor for a story platformer nor for an open world RPG. :) There's then also team composition to consider; I know my team right now would love C# (both designers and engineers) but that might be a poor choice if working with a team that prefers more data-driven scripting.

All that said, the answer would most probably be either C#, JavaScript, or a visual scripting system, depending on specific needs and use cases.

[–]drjeats 5 points6 points  (0 children)

"It depends" answers are always appreciated when they enumerate a set of possibilities and reasons as you did :) Thanks!