Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sometimes, I hate working with code where the developer was either a Basic developer or a mathematician: variable names limited to two characters (like "H" for health and "PF" for pounds of food remaining) work when when manipulating an equation and are a lot better than 0x005E, but the code isn't nearly self-documenting. On the other hand, the variable name could be "MessageMappingValuePublisherHealthStateConfigurationFactory". Naming things is one of the hard problems in computer science, and I'm glad we're past the point where the number of characters was restricted to 2 for performance reasons.

Unrelated, my monitor and my eyeballs hates the moire patterns developed by the article's background image at 100% zoom - there's a painful flicker effect. Reader mode ruins the syntax highlighting and code formatting. Fortunately, zooming in or out mostly fixes it.



over the years i've had to translate a lot of code from academics/researchers into prod systems, and variable/function naming is one of their worst habits.

just because the function you're implementing used single-character variables to render an equation in latex, doesn't mean you have to do it that way in the code.

a particular peeve was when they make variables for indexed values named`x_i` instead of just having an array `x` and accessing the ith element as `x[i]`


At least I've never seen UTF8 math symbols in the wild. Julia, Python, and other languages will let you use the pi symbol for 3.14... instead of just calling it pi.


I've seen that. Some Haskell libraries use Unicode for custom operators. Makes the code even harder to understand.


have you seen arthur whitney's code style?

https://www.jsoftware.com/ioj/iojATW.htm

i tried this style for a minute. there are some benefits, and i'll probably continue going for code density in some ways, but way less extreme

there's a tradeoff between how quickly you can ramp up on a project, and how efficiently you can think/communicate once you're loaded up.

(and, in the case of arthur whitney's style, probably some human diversity of skills/abilities. related: i've thought for a while that if i started getting peripheral blindness, i'd probably shorten my variable names; i've heard some blind people describe reading a book like they're reading through a straw)


40x25 text screens and line-by-line editors encourage short variable names as well


Also some of that older stuff it can be the compiler only let you have 8 chars for a variable name.


Applesoft BASIC only uses the first two characters (!) to distinguish one variable name from another. WAGON and WATER would be the same.

(page 7)

https://mirrors.apple2.org.za/Apple%20II%20Documentation%20P...


This is generally true of most 6502 Microsoft BASIC derivatives, Apple and Commodore included.


That was true of most BASIC dialects of that era. Many hard to track down bugs were introduced when programmers didn't understand this and had WATER overwrite WAGON.


Amstrad CPC's Locomotive BASIC supported up to 40 character variable names with no trimming.


Pretty sure the c64 did the same thing...


On the other hand, sometimes less descriptive but globally unique names add clarity because you know what they mean across the program, kinda like inventing your own jargon.

Maybe "PF" is bad in one function but if it's the canonical name across the program, it's not so bad.


> variable names limited to two characters

(It sounds like there was a justified reason for that here, though -- the variable names are not minimized during compilation to disk.)


and then there are the people who name their variables Dennis...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: