News for hackers. Stuff that matters.
Re:Grid – A Lua Game Engine by Kataphract on Sunday June 07, 2020 @03:01PM (#23449708)
Why do people use Lua in a world where we have Python?
Re:Grid – A Lua Game Engine by rishav_sharan on Sunday June 07, 2020 @03:15PM (#23449864)
IMO, 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.

Re:Grid – A Lua Game Engine by kroltan on Sunday June 07, 2020 @03:40PM (#23450086)
To be clear: Python does have embeddability, but it is orders of magnitude more complicated to integrate.
Re:Grid – A Lua Game Engine by CreepGin on Sunday June 07, 2020 @06:03PM (#23451282)
Hehe, hence the word "embeddability" instead of "embeddable".
Re:Grid – A Lua Game Engine by kroltan on Sunday June 07, 2020 @11:14PM (#23453255)
Oh yes. I used that word very precisely :D
Re:Grid – A Lua Game Engine by kroltan on Monday June 08, 2020 @02:32PM (#23459310)
I was half asleep when typing that comment, sorry. Too late do edit now. I meant to write:

"I believe that word was used very precisely"

Re:Grid – A Lua Game Engine by scythe on Sunday June 07, 2020 @08:31PM (#23452383)
To add to this, Lua has a thread-safe interpreter, which allows running multiple Lua threads in the same process. This contrasts with Python's GIL.
Re:Grid – A Lua Game Engine by Stevvo on Monday June 08, 2020 @02:23AM (#23454088)
You could make the same 4 points about Pawn, I don't know why nobody uses it. Pawn has all of lua's strengths without any of its quirks and weaknesses.
Re:Grid – A Lua Game Engine by anonymoushn on Monday June 08, 2020 @11:54PM (#23463492)
Some reasons I might not use Pawn:

The only benchmarks I could find claims that it is significantly slower than Luajit. The official docs claim that the fastest implementation is available on fewer platforms than Luajit.

Regarding the lack of structs, the official docs say "pawn has no "struct"s, but it extends arrays so that it can mimic light-weight structures with arrays; as an example of those extensions, pawn supports array assignment and array indices can be assigned an individual "identify" (or "purpose") and even form a sub-array." but the manual's mentions of array assignment make it seem like that's just memcpy. One could imagine having bullet objects and declaring BULLET_X=0, BULLET_Y=1, BULLET_SPRITE_IDX=2, and so on, just so that when one has a bullet object and they would like to draw it at the right location they could avoid writing draw(b[2], b[0], b[1]). Having an array of untyped cells and memcpy isn't really the same as having a struct with named members. Please correct me if I'm wrong.

A lot of useful patterns become less possible when one does not have a map or set type and when one does not have coroutines. It seems like instead of coroutines Pawn includes a syntactic sugar for a switch statement that depends on a single global state variable, in which the cases can be declared like functions. This is interesting but not particularly helpful. Why can one not have multiple different state machines, multiple instances of a state machine, and so on?

Re:Grid – A Lua Game Engine by jimbauwens on Sunday June 07, 2020 @03:07PM (#23449782)
Because 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).
Re:Grid – A Lua Game Engine by BoysenberryPi on Sunday June 07, 2020 @03:04PM (#23449746)
LuaJIT 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.
Re:Grid – A Lua Game Engine by ABS on Sunday June 07, 2020 @03:54PM (#23450217)
just a minor nitpick: LOVE2D is written in C++ :-)
Re:Grid – A Lua Game Engine by mhd on Sunday June 07, 2020 @03:28PM (#23449995)
Seriously 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.

Re:Grid – A Lua Game Engine by symmitchry on Sunday June 07, 2020 @03:04PM (#23449737)
Does Python have any good game engines? PyGame project is a nightmare.

Lua's https://love2d.org/ is amazing.

Re:Grid – A Lua Game Engine by cmrdsprklpny on Sunday June 07, 2020 @03:09PM (#23449797)
Grid appears to be based on LOVE: https://www.planimeter.org/grid-sdk/api/Game_Loop
Re:Grid – A Lua Game Engine by mjbrusso on Sunday June 07, 2020 @04:32PM (#23450539)
They are not comparable with Pygame, but easier for beginners:

https://pygame-zero.readthedocs.io

https://github.com/mjbrusso/game2dboard

Disclosure: I am the author of game2dboard

Re:Grid – A Lua Game Engine by rishav_sharan on Monday June 08, 2020 @12:24AM (#23453544)
I recently found https://arcade.academy/ Haven't used it myself but it looks feature rich and has an active community.
Re:Grid – A Lua Game Engine by shezi on Monday June 08, 2020 @05:48PM (#23461190)
Arcade is pretty nice. It's what pygame should be, at least in terms of installability.

https://arcade.academy/

Re:Grid – A Lua Game Engine by EamonnMR on Sunday June 07, 2020 @05:42PM (#23451121)
I'm curious as to what you found nightmareish about Pygame... It's SDL.
Re:Grid – A Lua Game Engine by symmitchry on Sunday June 07, 2020 @07:40PM (#23452080)
Years 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

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.

Re:Grid – A Lua Game Engine by EamonnMR on Wednesday June 10, 2020 @12:18PM (#23478831)
Fair enough. Though I have similar complaints about other packages on mac (Python and Ruby MySQL packages being good examples.)
Re:Grid – A Lua Game Engine by Quenty on Sunday June 07, 2020 @03:05PM (#23449755)
Lua 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.
Re:Grid – A Lua Game Engine by samatman on Sunday June 07, 2020 @03:20PM (#23449929)
I'm constantly asking a similar question: Why do people use Python in a world in which we have Lua.

Never gotten a satisfactory answer.

Re:Grid – A Lua Game Engine by hashmal on Sunday June 07, 2020 @03:36PM (#23450064)
Ease 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.

Re:Grid – A Lua Game Engine by Pxtl on Sunday June 07, 2020 @03:43PM (#23450111)
Have 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.

Re:Grid – A Lua Game Engine by fiblye on Monday June 08, 2020 @04:10AM (#23454601)
I 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.
Re:Grid – A Lua Game Engine by aspaceman on Sunday June 07, 2020 @03:27PM (#23449989)
Lua 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.

Re:Grid – A Lua Game Engine by andrewmcwatters on Sunday June 07, 2020 @03:53PM (#23450208)
Hi 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.

Re:Grid – A Lua Game Engine by StreamBright on Sunday June 07, 2020 @04:11PM (#23450377)
I am not sure this is not a trolling attempt.
Re:Grid – A Lua Game Engine by imprettycool on Sunday June 07, 2020 @11:10PM (#23453236)
I like how that comment has more responses than the OP