3 ms·
Agree. After working seriously on a large production Haskell codebase for several years I definitely took it for granted. Now that I’m writing stuff in C again
by agentultra 1y ago
Agree. After working seriously on a large production Haskell codebase for several years I definitely took it for granted. Now that I’m writing stuff in C again I do think immutability should be the default.
const isn’t really it though. It could go further.
- nixpulvis 1y agoAre Rust's defaults far enough?
- 1718627440 1y agoWell in C actually you can not mutate something, you can only reassign, as it is always pass-by-value. You need to work around that, by passing a pointer to the object instead. In that sense mutability is kind of a language keyword: '&'. When you want to just get the object, you pass object it, if you need to modify it, you need to pass &object. This is something I hate in C++, that random function invocations can mutate arguments without it being obvious in the call syntax.
- astrobe_ 1y agoI think that's why the * is generally preferred over the & for this purpose. It also can give some hints about ownership issues. This "pass by reference" thing is syntactic sugar and sometimes is great to have, but as Perlis said, "Syntactic sugar causes cancer of the semicolon" [1]. [1] https://www.cs.yale.edu/homes/perlis-alan/quotes.html https://www.cs.yale.edu/homes/perlis-alan/quotes.html