How can you do anything useful without mutable state?

后端 未结 18 1755
栀梦
栀梦 2020-11-28 17:12

I\'ve been reading a lot of stuff about functional programming lately, and I can understand most of it, but the one thing I just can\'t wrap my head around is stateless codi

18条回答
  •  遥遥无期
    2020-11-28 17:48

    You can't have a pure functional language that is useful. There will always be a level of mutability that you have to deal with, IO is one example.

    Think of functional languages as just another tool that you use. Its good for certain things, but not others. The game example you gave might not be the best way to use a functional language, at least the screen will have a mutable state that you can't do anything about with FP. The way you think of problem and the type of problems you solve with FP will be different from ones you are used to with imperative programming.

提交回复
热议问题