I was wondering if anyone could help me understand something about Love2d. Given that Love2d is written in C++ and uses Lua as a scripting language, does it suffer from any of the performance concerns that are inevitable in scripting languages? If so, to what extent?
Cheers!
A Question About Love2d and Performance
-
- Prole
- Posts: 1
- Joined: Tue Mar 31, 2020 11:15 am
Re: A Question About Love2d and Performance
Lua is considered to be among the faster ones of interpreted languages. Much of what you call in Love2d is implemented in C though, so most "system" calls have the speed of compiled C (or C++, but that isn't much of a difference)
Furthermore Love2d uses libraries like OpenGl and can benefit from hardware acceleration of graphics operations.
So, the only "slow" part is the code that you write yourself. And in my experience Lua is surprisingly fast, given that a lot is done with double precision floats, string comparisons and hash tables (also called associative arrays).
I'm currently working on a client server rpg system (look for Tiny Places thread to see screenshots, there are also videos linked) and the client uses 10% of one CPU core on my system. So for me, it is way fast enough for even such a project.
Furthermore Love2d uses libraries like OpenGl and can benefit from hardware acceleration of graphics operations.
So, the only "slow" part is the code that you write yourself. And in my experience Lua is surprisingly fast, given that a lot is done with double precision floats, string comparisons and hash tables (also called associative arrays).
I'm currently working on a client server rpg system (look for Tiny Places thread to see screenshots, there are also videos linked) and the client uses 10% of one CPU core on my system. So for me, it is way fast enough for even such a project.
In soviet russia, code debugs you.
Re: A Question About Love2d and Performance
Performance/optimization is probably one of the most filled with misconceptions topic in programming (or other areas).
LÖVE is fine.
LÖVE is fine.
Re: A Question About Love2d and Performance
For me, I have a little Experience in Python + Pygame, and I must say, Love2d is a lot faster than Pygame! In Pygame, you need(!) to catch every Quad that changed in the Frame before and draw only the Changes, otherwise it's impossible to draw Background and Sprites on a Resolution like 1024x768 and 60 FPS.
On Love2d, I can clear and draw the whole Canvas new on every single Frame and still provide 60 FPS on 1024x768...
Love2d and Pygame use both SDL; I really don't know what makes Pygame so slow...
On Love2d, I can clear and draw the whole Canvas new on every single Frame and still provide 60 FPS on 1024x768...
Love2d and Pygame use both SDL; I really don't know what makes Pygame so slow...
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: A Question About Love2d and Performance
No one above mentioned this but löve by default also uses LuaJIT instead of just the "vanilla" PuC lua editions, meaning that since that's a just in time compiler, it makes your code execute even faster... basically. (and you can also use C types as well, if you want; caveat is that that's slow without the JIT enabled, and android has it disabled afaik due to a bug, and iOS doesn't allow it to boot; meaning speedups from that only happen on desktop OS-es)
Also, imo a minor downside is that you're stuck with lua 5.1 + some 5.2 things that luaJIT adds for you, and a few 5.3 features löve itself adds in the love "namespace" (e.g. data un/packing)... but that said, i don't feel like i'd miss the features they tacked on over the years either.
As for why PyGame might be slower than löve might be that pygame only uses SDL and not OpenGL directly, as what löve does; i can't verify this since their website seems to be down-ish, but if that's the reason, then all graphics manipulation in pygame happens on the CPU and in main RAM instead of the GPU, hence why it's slower.
Also, imo a minor downside is that you're stuck with lua 5.1 + some 5.2 things that luaJIT adds for you, and a few 5.3 features löve itself adds in the love "namespace" (e.g. data un/packing)... but that said, i don't feel like i'd miss the features they tacked on over the years either.
As for why PyGame might be slower than löve might be that pygame only uses SDL and not OpenGL directly, as what löve does; i can't verify this since their website seems to be down-ish, but if that's the reason, then all graphics manipulation in pygame happens on the CPU and in main RAM instead of the GPU, hence why it's slower.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests