+1 vote

Cheers!

Just checked out Godot and totally in love with its simplicity (as opposed to Unity)

I did study some of the documentation, and I have one thing in my mind which I would like to hear you thoughts on.

I'm a functional programmer currently working with Haxe. (therefore using Godot Sharp)

How would you unify Godot with the concept of functional programming, Godot being heavily based on OOP/imperative?

There is the Haskell approach:
encapsulating all imperative action in values of the generic type IO a (think Action<R> where R is the type of the result of the action).

I guess in Godot this could look somewhat like
function newNode(parent:Node, pos:Vector3D, orient:Quaternion, model:Model):Action<Node>
where Node represents a handle to an existing node in the scene tree.
There would then be functions to change them and stuff like move(node:Node, offset:Vector3D):Action<{}>.

In the above example one would've to write all this encapsulating code first...

My approach

I'd dream up something like GameState<T> where T is the internal state variable.

In a pacman game for instance the id of the arena, the position of pacman and all the ghosts etc. is contained in a structure called PacGame. So when instantiating a new GameState<T> it would take a parameter T->Video (In that case PacGame->Video). The type Video would essentially be a set of some kind of position-orientation-model triple. It's like saying "listen Godot, so this is how my pacman game should look like".

This would kind of be my favorite. But is it possible instead of dealing with nodes to just tell Godot "Please for this frame go and render those models at (X,Y,Z) and at (X,Y,Z) and so on"?

I understand if this is a bit against the grain, but I kind of abhor oop... just doesn't go well with functional (at least IMHO =)

What are your thoughts on that?
How would you approach this?

Very curious about your answers =)

Have a good one!
- Robin

Godot version v3.1.1.stable.mono.official
in Engine by (13 points)
edited by

I've heard about doing functional programming in the engine, but only in GDscript. Here's a video by vnen (a.k.a. George Marques, the guy who maintains GDscript) on how to make functional applications in GDscript.

Please log in or register to answer this question.

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.