←back to thread

498 points azhenley | 7 comments | | HN request time: 0s | source | bottom
Show context
AaronAPU ◴[] No.45771866[source]
This would require coming up with an order of magnitude more variable names which is just unnecessary cognitive load.
replies(3): >>45771880 #>>45771922 #>>45772125 #
1. furyofantares ◴[] No.45772125[source]
An order of magnitude? That sounds like pretty outrageous hyperbole. A variable getting reassigned 10 times sounds extremely rare, the average in my experience has to be less than 1 reassignment. I think the approach requires coming up with maybe 10% more names.

Usually there are good, obvious names for intermediate calculations in my experience.

I'm open though - what kinds of things are you doing that require reassigning variables so much?

replies(2): >>45772715 #>>45777320 #
2. AaronAPU ◴[] No.45772715[source]
Probably exaggerated a bit with that phrasing (“outrageous” seems similarly hyperbolic ;))

But any variable which I’ve not already marked as const is pretty much by definition going to be modified at least once. So now instead of 1 variable name you need at least two.

So now the average number of variables per non-const variable is >= 2 and will be much more if you’re doing for example DSP related code or other math heavy code.

You can avoid it with long expressions but that in principle is going against the “name every permutation” intention anyway.

replies(1): >>45773127 #
3. furyofantares ◴[] No.45773127[source]
Fair enough re: "outrageous"!

It's actually math heavy code (or maybe medium heavy?) where I really like naming every intermediate. fov, tan_fov, half_tan_fov, center_x, norm_x

replies(1): >>45774144 #
4. AaronAPU ◴[] No.45774144{3}[source]
I spent a decade or so working on video codecs with an international team, and there was sort of an unwritten rule that code shouldn’t have comments and variable names shouldn’t be descriptive (english language couldn’t be assumed).

Which sounds really awful, but after a while it forces you to parse the logic itself instead of being guided by possibly-out-of-date comments and variable names.

I now prefer less verbosity so that probably explains why I’m a little out of distribution on this topic.

If you looked at any of my code prior to that job, it was the polar opposite with very “pretty” code and lengthy comments everywhere.

replies(1): >>45780144 #
5. ◴[] No.45777320[source]
6. 1718627440 ◴[] No.45780144{4}[source]
This is kind of the opposite of LLMs, they seem to derive meaning mostly from the variable names, not from what the code actually does.
replies(1): >>45781233 #
7. AaronAPU ◴[] No.45781233{5}[source]
I haven’t noticed that, will have to keep an eye out. Could help explain some quality inconsistencies.