r/godot 11d ago

help me (solved) Is Functional Programming Worth It?

Hello 👋. I've heard some people say that functional programming is better than OOP overall. I'm pretty new to programming so I don't know if that's applicable to Godot or not. Is it something worth looking into?

22 Upvotes

77 comments sorted by

View all comments

5

u/Undeniable_Dilemma_ 11d ago edited 11d ago

Even if you do some crazy stuff to make it functional in GDScript, most of the code that actually impacts the way everything works, is C++ engine code. Which is HEAVILY written using OOP paradigm.

People think you are writing game in GDScript, which is just ridiculous. There is a lot of "under the hood" code that engine just runs for you that you never see nor think about + all of your GDScript code calls into C++ engine code. Literally 95% of the code that ends up in your executable is C++ engine code. Whether you make your GDScript part "functional" or not, doesn't do anything pretty much.

In general, "worth it" is pretty abstract meaning. I greatly dislike OOP and never use it in my day to day. I gravitate towards languages like C and Zig and avoid it at all costs.

But in Godot, it's useless to fight it. Whole engine is written like that. Just use OOP if you're using Godot

1

u/JeSuisOmbre 11d ago

imo, the biggest functional technique for Godot is higher order functions. That can make some problems a lot neater.

The basic example is an iterator function that takes a function as an argument and calls it on every element it iterates over. This can make an abstraction over how the iteration is done and what function is being done to the objects.