Skip to content
Discussion options

You must be logged in to vote

I treat immutability as a default at the boundaries and mutability as an optimization inside hot paths.

In systems languages, the main heuristics I use are:

Concurrency boundaries: immutability simplifies reasoning and eliminates entire classes of data races.

Hot vs. cold paths: in hot loops, controlled mutability often provides measurable gains with minimal conceptual cost.

Ownership clarity: in Rust, for example, explicit ownership and borrowing already provide safety, so mutability can be acceptable when it’s local and well-scoped.

When immutability forces excessive allocations or copying, I usually reconsider it. The goal isn’t purity, but making illegal states unrepresentable without…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iaversao7-sketch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants