4 ms·
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
by LeifCarrotson 2y ago
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.
- harrison_clarke 2y agohave you seen arthur whitney's code style? https://www.jsoftware.com/ioj/iojATW.htm 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)
- bluedino 2y ago40x25 text screens and line-by-line editors encourage short variable names as well
- sumtechguy 2y agoAlso some of that older stuff it can be the compiler only let you have 8 chars for a variable name.
- bluedino 2y agoApplesoft 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%20Project/Software/Languages/Applesoft%20BASIC/Manuals/Applesoft%20II%20BASIC%20Programming%20Reference%20Manual.pdf https://mirrors.apple2.org.za/Apple%20II%20Documentation%20P...
- Mountain_Skies 2y agoThat 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.
- nubinetwork 2y agoPretty sure the c64 did the same thing...
- sedatk 2y agoAmstrad CPC's Locomotive BASIC supported up to 40 character variable names with no trimming.
- classichasclass 2y agoThis is generally true of most 6502 Microsoft BASIC derivatives, Apple and Commodore included.
- hombre_fatal 2y agoOn 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.
- parpfish 2y agoover 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]`
- Breza 2y agoAt 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.
- JoshTriplett 2y agoI've seen that. Some Haskell libraries use Unicode for custom operators. Makes the code even harder to understand.
- xg15 2y agoand then there are the people who name their variables Dennis...
- cjbprime 2y ago> 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.)