2 ms·
Compilers care about functional programming in its side-effect-free form because you can only optimize code you can understand the side effects of, and side-eff
by msla 7y ago
Compilers care about functional programming in its side-effect-free form because you can only optimize code you can understand the side effects of, and side-effects generally foreclose on optimization. The most obvious example is the volatile keyword in C, and how that forces a lot of memory traffic the compiler would otherwise be able to avoid.
- ncmncm 7y agoThat is the theory. In practice, the optimizations compilers implement using the advantages of known lack of side effects and mutation generally just aim at recovering part of the performance lost through excess copying.