is coding games in Godot data or object oriented programming?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jujumumu

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.

:bust_in_silhouette: Reply From: gmaps

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 :slight_smile:

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:

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:

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.

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.

jujumumu | 2019-11-21 17:43

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.

gmaps | 2019-11-21 19:37

THX thanks for clarifying for me

jujumumu | 2019-11-21 23:40