4 ms·
> 3) Immutable (can be passed around like values) > I don't know any good reason to deviate from these rules. Even systems languages would do well to follow th
by josteink 11y ago
> 3) Immutable (can be passed around like values)
> I don't know any good reason to deviate from these rules. Even systems languages would do well to follow them, IMO.
Systems-languages are used for things like OS kernels and god knows what where other equally important rules apply:
1. being able to manipulate things directly, in place, without having to allocate additional memory (i.e. creating a new copy)
2. efficiency may be more crucial than type-system guaranteed safety.
Not saying I disagree with your general position, I'm just open to the fact that there's always valid exceptions to any rules.
- pjmlp 11y agoAnd that is why sane system programming languages like Burroughs Algol, Mesa, Modula-2, Modula-3, Ada, .... provide escape hatches for the few uses where breaking the rules is really required. But, importantly, they don't do it by default as C does.
- vardump 11y agoHmm... I can't remember any scenario I needed to manipulate (mutate) strings in kernel in place. For guaranteed small, say below 64 bytes, strings stack is usually fine. Not saying it doesn't happen, only that it is rarely needed. Usually when you can't allocate memory (like IRQ handler), you don't do string processing either.