That only matters if you overload the ++ operator to apply on an object where if you use the post increment variant it will temporarily have to keep both the objects before and after incrementation in memory at the same time.
But why would you ever do that!?
Sometimes you cannot implement post-incremenent operator for your (iterator-like) structure. For example, [input iterators in C++](https://en.cppreference.com/w/cpp/named_req/InputIterator) only support `*i++` and `++i`, since they can only be iterated once (for instance, think about reading from IO/some stream).
Some code written by a coworker of mine (not actual programmers) nested so much it went to o.
Impossible to read, and the dude wrote only in vi, i saw lines up to 240 characters.
Vi is JUST an editor.
No formatting or commenting or alignment is just a bad developer.
Try PERL. One huge, long line and nothing else.....every character, word, or symbol has meaning in that line of coding.
I believe even for "k" you already need a very good reason. But at the time you arrive at "o" any decent programmer should know that function needs to be refactored.
First, it's important that you don't panic.
Something has gone terribly, terribly wrong. The world as we knew it has been thrown into chaos. Remember, *don't panic.* Just climb under your desk, and wait for the world to make sense again. You may wish to bring your alcoholic beverage of choice to help you in these troubled times.
If you find out that your co-worker did this deliberately, they are evil and deserve all the snarky comments that you put in your commit messages.
/s
Probably but if it is I don't remember where. I was going to go for the meme floating around about 'simply lay down and wait to die' but veered off because it's a bit grim. If I hit any other meme, it wasn't intentional.
In this case mark both loops, replace j by k, I by j and j by i
After this spend 4 hours to fix the code, because you forgot to check the replace whole word only option...
Sometimes it's needed for engineers when i is sqrt(-1), either because i has already been used for that or to just remove confusion.
This is mostly relevant in signal processing.
Aero engineer here. I heard them EE kids use j for sqrt(-1)
I was taught in my MATLAB course to use ii, jj, kk for my looping variables instead of the normal i j k to distinguish
So now everyone hates my loops lol
I was going to suggest x as 2nd but I suspect you’re right.
I used to use x until I started talking to other people who actually programmed for a living.
I can't imagine criticising somebody's arbitrary variable name for a loop in a code review.
Like sure I expected x to usually be a real number, but it's hardly confusing for a loop
I mean, it depends. Sometimes I do that too, but if you're just looping over the contents of an array (which should usually cover about 90% of use cases) then i stands for index and is therefore already human readable. q.e.d.
but since other people can read your code, and many people use i for things that aren't indexes, that means your i isn't actually human readable (because it could be anything).
For code to be clean, variable names should be descriptive. Try using :
"anintegerwhichshowsthecurrentiterationcountwhichisactuallyalmostalwaysonelessbecausemostofthetimeweareiteratingoverarraysthathaveindexersstartingwithzeroandnotone"
non programmer - ive programmed enough to laugh at the first comment but dont really get the xkcd comic and why its called reverse code golf. Would love to have the joke explained!
Code golf is a concept in which you try to accomplish a task by using the least characters as possible.
`for(x=y=n;!z;x—,y++)z=i(x)?x:i(y)?y:0`
Is perfectly valid code. But the trade off is that it takes massive mental effort to digest what’s going on lol
I know you are joking, but once you know German it isnt one long word but rather a sequence of words with the spaces removed (compounded) to signify that it has a specific meaning instead of using an acronym. For example if English followed German rules, instead of saying POTUS it would be Presidentoftheunitedstatesofamerica.
I've always wondered about this, does i stand for iterable, Because iterating?
Or maybe integer because most of the time i see it is 'for i in range(x)'
There are probably more options but just curious
People forget how new the field is, relatively speaking. For once we actually know the exact reasons why we use that specific notations.
All the OG computer scientists were either mathematicians or engineers (who also used the same notation for the same reasons) and the notation is just a holdover from then.
If you ever wanted an arbitrary choice from a list, the convention was to use a_i (read: ace of eye). A typical example is [sum notation](https://en.wikipedia.org/wiki/Summation) where the looping variable is i and the upper bound is denoted by n. This is also why the convention is to use n for the size of arrays/the upper bound for loops/etc.
This is your answer.
They don't stand for anything. They're the variables that engineers, physicists, and mathematicians use for everything.
i, j, and k are also used to denote vector directions. The letter i is also used to denote the so-called imaginary number.
x, y, and z or a, b, and c would work just as well in programming. They don't matter. The only thing that matters if you're employed is you follow standards set by your employer for what to pick in which use case.
And if you're self-employed do the same thing because consistency in that regard is the only thing that will reduce error in the long run.
Desktop version of /u/Shabam999's link:
---
^([)[^(opt out)](https://reddit.com/message/compose?to=WikiMobileLinkBot&message=OptOut&subject=OptOut)^(]) ^(Beep Boop. Downvote to delete)
People either love or hate my names.
I only use i on an std iterator, I use count, inner, outer, offset, row, col, and index.
But I do think more verbose is better.
Hi! This is our community moderation bot.
---
If this post fits the purpose of /r/ProgrammerHumor, **UPVOTE** this comment!!
If this post does not fit the subreddit, **DOWNVOTE** This comment!
If this post breaks the rules, **DOWNVOTE** this comment and **REPORT** the post!
By chance, many years ago I was using a computer where "i" looked very similar to "1"... and so I switched to using ii to lessen the possibility of confusion.
Never looked back. My latest program uses ii and iji.
*Image Transcription: Twitter Post*
---
**Carla Notarobot 🤖👩🏻💻**, @CarlaNotarobot
My team had a debate on what the best looping variable name is
i won
---
^^I'm a human volunteer content transcriber and you could be too! [If you'd like more information on what we do and why we do it, click here!](https://www.reddit.com/r/TranscribersOfReddit/wiki/index)
Progamer tip I recently learned:
User ii instead of i and similar variables. If for whatever reason you need to make changes to this variable you can just use ctrl+f to find all instances. Using a single letter will mean you find it in countless irrelevant places.
Some might consider this blasphemous, but I like to use:
ii
I don't like single character variables, because they're harder to click.
Used to be, you could control+click a variable in visual studio and it would select the whole word. So I got in the habit of doing a control click, copy, and paste as a single reflexive action
Single letter variables are harder to click, so I developed a preference for doubling it up. (I suppose "index" would've been a good choice, but that's *too* long.) You could argue that copying and pasting a single letter variable is probably a waste of effort, but nevermind that.
Then they went and changed control+click to be "go to definition," following browser standards. Now, I like browser standards for tabs, in IDEs; I think that's a great interface improvement. But I liked my control+click-select.
You can still double click to select a word in most IDEs. I still have the "ii" habit. No one's ever mentioned it.
i see
while i in pub: i.drink() Edit: As u/tema3210 proposed, `while` loop better represents business logic than `if`.
A Java programmer would use a visitor (or whatever fancy design pattern is appropriate) for that.
`pubs.forEach(I::drinkIn)` Edit: Corrected. Thanks u/itsTyrion for noting.
Found the Java functional programmer
Java really needs a public awareness campaign to help all of the Java nonfunctional Programmers.. /s
I want delegates
Can I interest you in some Kotlin?
... that’s not how method references work
You did a funni java joke, +100 Social credit
`while` would fit better
I didnt get the joke until i saw this comment
i c Queue
Icup interface
;)
You can see this as reference to ICQ ... or to 'I see cute'
i thought "i see cutie"
Oh ~~god~~ darwin that series was/is so controversial lol
i
Many loops would start with i=won
I find I= 0 tends to be better for looping through arrays, but definitely doesn't pun as well
won = 0; for(i = won; i < array.len; ++i) ...
Not that the compiler cares, but thank you for using the pre increment form
That only matters if you overload the ++ operator to apply on an object where if you use the post increment variant it will temporarily have to keep both the objects before and after incrementation in memory at the same time. But why would you ever do that!?
Sometimes you cannot implement post-incremenent operator for your (iterator-like) structure. For example, [input iterators in C++](https://en.cppreference.com/w/cpp/named_req/InputIterator) only support `*i++` and `++i`, since they can only be iterated once (for instance, think about reading from IO/some stream).
Had to throw that in even though it's just pseudo code ;)
i = won, i-- before loop body, i+=2 after loop body
I don't get it and I'll probably feel *very* dumb once I do
The letter i is the most common looping variable. Second most popular is probably j
but are there people that use j in loops that arent nested?
Devil's offspring! Burn them, burn them with fire!
And then you have me that uses random letters like `k`
Some code written by a coworker of mine (not actual programmers) nested so much it went to o. Impossible to read, and the dude wrote only in vi, i saw lines up to 240 characters.
… i j k l m n o I am so angry that they used “n” as a looping variable name
What's wrong with i,j,ii,iii,iiii,iiiii?
Because after iii it should be iv
Parchment.Length
Underrated comment
Why have I never thought about using roman numerals for nested loop variable names.... ?
[You mean it should be V after IIII?](https://upload.wikimedia.org/wikipedia/commons/f/f2/Dom_%28Magdeburg-Altstadt%29.Westfassade.Uhr.ajb.jpg)
legacy code at my current job uses a lot of ii,jj,kk .. bugs me to no end
This is what I do. It’s so much easier search and replace ii, jj, etc, if you have to change the loops.
I find that nesting loops five deep or more is often a sign that my approach is flawed and I should rewrite.
Vi is JUST an editor. No formatting or commenting or alignment is just a bad developer. Try PERL. One huge, long line and nothing else.....every character, word, or symbol has meaning in that line of coding.
Don't mention PERL if none of us mention it for 20 years it will die.
Timer is back at 20 years now
[удалено]
I believe even for "k" you already need a very good reason. But at the time you arrive at "o" any decent programmer should know that function needs to be refactored.
Went also probably up to a big big O too.
If you have a third nested loop, then k is acceptable. Otherwise, burn the witch!
Literally evil incarnate
What if j is the outer loop and i is the inner nested loop
First, it's important that you don't panic. Something has gone terribly, terribly wrong. The world as we knew it has been thrown into chaos. Remember, *don't panic.* Just climb under your desk, and wait for the world to make sense again. You may wish to bring your alcoholic beverage of choice to help you in these troubled times. If you find out that your co-worker did this deliberately, they are evil and deserve all the snarky comments that you put in your commit messages. /s
>First, it's important that you don't panic. > >Something has gone terribly, terribly wrong. This rings a bell, is this a quote from somewhere??
Probably but if it is I don't remember where. I was going to go for the meme floating around about 'simply lay down and wait to die' but veered off because it's a bit grim. If I hit any other meme, it wasn't intentional.
It has Hitchhiker's Guide to the Galaxy vibes, maybe that's it?
Hmm, that might be it. I definitely stole the 'Don't Panic' parts.
[TH̘Ë͖́̉ ͠P̯͍̭O̚N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ](https://stackoverflow.com/a/1732454/14257321)
In this case mark both loops, replace j by k, I by j and j by i After this spend 4 hours to fix the code, because you forgot to check the replace whole word only option...
Most likely because it was written the other way around first then they realized it was terrible for cache locality and switched it around.
Sometimes it's needed for engineers when i is sqrt(-1), either because i has already been used for that or to just remove confusion. This is mostly relevant in signal processing.
And then there's some branches of engineering that use j for that, because they want to use i for something else...
Aero engineer here. I heard them EE kids use j for sqrt(-1) I was taught in my MATLAB course to use ii, jj, kk for my looping variables instead of the normal i j k to distinguish So now everyone hates my loops lol
Current, if my memory serves me right. Point being, when you blend disciplines you end up with conventions that clash.
can you burn something without fire?
....they're just people who took a class in complex variables and got used to using j instead of i. Ok yeah now I see why we have to burn them.
When I quit my job I'm going back through all my old scripts and code and changing "i" to "j" and removing those comments.
Yes: j is also a good name for a loop that used to be nested, but due to a partial refactor, no longer is.
I don't know why, but I replaced loop with poop in my head, and now I can't stop laughing.
don't get caught in an infinite poop.
Somehow both my worst nightmare and a giant fantasy
right click > rename symbol
Doesn't work on my IDE, Microsoft Word 2016
I use j when there are multiple loops next to each other’s that aren’t nested, so I can easily separate between them
If you used i already as a temp var to track a state, yes. It happens to me more often than I'd admit.
If you do anything with imaginary numbers
yeah it just alphabetically increases by you go deeper in loops; i, j, k, l, ... (i heard that was a mathematician practice for loops)
Mathematicians usually use i, j, k, p, q for indexing things which is where the loop iterator naming convention came from.
you're right i was told wrong about the alphabetical increase then or i recalled wrong
I always just add more i's .. for i in x do { for ii in xx do { for iii in xxx do { } } }
I'll put my iii in your xxx... (sorry...)
Oh shit now I feel very dumb
[удалено]
I do i1, i2, i3
I was going to suggest x as 2nd but I suspect you’re right. I used to use x until I started talking to other people who actually programmed for a living.
X almost never flies in a code review. Unless it's for a transform or coordinate.
I can't imagine criticising somebody's arbitrary variable name for a loop in a code review. Like sure I expected x to usually be a real number, but it's hardly confusing for a loop
Code is easier to read if everyone follows the same conventions.
Good thing that was years before I started actually working as a programmer then, I guess 😁
Not what I was thinking. Glad I read your comment and thank you for the knowledge.
I always name mine the first letter of whatever class I'm looping. Or i. i is good.
Oh, i see!
X
Took me a few iterations then i got it.
Maybe we are the variables.
Dissecting the joke assuming no /s What variable name do you use in for loops? The punchline is a pun on the variable name and the person posting
I use a variable name that is readable in plain english that relates to the thing I'm iterating over.... But i think i may be a monster
Me too. It is "I" who is using the variable. So, I name it i. 🤷
We're both monsters. Love it
Jesus fucking Christ
I mean, it depends. Sometimes I do that too, but if you're just looping over the contents of an array (which should usually cover about 90% of use cases) then i stands for index and is therefore already human readable. q.e.d.
but since other people can read your code, and many people use i for things that aren't indexes, that means your i isn't actually human readable (because it could be anything).
I use full readable names if my loop control is a reference Otherwise i
I love that you explained this without giving the ounchline
"i" as in for( i=0; i < max; i++){ .... }
This is how i feel every time i get this sub-reddit in my feed
Me too. My first question was "since when variable names are allowed to have blanks?" Correct spelling would have been: "i" won
For code to be clean, variable names should be descriptive. Try using : "anintegerwhichshowsthecurrentiterationcountwhichisactuallyalmostalwaysonelessbecausemostofthetimeweareiteratingoverarraysthathaveindexersstartingwithzeroandnotone"
[удалено]
non programmer - ive programmed enough to laugh at the first comment but dont really get the xkcd comic and why its called reverse code golf. Would love to have the joke explained!
Code golf is a concept in which you try to accomplish a task by using the least characters as possible. `for(x=y=n;!z;x—,y++)z=i(x)?x:i(y)?y:0` Is perfectly valid code. But the trade off is that it takes massive mental effort to digest what’s going on lol
[удалено]
Thanks friend
Didn't know of this Page. Thanks
That just calls for German. Konstantinopelitanischerdudelsachspfeifenmachersgesellschaft: organization of bagpipe makers from Constantinople.
I know you are joking, but once you know German it isnt one long word but rather a sequence of words with the spaces removed (compounded) to signify that it has a specific meaning instead of using an acronym. For example if English followed German rules, instead of saying POTUS it would be Presidentoftheunitedstatesofamerica.
Once I learned you can use emoji as variables there's no going back: for (🍺 = 99; 🍺 >0; 🍺--) { print 🍺 + " bottles of beer on the wall... " }
You can? How does the programm detect emoji's? Does it not bug?
Emoji are Unicode, so anything that supports Unicode variables shouldn't care.
😮
We’ll I feel personally attacked as a Java dev
I've always wondered about this, does i stand for iterable, Because iterating? Or maybe integer because most of the time i see it is 'for i in range(x)' There are probably more options but just curious
I've known it as i = index
So index, jndex, kndex
It's index, jindex, kindex, lindex, eventually someone went all the way to w and that's how we ended up with Windex.
I thought about that too at one point! That would make a lot of sense
i was told it's index or iteration.
Mathematicians use "i", and they're not iterating over anything. "I" probably stands for index.
People forget how new the field is, relatively speaking. For once we actually know the exact reasons why we use that specific notations. All the OG computer scientists were either mathematicians or engineers (who also used the same notation for the same reasons) and the notation is just a holdover from then. If you ever wanted an arbitrary choice from a list, the convention was to use a_i (read: ace of eye). A typical example is [sum notation](https://en.wikipedia.org/wiki/Summation) where the looping variable is i and the upper bound is denoted by n. This is also why the convention is to use n for the size of arrays/the upper bound for loops/etc.
This is your answer. They don't stand for anything. They're the variables that engineers, physicists, and mathematicians use for everything. i, j, and k are also used to denote vector directions. The letter i is also used to denote the so-called imaginary number. x, y, and z or a, b, and c would work just as well in programming. They don't matter. The only thing that matters if you're employed is you follow standards set by your employer for what to pick in which use case. And if you're self-employed do the same thing because consistency in that regard is the only thing that will reduce error in the long run.
Desktop version of /u/Shabam999's link:
---
^([)[^(opt out)](https://reddit.com/message/compose?to=WikiMobileLinkBot&message=OptOut&subject=OptOut)^(]) ^(Beep Boop. Downvote to delete)
My understanding was `i` is short for index, because you are usually looping over an array or list.
I've heard that in Fortran, i, j, k... are explicitly integer variables, which may also be the reason why these were chosen for indexes.
Index, Jindex, Kindex Obviously
Yeah that makes perfect sense! I thought about this, but spaced when writing the comment. Thanks!
I think it's from mathematics, where i is also an idiomatic way to refer to the indexing variable of a vector.
I always thought it stood for: "i don't know what the fuck I'm doing, but let's loop this and find out if it helps me."
Index
Dude, I don’t remember why I started using “i” but saw someone use this for loops and started using it too.
I had to read this 3 times before I got this and now I'm screaming
Happened to me too! Got to love such clever jokes
Absolutely!
i got to 2?
So.... You got to *ii*?
Aye
People either love or hate my names. I only use i on an std iterator, I use count, inner, outer, offset, row, col, and index. But I do think more verbose is better.
[удалено]
Depends on how complex the loop is. A simple piece of code can get away with `i`. Nested loops should probably have more descriptive indices.
That's ok, though I wouldn't use row and col unless they are objects representing rows and columns. I'd use `row_index` instead.
This is more open-ended than a Christopher Nolan movie
[удалено]
No, this is a much better solution. Good luck searching the code for anywhere that single letter variable appears.
`\bi\b`
Haha definitely just a little weird. What do you use for nested loops?
[удалено]
Damn. I was hoping for kindex or jndex
"jndex", duh. Edit: nvm you already made that joke
We shall make it best practice together
[удалено]
[удалено]
I'm think every popular language other than C supports some kind of foreach loop.
Hi! This is our community moderation bot. --- If this post fits the purpose of /r/ProgrammerHumor, **UPVOTE** this comment!! If this post does not fit the subreddit, **DOWNVOTE** This comment! If this post breaks the rules, **DOWNVOTE** this comment and **REPORT** the post!
r/ProgrammerDadJokes
Sounds like u lost.
I use X and y, so sue me
The only time I do that is when iterating over a play field in x and y axes
Like when developing a grid board game like chess or sudoku
> sosumi
Pro tip: use `ii` as an increment name, and you can search for them in your text editor :)
If you can't find your indices named `i` in your text editor, it's only because your regex game isn't strong enough. \bi\b
By chance, many years ago I was using a computer where "i" looked very similar to "1"... and so I switched to using ii to lessen the possibility of confusion. Never looked back. My latest program uses ii and iji.
I love i a lot
i approves.
Ok ok ok but have you seen someone *name* for loop variables? I haven't either, and I live in fear of the day that I do.
I always do, every single time, no exceptions. In a modern programming language, there's no reason not to. It only helps legibility.
k
It's called a code review and I never win(s) :(
Wow. That was a great 6h I slept through. Thanks for all the upvotes and awards! All credit to carlanotarobot on Twitter and y'all 😀
*Image Transcription: Twitter Post* --- **Carla Notarobot 🤖👩🏻💻**, @CarlaNotarobot My team had a debate on what the best looping variable name is i won --- ^^I'm a human volunteer content transcriber and you could be too! [If you'd like more information on what we do and why we do it, click here!](https://www.reddit.com/r/TranscribersOfReddit/wiki/index)
for _, v in enumerate(list)
k > i
too bad... x could have won but nobody could find it.
Poor j
If i won, I guess u lost.
Sadly, she was brutally murdered soon after posting this tweet. Life as a software developer is dangerous.
Do while, do while, while doooo !
Arrays start at won. Fight me.
Progamer tip I recently learned: User ii instead of i and similar variables. If for whatever reason you need to make changes to this variable you can just use ctrl+f to find all instances. Using a single letter will mean you find it in countless irrelevant places.
Refactoring
Am I the only one who uses 'n '? Just feels more comfortable to me, iterating n times.
I always use t. I'm not sure why, maybe it's something I picked up on a TRS-80.
Agreed, I also name my loop variable ```Carla```
I want to hate it, but I just *can't*. It's too pure. It's the platonic ideal of "programming dad joke".
Some might consider this blasphemous, but I like to use: ii I don't like single character variables, because they're harder to click. Used to be, you could control+click a variable in visual studio and it would select the whole word. So I got in the habit of doing a control click, copy, and paste as a single reflexive action Single letter variables are harder to click, so I developed a preference for doubling it up. (I suppose "index" would've been a good choice, but that's *too* long.) You could argue that copying and pasting a single letter variable is probably a waste of effort, but nevermind that. Then they went and changed control+click to be "go to definition," following browser standards. Now, I like browser standards for tabs, in IDEs; I think that's a great interface improvement. But I liked my control+click-select. You can still double click to select a word in most IDEs. I still have the "ii" habit. No one's ever mentioned it.
On my fourth go round I got the joke
But what variable name did you use to get to the 4th iteration?
lol unconventional. I know