News for hackers. Stuff that matters.
Re:Show HN: My Child's First Program by xyzelement on Tuesday December 06, 2022 @12:17PM (#33883581)
I love the variable names. I definitely had the same naming conventions as a kid :)

Funny story. Sophomore year at college, I worked at a dev shop, and I was the first person to set up version control there (CVS... it was like year 2000.) The next day I reviewed changes that were merged and variables $tit and $ass were all over the place.

I assumed the guy who checked it in was just immature and met w him to "professionalize" him. But turns out these variables referred to Titles and Assignments (it was staffing software). LOL!

Re:Show HN: My Child's First Program by belthesar on Tuesday December 06, 2022 @12:21PM (#33883652)
As a kid? When writing stupid scripts, I frequently use `fart` as a variable name to this day.

I'm a staunch supporter of naming variables intentionally in software that lives, but I'm definitely not above doing a `fart=True; while fart: ...` in temporary repl work.

Maybe I'm just eternally 10 years old, haha.

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...

Re:Show HN: My Child's First Program by rootusrootus on Tuesday December 06, 2022 @12:29PM (#33883808)
Heck, when I write throwaway scripts most of my variables are different slang terms for feces. Sure, I use foo, bar, baz, bing sometimes too. But I never grew up either. At some point I decided that was a Good Thing, and I have no further plans to mature.
Re:Show HN: My Child's First Program by andai on Tuesday December 06, 2022 @12:45PM (#33884091)
In college, usually a few minutes before an assignment was due, I'd frantically Ctrl+F the project for various curse words.
Re:Show HN: My Child's First Program by olav on Tuesday December 06, 2022 @12:47PM (#33884122)
Nice. I vividly remember the days, sometimes in the 80s, in some university cellar, hacking away at our green-lit vt terminals connected to some vaxens, that one of the other regulars in the room and I used temp variables _hudli_ and _tralla_ as some kind of ritual.
Re:Show HN: My Child's First Program by olav on Tuesday December 06, 2022 @12:49PM (#33884153)
Ah, "hudli hudli" stands for "Extraordinarily fast guitar playing" https://www.urbandictionary.com/define.php?term=Hudli - it's only now that I look this up
Re:Show HN: My Child's First Program by dark-star on Tuesday December 06, 2022 @02:33PM (#33885759)
heck, in MY time, variables could only have 2 (significant) letters, so we were stuck with "hi", "jk", "ah" and things like our initials....

The good thing is that since only 2 letters were significant, the variables "fa", "fart", "fan", "fall" etc. were all treated the same, which could cause some confusion to people not familiar with the intricacies of C64 BASIC ;-)

Re:Show HN: My Child's First Program by ExtremisAndy on Tuesday December 06, 2022 @02:42PM (#33885868)
Are you serious?! That is so hilarious to me, because I do the same thing! And I am always so terrified that I will get an interview, and they will want to see a sample of my code, and I will have forgotten to take out all the bits of juvenile humor that are scattered through the code of my personal projects!
Re:Show HN: My Child's First Program by xyzelement on Tuesday December 06, 2022 @03:17PM (#33886429)
I actually try to not do that now. As they say, programming is the art of naming and I think forcing myself to think about what a variable is (and then using that name) leads to better outcomes.

Agree for throwaway work it may not matter but I try to keep myself disciplined anyway. A good example is say I am doing an advent of code and the temptation is to treat it as throw away code. But the reality is, sometimes I put it down and come back to it, and having variables like fart doesn't really help snap back into the context.

Not saying this is an absolute but I find it a general rule of thumb for myself

Re:Show HN: My Child's First Program by jrootabega on Tuesday December 06, 2022 @12:51PM (#33884192)
In a class where we were writing a parser for math expressions, this was my plausible deniability scenario when I named the functions whose job was to analyze characters. Looking back, I'm sure the teachers were not at all amused.
Re:Show HN: My Child's First Program by Mawr on Tuesday December 06, 2022 @01:40PM (#33884953)
Re:Show HN: My Child's First Program by Vaslo on Tuesday December 06, 2022 @01:46PM (#33885057)
lol nice find
Re:Show HN: My Child's First Program by metadat on Tuesday December 06, 2022 @02:49PM (#33886013)
The linked "dog story" is an.. eye opener, too:

https://old.reddit.com/r/cscareerquestions/comments/95dgrx/i...

Re:Show HN: My Child's First Program by chewxy on Tuesday December 06, 2022 @03:30PM (#33886585)
Surprisingly I did get pulled into a meeting with the CEO and a sales/custcare guy because of a similar issue.

I wrote functions that are available for the users to use (they can customize their own dashboard). Our function conventions are camelCase. The function I wrote was something along the lines of `cumOnMetric` or something like that.

Needless to say some square somewhere thought this was a joke and didn't like it. So there I was, just blinking away and wasn't even aware this was something sensitive. It was funny sure, but I didn't have the idea that it was "unprofessional". I still feel the idea of professionalism is quite a club thing.

But yeah we got our first snake_case function name because of that.

Re:Show HN: My Child's First Program by ikornaselur on Wednesday December 07, 2022 @03:10AM (#33891885)
I don't see how the casing matters here? Would `cum_on_metric` somehow be better?
Re:Show HN: My Child's First Program by sakras on Tuesday December 06, 2022 @02:42PM (#33885881)
As a kid my dad told me that I could name my variables whatever I wanted. I still remember the confusion on his face when he saw “int iPod” and “string xbox” all over my code.
Re:Show HN: My Child's First Program by xyzelement on Tuesday December 06, 2022 @04:37PM (#33887407)
I lied! It wasn't CVS... It was Visual Source Safe!
Re:Show HN: My Child's First Program by nfw2 on Wednesday December 07, 2022 @01:01AM (#33891134)
I can't imagine anyone accidentally naming their variables $tit and $ass and not realizing it. I expect the guy thought it was funny, and the domain gave him some plausible deniability.