1. 13
  1.  

  2. 4

    I always liked this example of an algorithm that naturally and efficiently uses mutation.

    An even more familiar example is QuickSort. The algorithm naturally uses mutation, but there is also a functional version that is short and elegant, but also inefficient.

    http://augustss.blogspot.com/2007/08/quicksort-in-haskell-quicksort-is.html

    https://stackoverflow.com/questions/7717691/why-is-the-minimalist-example-haskell-quicksort-not-a-true-quicksort

    https://wiki.haskell.org/Introduction#Quicksort_in_Haskell

    So I no longer have much interest in programming in languages without (idiomatic, easy) local mutation. (Quite the contrary, I would find a language with better support for explicit / exhaustive state machines more useful.) All my programs use local mutation and controlled global mutation with dependency inversion. I find that this style “scales” well. A couple comments on that:

    https://news.ycombinator.com/item?id=22835750

    https://www.oilshell.org/blog/2020/04/release-0.8.pre4.html#dependency-inversion-leads-to-pure-interpreters