+1 vote

Apparently data oriented programming is better that object oriented programming for games. The problem is I tried searching up what they are and I did not understand. Can someone please explain what they are and if coding games in Godot is object oriented or data oriented.

in Engine by (450 points)

1 Answer

+4 votes
Best answer

Godot follows object oriented design. Most of programmers are used to it and it's intuitive.

https://docs.godotengine.org/uk/latest/getting_started/step_by_step/godot_design_philosophy.html#object-oriented-design-and-composition

If you're worried about performance, I believe that the impact would be noticable only if you're an AAA studio. Even then, Unity & UE4 both use object oriented design :)

That said, DOD is becoming more and more popular. I don't follow the game engine news closely, but it seems that Unity is going in DOD direction:

https://unity.com/dots

Most important things in data oriented design (not programming) are:

  • separation of data from logic
  • Embracing the array functions
  • Make data compact -> no unnecessary info
    etc

I suggest you check this talk, it's an hour long, but it's a good explanation:

https://www.youtube.com/watch?v=yy8jQgmhbAU

Edit:
Here is a thread on similar topic:
https://www.reddit.com/r/godot/comments/ajftpe/can_ecs_improve_performance_in_godot/

tldr; Unless you simulate a huge amount of same objects in Godot you don't really need cache hit improvements that you get by using ECS. If you do need it, you can just write your own c++ code that simulates it.

by (709 points)
selected by

I'm making a game similar to Terraria, if I use ood will I still have good performance for a game like that or do I need to use dod for a better performance. I want the game to run at 60 fps.

If you want to make a 2D game, there is no better engine than Godot IMO. Don't worry about DoD, it's not important at all. There are million more important things to consider when improving performance. For a terraria style game you can have much more than 60fps. And don't worry about performance until you absolutely need to! Premature optimization is the root of all evil.

THX thanks for clarifying for me

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.