Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Code purity isn't just for you, it's also for the compiler to be able to make assumptions about the code in order to apply optimizations that would not otherwise be possible. For example, if the compiler "knows" that a certain branch won't be used, it doesn't have to evaluate it. This is part of the reason why Haskell can reach near-C performance and why its recursion is particularly performative.


> Code purity isn't just for you, it's also for the compiler to be able to make assumptions about the code in order to apply optimizations

Yes, and purity is also for your collaborators (including your future self) who didn't write the code so don't understand it as well as you do.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: