3 ms·
Your write but if you use a FP Language you are more forced to do so and it makes it easier to do. Why should I tear my self a arm of to do FP with Java or C++
by nickik 16y ago
Your write but if you use a FP Language you are more forced to do so and it makes it easier to do. Why should I tear my self a arm of to do FP with Java or C++ if I can just use Haskell or a language that is not as strict as haskell.
- silentbicycle 16y agoNo, you aren't. In OCaml, you can use mutable references, they're just not the default. Erlang has process dictionaries. Etc. Haskell is unusually strict in that regard, turning what is normally a design option into an all-or-nothing situation. Edit: I know there are a few ways around it via monads, but the culture surrounding Haskell seems quite a bit more likely to treat state/purity as an all-or-nothing issue than the others'. Maybe I'm making inaccurate assumptions about Haskell based on the loudest members of its community, though.
- jrockway 16y agoNot really. Mutable refs are provided by ST, which allows for chunks of your program where you are mutating state, but where the mutable state can't leak outside of boundaries you set. (There is also the good-old-IORef, but I avoid IO for anything that's not input or output.)
- gaius 16y agoI'd say to all intents and purposes you can't do FP with Java, or at least not leverage some of the advantages of doing do, because you simply don't know where in the libraries there might be some mutable state. In that sense, Java's greatest strength, its vast ecosystem, is a fundamental weakness. The same is true with other JVM languages such as Scala and Clojure as soon as you start to leverage third-party JARs. With Haskell, you know that something that claims to be pure is.