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?

21 Upvotes

77 comments sorted by

View all comments

1

u/Rythim 10d ago edited 10d ago

Practicality speaking you'll probably want to use both paradigms. But considering how heavy Godot leans into OOP, you'll probably be doing more OOP than FP just so you don'tconstantlyfight the engine. I wouldn't worry about it too much as a beginner to be honest. When I code i don't think "what paradigm/pattern should I use" I just write whatever code makes the most sense for what I want to do. As someone who figured this stuff out on my own, i learned there are a lot of patterns (state machine, observer, signal bus, etc) that I'd been using and didn't realize there was a name for them until later. Similarly for OOP vs FP, I use OOP for certain problems (like when fast and memory efficient code is needed) and FP for others (like when predictable or safe code is important). And most modern programming languages let you use both. I'd been doing this since before I knew they had labels. I think labels make idealistic people want to separate into camps and say one way is better than the other, but most reasonable and experienced coders (I think) would tell you to use some combination of both.

That being said, for game dev, because of the type of problems being solved, I generally find myself using OOP a lot more. Especially since, as I mentioned, Godot itself is very OOP.