4 ms·
I stand corrected. Don't you still have to do lots of messing around (in comparison to an imperitive language) to simulate state though?
by didroe 17y ago
I stand corrected. Don't you still have to do lots of messing around (in comparison to an imperitive language) to simulate state though?
- stonemetal 17y agoI am still new to functional programming, but so far it seems like I produce two kinds of code. Functions that gather state and functions that modify state. Say in the above example of update_world world1 all this would do is break apart the world data structure and forward the pieces to their respective update functions and then gather the parts in to a new world. The individual update functions either do the break and gather thing or they do the actual computation on a small entity or set of entities. This makes a large number of small easy to test functions that do the actual work and several "middle layer" functions that are easy to test with stubs. Though it would be interesting hear how people who have been doing FP for a while handle it.
- aufreak 17y agoThe pure functional world was pretty much impenetrable for me for that very reason ... until I encountered Monads in Haskell. Monads have changed the game completely by providing a very clean encapsulation of side effects in general. There are people who are trying to generalize it even further using what are called "arrows", but just groking Monads in Haskell will give you a new understanding, somewhat along the lines of what learning exterior calculus does to your view of traditional vector calculus.