4 ms·
Why do people use Lua in a world where we have Python?
by Kataphract 6y ago
Why do people use Lua in a world where we have Python?
- symmitchry 6y agoDoes Python have any good game engines? PyGame project is a nightmare. Lua's https://love2d.org/ https://love2d.org/ is amazing.
- cmrdsprklpny 6y agoGrid appears to be based on LOVE: https://www.planimeter.org/grid-sdk/api/Game_Loop https://www.planimeter.org/grid-sdk/api/Game_Loop
- mjbrusso 6y agoThey are not comparable with Pygame, but easier for beginners: https://pygame-zero.readthedocs.io https://pygame-zero.readthedocs.io https://github.com/mjbrusso/game2dboard https://github.com/mjbrusso/game2dboard Disclosure: I am the author of game2dboard
- EamonnMR 6y agoI'm curious as to what you found nightmareish about Pygame... It's SDL.
- symmitchry 6y agoYears of being extremely difficult to run on a Mac (no pip install), horrible website update (the old one was bad, but at least it was cool & functional), and on-going issues like this: https://github.com/pygame/pygame/issues/555 https://github.com/pygame/pygame/issues/555 There's not even a note on the website that it's entirely broken in Mojave. It's just _always_ something. Compared to LOVE and numerous other projects which just worked right out of the box. I'm a total Python guy, but Pygame has always been frustrating.
- EamonnMR 6y agoFair enough. Though I have similar complaints about other packages on mac (Python and Ruby MySQL packages being good examples.)
- rishav_sharan 6y agoI recently found https://arcade.academy/ https://arcade.academy/ Haven't used it myself but it looks feature rich and has an active community.
- shezi 6y agoArcade is pretty nice. It's what pygame should be, at least in terms of installability. https://arcade.academy/ https://arcade.academy/
- BoysenberryPi 6y agoLuaJIT is much faster than Python, directly interfaces with C, incredibly small,and the language itself is very simple. This is also built on top of LOVE2D which is written in Lua and is arguably one of the best game frameworks out there.
- ABS 6y agojust a minor nitpick: LOVE2D is written in C++ :-)
- Quenty 6y agoLua has significantly better performance than Python, but the big reason is that Lua has a very nice C/C++ API that makes it easy to integrate with other programs. Combined with a 20k LoC source code, and you have a programming language that is cheap and easy to embed, fast, and simple. Batteries are not included, so it’s very light weight.
- jimbauwens 6y agoBecause Lua is much simpler than Python, but not in a way that makes it less powerful. You can grasp the entirety of Lua in your head, with all its semantics and behaviour, which is less easily done with Python (in my opinion).
- rishav_sharan 6y agoIMO, these are the main reasons; 1. Embeddability. You can create a game engine in a performant systems language like c++ and embed lua in it for the scripting. 2. Speed. The lua interpreter is much faster than python in general. When you throw luajit into the fix, they are not really comparable at all. 3. simplicity: lua is tiny. and one of the easier languages for non coders (game designers, artists) to get started with. 4. Effortless C interop. You can make lua bindings for anything written in c with minimal effort. Now to this specific engine. lua has one of the simplest and most beloved game frameworks out there - Love2d. its almost a foundational game framework for so many people (like pygame in python, XNA etc), including yours truly. Its been a beginners choice for over a decade now. Grid is built on top of Love2d. btw, just in case you are interested in a python game engine, you should try out Arcade. Its pretty feature rich and aimed at beginners.
- samatman 6y agoI'm constantly asking a similar question: Why do people use Python in a world in which we have Lua. Never gotten a satisfactory answer.
- aspaceman 6y agoLua is very easy to parse fast in a way python isn’t. It makes it adaptable to embedding, JIT and other optimizations. The cost is a less elegant syntax. I understand a lot of folks hate working with Lua, but it fits a certain niche.
- mhd 6y agoSeriously asking or just trolling? This statement could be made for almost any language. Why did we start with Python when there was Perl? Why did we start with Perl when we could use shell and awk? Why did we start writing something like awk when we could just have dedicated C programs? Why C when we had BCPL/Algol? Why Algol when we had... okay, granted, there's a limit. Regarding the specifics: Lua is very simple, you can keep the whole language in your head easily, the table mechanism is very powerful, and the whole thing is easy to embed. Which is why it was used in commercial games and thus is industry/genre-relevant.
- hashmal 6y agoEase of embedding has been pointed out. Another reason for using Lua in games is that its garbage collection strategy is well-suited for the task. Python uses reference counting (which has a predictable performance profile but can lead to long pauses if a large object graph is deallocated at once) and stop-the-world GC for reference cycles.
- Pxtl 6y agoHave you ever tried to embed a python interpreter? Lua is both easier to embed and allows you to have a strict interface. Look up the history of bastion/rexec in Python - with python there's no possibility of controlling untrusted code.
- andrewmcwatters 6y agoHi Kataphract, Much like many people turn to Python for scientific scripting, for example, Lua has gained a reputation for being easy to use in the game development world.
- StreamBright 6y agoI am not sure this is not a trolling attempt.
- imprettycool 6y agoI like how that comment has more responses than the OP
- deleted 6y ago[deleted]
- fiblye 6y agoI liked the speed and the power of tables. It's also an incredibly simple language. I learned the ins and outs in a couple of days and was able to get right to work on making a game. Almost never did I have to reference documentation after that--it all fit in my head without even really trying to memorize it. Python, on the other hand, has loads of features, but that results in me often looking up the right way to do something since there are so many layers to it. What Lua provides is rather bare, yet powerful and incredibly easy to jump right into.