I have had a recent interest in functional programming and found it to be most appealing to me. However, coming from a OOP background i can't seem to wrap my head around some problems.
The main problem I am having trouble with is parallelism. I am thinking about writing a game functionally so that will be the basis of my example.
Lets say I have a Player class and update method (OOP paradigm here):
class Player(blah blah blah):
blah blah
void update(int delta):
If I want to make a bullet, assuming I have a Bullet class, i would do it as so:
if (keydown(SPACE)):
spritebatchdrawlist.append(new Bullet(self.x, self.y))
Or something like that. However, in a functional language you don't have classes so I thought about how I would make a bullet functionally. Since I know how to draw a bullet flying across the screen using recursion (not gonna show it here) I thought that i could simply call a bullet method that would do its own thing and go where it should. However, if i call said Bullet method, it would stop executing the update method until it finished rendering the Bullet. So my question is this: Is it possible to "partially execute" the bullet method, leave it on the stack, and then execute the next recursive step the next run. I know this is possible with multithreading but I was wondering is you guys knew of a cleaner (and more hardware independent solution)
Thanks