Re:Admitting that Functional Programming Can Be Awkward
by silentbicycle on Tuesday June 16, 2009 @12:45PM
(#660480)
> you know that it only changes the state of this player, and nothing else.
This gets ugly when the state of every actor can potentially affect the state of every other actor, though. This is pretty common in games.
That's the main point the linked article is making.
Re:Admitting that Functional Programming Can Be Awkward
by miloshh on Tuesday June 16, 2009 @03:11PM
(#660706)
Yes, and it is a weak point.
My point, instead, was that FP does not break down when things get ugly; on the contrary, it gives much stronger guarantees on correctness. Of course, it takes effort to express the problem in the more restrictive functional paradigm.
If you have a function that moves a player in a game such as movePlayer :: PlayerState -> PlayerState, you know that it only changes the state of this player, and nothing else. In an OO language you would do something like player.doUpdate(), which has absolutely no guarantees.
Plus there are many facilities available to deal with threading and hiding state.