4 ms·
I don't have so much a problem with the intent of the statement, but that it is misleading. Ordered execution is basically function composition, which is one of
by rbehrends 11y ago
I don't have so much a problem with the intent of the statement, but that it is misleading. Ordered execution is basically function composition, which is one of the most fundamental parts of math you'll learn. That function composition isn't commutative is nothing new, and it's something that mathematicians have to deal with every day (automorphism groups, linear algebra, functional analysis, the Collatz conjecture, whatever). Nor is it dangerous, and you aren't going to avoid function composition in a functional programming language, either.
The reason why it can become problematic is that the simple way of having mutable state is to model it as having a huge global ball of state that just gets threaded through every function as an argument. But you don't have to do it this way, and methods have been developed to do it better. See, e.g., schemas in Z (the specification language) and its refinement calculus. That very few languages (other than Eiffel and Ada/SPARK) have tried to actively go down that path is a different issue.
You can also have non-functional programming that only ever modifies a function's local state, which makes reasoning about mutability much easier. Object capability languages do this (for pretty much the obvious reasons) and ParaSail is an example of a language trying to exploit this property for concurrency. And, of course, you can do it voluntarily in any decent imperative programming language, too.
You can also relax functional programming's requirement for referential transparency a bit and get other interesting trade-offs. For example, if you have write once semantics rather than full immutability, you get a different concurrency model (what several concurrent logic programming languages have tried to exploit), which is in many ways more interesting than one based on immutability. And, of course, logic programming is also an attempt of "describing what is".