For sure, this has been something I learned from working in Scala that has made my code in other projects much more readable and easier to reason about. For performance reasons I may need to use mutables, but often I can keep it in the context of the function and just encapsulate it.
There are solutions to it. For example in Scala I’ve had to use Class tags a couple of times before and they were ergonomic and functioned well