Live data from Hacker News

John Carmack on mutable variables

twitter.com

161–170 of 663 posts

Re: John Carmack on mutable variables

#163

Earlier quoted context omitted.

As a Python programmer at day job, that is Clojure-curious and sadly only gets to use it for personal projects, and is currently threatened by an obnoxious TypeScript take over, I feel this.

Removing barriers to sloppy code is a language feature. That is why vibe coding, JavaScript and Python are so attractive.

Removing barriers to civil engineering building design is a feature.

Who needs to calculate load bearing supports, walls, and floors when you can just vibe oversize it by 50%.

Re: John Carmack on mutable variables

#164

After a 2 year Clojure stint I find it very hard to explain the clarity that comes with immutability for programmers used to trigger effects with a mutation. I think it may be one of those things you have to see in order to understand.

salutes from a WestLondonCoder

Re: John Carmack on mutable variables

#166
This is the mental distinction of what something represents vs what is its value. The former should never change regardless of mutability (for any sane program…), and the latter would never change for a const declaration.

The value (pun intended) of the latter is that once you’ve arrived at a concrete result, you do not have to think about it again.

You’re not defining a “variable”, you’re naming an intermediate result.

Re: John Carmack on mutable variables

#168
Dumb question from a primarily Python programmer who mostly writes (sometimes lengthy) scripts: if you have a function doing multiple API calls - say, to different AWS endpoints with boto3 - would you be expected to have a different variable for each response? Or do you delete the variable after it’s handled, so the next one is “new?”

Re: John Carmack on mutable variables

#169
post #116

On a similar note, I’ve always liked the idea of being able to mark functions as pure (for some reasonable definition of pure). The principle of reducing state changes and side-effects feels a good one.

For what it's worth, I was experimenting with this idea for Python (in an almost completely vibe-coded fashion) here: https://github.com/jlmcgraw/pure-function-decorators

Whether it's of any actual utility is debatable

Post reply on HN