A Question About Love2d and Performance

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
baiselmareo6
Prole
Posts: 1
Joined: Tue Mar 31, 2020 11:15 am

A Question About Love2d and Performance

Post by baiselmareo6 »

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!
User avatar
Varkas
Citizen
Posts: 83
Joined: Mon Mar 09, 2020 2:26 pm

Re: A Question About Love2d and Performance

Post by Varkas »

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.
In soviet russia, code debugs you.
User avatar
Imagic
Prole
Posts: 44
Joined: Mon Sep 30, 2019 8:20 am
Contact:

Re: A Question About Love2d and Performance

Post by Imagic »

Performance/optimization is probably one of the most filled with misconceptions topic in programming (or other areas).

LÖVE is fine.
Astorek86
Prole
Posts: 20
Joined: Fri Jul 13, 2018 7:35 pm

Re: A Question About Love2d and Performance

Post by Astorek86 »

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...
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: A Question About Love2d and Performance

Post by zorg »

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.
Me and my stuff :3True 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.
Post Reply

Who is online

Users browsing this forum: ausboss20001 and 21 guests