News for hackers. Stuff that matters.
Re:John Carmack on Mutable Variables by bjoli on Saturday November 01, 2025 @08:39AM (#45781186)
I spent some time discussing in another thread discussing why the foreach loop is so bad in many languages. Most of the bugs I write come from me managing state, yet if I want to do much more than going start to end of a collection I have to either use methods that are slower than a proper loop or I have to manage all the state myself.

In common lisp you have the loop macro (or better: iterate), in racket you have the for loops. I wrote a thing for guile scheme [0]. Other than that I dont know if many nice looping facilities. In many languages you can achieve all that with conbinatoes and what not, but always at the cost of performance.

I think this is an opportunity for languages to become safer and easier to use without changing performance.

0:https://rikspucko.koketteriet.se/bjoli/goof-loop

There are no comments on this comment yet.