Hello, I am checking out the defold for the first time and I was reading the docs. In general it mentions that defold is performant and ideal for mobile/web and design choices are made with performance in mind. I would like to know further about this. Can someone elaborate or explain how it is made performant and what design choices are applied, or give a link for detailed reading? Thanks.
Good question! I’ll add some things and then perhaps @JCash and others from the team can add more. First of all, this blog post gives some insights into why Defold is fast thanks to the way we write code:
Besides using a specific code style there are also other things which favour performance:
- Memory allocations - Defold is designed to allocate the memory it needs up-front. You configure the max count of sprites and other components in game.project and this amount will be allocated when the engine starts. Fewer dynamic allocations → Faster. Iterating over contiguous blocks of memory → Faster.
-
Reactive code style - In Defold we use Lua for game logic scripting but we use an API where you hand over certain operations to the engine which executes native code. When the operation is done you get a callback which you can react to. One such example is tweening where you can animate a game object from one point to another, using some kind of easing function. Instead of moving the game object in Lua you let the engine do it for you using
go.animate()
. When the animation is finished you get a callback in Lua. The same goes for particle effects, http request, timers and many other things.
I agree, it’s a good question.
Something we try to think about is cache coherency.
Keeping the relevant data in the L1 cache when calculating things is the goal.
To make it so, we allocate contiguous blocks up front, when a collection is loaded, in a data oriented design.
Also, we keep the C structs (POD types) as small as possible.
The end result is that we can avoid some costly cache misses when processing the data.
Keeping the code small also has a similar effect, it’s less code that has to be run!
These practices come from experience from other projects (e.g. game engines), and knowing what works well and what doesn’t.
That said, I think there is nothing new or unique about our approach, we just keep this in our focus all the time.
And at the end of the day, we let the projects show if it’s performant or not.
Here’s our bunny mark example, running 32k sprites @60fps. (click to add more sprites)
Thanks for the answers! It was a good read especially the blog post. It is actually refreshing to see an engine made with performance and simplicity in mind and not bloating it with the every feature that comes to mind to make it everything engine. Its been only 3 days I’ve started to explore Defold and it’s been amazing so far. As you guys also say in the docs, it might not be the best engine for every game, but this is actually how you make a dedicated game engine to solve your dedicated problems best way possible. Defold (as far as I understand) does not try to be a golden hammer and solve every problem someway but solve some most specific problems in best way possible.
In work I use unity and in my free time I was checking out other engines just from youtube/blogs to see how they are doing but actually haven’t tried them until this week (wonder what happened this week to make me try other engine alternatives) and while there are some also very nice alternatives, I can clearly say I am enjoying Defold the most by far. It is simple and performant (which actually I care a lot, lot more than having an engine with everything that comes to mind features bloated in it) , development experience seems nothing but amazing and on top of that it is not some early stage open source prototype but actually a battle proven, mature (or at least more mature than most other alternatives) engine a lot of titles made with it. Thanks for making an amazing piece of software like this (and it is free!) and I hope you keep up the amazing work. Got yourselves just another game developer who is grateful and appreciates what you guys do.
Correct. Defold will never be the best engine for all games. But a very good engine for some games. We will not compete with Unreal and bespoke AAA engines. But we are carving a niche for ourselves in web and mobile and also to some extent some types of desktop games. And with our recent advances in 3D we will also be a good choice for some types of 3D games.
@Mathias_Westerdahl & @britzl, don’t you think that considering how the engine works it’s almost a perfect fit for Vampire Survivors clones?