News for hackers. Stuff that matters.
Re:Show HN: My Child's First Program by taylodl on Tuesday December 06, 2022 @12:41PM (#33884016)
I must be old-fashioned! My variable names in throwaway programs tend to be x, y, and z and my iteration variables tend to be i, j, and k.
Re:Show HN: My Child's First Program by noboostforyou on Tuesday December 06, 2022 @01:31PM (#33884809)
Same (did you start learning programming with C?). i++ is pretty much hardcoded into my brain.
Re:Show HN: My Child's First Program by craigkilgo on Tuesday December 06, 2022 @01:37PM (#33884903)
Everyone doesn't use i,j,k for counting variables?
Re:Show HN: My Child's First Program by tqwhite on Tuesday December 06, 2022 @03:00PM (#33886172)
Yes. At least all decent people.
Re:Show HN: My Child's First Program by jasonhansel on Tuesday December 06, 2022 @02:01PM (#33885250)
Huh. I tend to use the first letter of the type, so "s" for a string, "d" for a dictionary, etc. Then "s2," "d2," etc. if there are more than one.
Re:Show HN: My Child's First Program by SoftTalker on Tuesday December 06, 2022 @04:16PM (#33887169)
When I learned programming the BASIC variant I used only supported two-character variable names. And even where longer names were allowed, the text of the program consumed memory so you could optimize by keeping variable names as short as possible. So I had the habit of using single-letter variables for quite a while. I still use them as loop counters, or in small functions where the scope of the variable is maybe a few lines of code and completely unambiguous. In such cases I think long variable names are distracting.
Re:Show HN: My Child's First Program by qolop on Tuesday December 06, 2022 @10:17PM (#33890250)
My foo is "yo" and my bar is "ho"
Re:Show HN: My Child's First Program by volkanvardar on Wednesday December 07, 2022 @12:31AM (#33890945)
Mine are: x, xx, xxx, xxxx...
Re:Show HN: My Child's First Program by laylomo2 on Wednesday December 07, 2022 @04:49PM (#33900777)
Mine are just whatever happens to be under the keyboard layout I'm using at the time. If qwerty, then `asdf`, `qwer`, `uiop`, `zxcv` are likely to be temp variable names. But since I've dabbled in other layouts, I've found the names have changed to:

- Dvorak: aoeu, htns, gcrl, mwvz

- Colemak: arst, neio, qwfp

- Mtgap: inea, htsr, dlcw, fvgj

etc...