3 ms·
I agree completely about immutability and purity—for my own code I strongly lean that way and try to outsource as much of my thinking to the compiler as possibl
by lolinder 4y ago
I agree completely about immutability and purity—for my own code I strongly lean that way and try to outsource as much of my thinking to the compiler as possible.
However, there are times where impurity and mutability are beneficial—whether within a single function or at the margins. Functional programming languages do not tend to have good support for these cases, because their whole thing is representing everything in a functional style.
I think this is why functional languages don't tend to get traction while the multi-paradigm languages do. Given a choice between purity and pragmatism, most engineers will pick pragmatism. The alternative is to intentionally remove tools from your toolbox, and unless those tools are demonstrably more dangerous than they are helpful that's a tough sell.
My ideal language is a multi paradigm language which has robust, statically analyzable support for objects, imperative code, and functional code.
- Tainnor 4y agoI mean, you can write mutable code in Haskell, too. Parts of it can even look quite imperative. I think there are other cultural problems with the language, though.
- lelanthran 4y ago> I think this is why functional languages don't tend to get traction while the multi-paradigm languages do. Given a choice between purity and pragmatism, most engineers will pick pragmatism. Well, it's obvious to the working corporate-employed programmer, not so obvious to the ivory-tower theorist. The short argument is that the entire point of a program is to take inputs and produce outputs. Making the consumption of inputs and the generation of outputs a second-class citizen in the language with the goal of "purity" just makes it that much harder for a program to perform its primary task.
- naasking 4y ago> Making the consumption of inputs and the generation of outputs a second-class citizen in the language with the goal of "purity" just makes it that much harder for a program to perform its primary task. You have this backwards. I/O is second class in every language except Haskell and languages with type and effect systems. Those are the only languages where it's a first-class citizen, which is to say that I/O computations are values that can be passed around, interpreted and otherwise recognized or operated on in various ways. The problem is that people are used to the second class status and don't understand the additional power first class status gives you, or the patterns needed to make it extensible and maintainable.