News for hackers. Stuff that matters.
Re:Abandonware of the web: do you know that there is an HTML... by niek_pas on Saturday November 01, 2025 @09:31AM (#45781510)
I was just about to comment the same. I’m sure people have a good reason for it (or at leafy _a_ reason), but single-letter variable names always struck me as optimizing for the wrong thing.

As someone who likes to program in Haskell, I feel this pain very strongly. :)

Re:Abandonware of the web: do you know that there is an HTML... by adamddev1 on Saturday November 01, 2025 @09:41AM (#45781569)
Strong BASIC memories. On the Apple IIe, anything after the first two characters of variable names was ignored.
Re:Abandonware of the web: do you know that there is an HTML... by bottd on Saturday November 01, 2025 @09:38AM (#45781556)
Do you always feel this is the case? To me the go to single letter variables are very readable. Used so widely my eyes parse them like other symbols: =, &, +, etc.
Re:Abandonware of the web: do you know that there is an HTML... by alentred on Saturday November 01, 2025 @09:53AM (#45781663)
My rule of thumb: only using single letter variables in one-liners (and never if it spills to another line), or for something that is conventionally represented as such. So for example:

    ```python
    bar = [foo(e) for e in elements]
    ```
or, using `x`, `n`, `s` and similar when they represent just that, a generic variable with a number, string, etc. I think there is a Code Complete chapter about it.
Re:Abandonware of the web: do you know that there is an HTML... by jazzypants on Saturday November 01, 2025 @10:16AM (#45781811)
Yeah, I'm not GP, but my exceptions to this rule are `i` for "iterator" in `for` loops and `e` for "event" in event listeners.
Re:Abandonware of the web: do you know that there is an HTML... by NetMageSCW on Saturday November 01, 2025 @01:35PM (#45783558)
Don’t use ‘i’ (looks like 1), use ‘j1’, etc - helps set you up if you need a nested loop someday. Of course, at that point better naming would probably be best.
Re:Abandonware of the web: do you know that there is an HTML... by croes on Saturday November 01, 2025 @10:03AM (#45781730)
In real ok, but in this short example it‘s pretty obvious what t,b, r and c mean
Re:Abandonware of the web: do you know that there is an HTML... by somat on Saturday November 01, 2025 @07:03PM (#45786286)
It is also a math thing. most(if not all) constructions intended for mathematical consumption have some of the most miserable naming I have ever seen. I think it comes down to two things. when I am feeling less charitable it is that naming things is hard. so they don't bother. And when more charitable it is that they are optimizing for quick mental manipulation of a familiar machine. This tends toward the smallest variable names you can get away with, tons of implied context and compressed symbology. Of course this leaves the rest of us struggling, not with the concept but the way it is presented.

I like to joke, "you think programmers are bad at naming thing, you should see the mathematicians, programmers are infants before the infernal naming sense of the common mathematician".