News for hackers. Stuff that matters.
Re:John Carmack on Mutable Variables by nielsbot on Thursday October 30, 2025 @11:47PM (#45768207)
I use Swift for work. The compiler tell you this. If a mutable variable is never mutated it suggests making it non-mutable. And vice versa.
Re:John Carmack on Mutable Variables by qmmmur on Friday October 31, 2025 @03:40AM (#45769302)
As will Typescript, at least using Biome to lint it does.
Re:John Carmack on Mutable Variables by maleldil on Friday October 31, 2025 @11:38AM (#45773283)
Re:John Carmack on Mutable Variables by nielsbot on Friday October 31, 2025 @01:05PM (#45774260)
My very minor complaint about TypeScript is you use to use `const` which is 2 additional letters.

Seriously though, I do find it slightly difficult to reason about `const` vars in TypeScript because while a `const` variable cannot be reassigned, the value it references can still be mutated. I think TypeScript would benefit from more non-mutable values types... (I know there are some)

Swift has the same problem, in theory, but it's very easy to use a non-mutable value types in Swift (`struct`) so it's mitigated a bit.

Re:John Carmack on Mutable Variables by bartvk on Friday October 31, 2025 @04:43AM (#45769704)
Yup, it's pretty great. You get into the habit of suspiciously eyeing every variable that's not a constant.