News for hackers. Stuff that matters.
Re:Why study functional programming? (2012) by at_compile_time on Tuesday August 02, 2022 @03:06PM (#32322941)
What are the advantages of complete immutability when we can write compilers that specifically prevent shared mutability? You're avoiding the dangerous quadrant but also excluding a valid one. I'd definitely prefer FP's solution over Python's GIL, but it still feels like an unnecessary compromise.
Re:Why study functional programming? (2012) by assbuttbuttass on Tuesday August 02, 2022 @03:12PM (#32323016)
Most functional languages allow mutability when you need it, they just default to immutable data. Haskell might be the exception, where everything has to be immutable all the time
Re:Why study functional programming? (2012) by poorlyknit on Tuesday August 02, 2022 @03:55PM (#32323494)
This is not true, Haskell of course allows you to mutate state. It just forces you to declare it: For example, there's a MutableByteArray type whose operations only work in a specific Monad (because Haskell...) [1].

There's also more basic stuff like IORef which represents an assignable variable [2]. Again, you're constrained to use this in IO contexts.

Etc.

Haskell basically just forces you to do that thing someone else in this thread mentioned: Write functional APIs, allow side effects but make them explicit and confined to very specific places.

[1]: https://hackage.haskell.org/package/primitive-0.7.4.0/docs/s... [2]: https://hackage.haskell.org/package/base-4.16.3.0/docs/Data-...

Re:Why study functional programming? (2012) by marcosdumay on Tuesday August 02, 2022 @03:52PM (#32323463)
Everything does not have to be immutable in Haskell. It's only that mutability can only exist in IO or some other context that deals with it. The language enforces purity, not immutability.