3 ms·
You can rightfully blame having state setting be part of your language. It is easier to program without state than with it, just like it's easier to juggle 2 ba
by yjgyhj 10y ago
You can rightfully blame having state setting be part of your language. It is easier to program without state than with it, just like it's easier to juggle 2 balls than 3. Without state (or with the absolutely minimum of it) you can not make mistakes with it. Also, if your state-setting operator is super similar to your equality-checking operator, you can fall into this trap (like the devs in question did).
Programming without state is something that has helped me personally make my code much better. I produce less bugs by far since I stopped relying on state for so many things. A lot of micro-optimisations are not doable for me. In exchange I guess I get to run things in parallell very easily. But mostly, I get fewer bugs, which makes my life and the lives of my customers better.
- spacemanmatt 10y agoPicking up Clojure and learning to be extremely judicious about the use of persistent state reduced my bug output rate dramatically.
- yjgyhj 10y agoAmen to that! If Rich Hickey is reading this - it is to you I owe my thanks for the many hours I have not spent on fixing state bugs. Clojure was my first functional love story.
- aij 10y agoWriting stateful code by default in hopes that it will be faster is a premature optimization IMNSHO. A lot of times it isn't actually any faster, and it's certainly more error prone.