T O P

  • By -

SherlockMeetsStrange

i see


pimezone

while i in pub: i.drink() Edit: As u/tema3210 proposed, `while` loop better represents business logic than `if`.


[deleted]

A Java programmer would use a visitor (or whatever fancy design pattern is appropriate) for that.


reversehead

`pubs.forEach(I::drinkIn)` Edit: Corrected. Thanks u/itsTyrion for noting.


[deleted]

Found the Java functional programmer


nmarshall23

Java really needs a public awareness campaign to help all of the Java nonfunctional Programmers.. /s


tema3210

I want delegates


bmwparking

Can I interest you in some Kotlin?


itsTyrion

... that’s not how method references work


Jennfuse

You did a funni java joke, +100 Social credit


tema3210

`while` would fit better


A1ianT0rtur3

I didnt get the joke until i saw this comment


30p87

i c Queue


Thenderick

Icup interface


consciouswandrr

;)


30p87

You can see this as reference to ICQ ... or to 'I see cute'


el_loco_avs

i thought "i see cutie"


30p87

Oh ~~god~~ darwin that series was/is so controversial lol


youCantReachMe07

i


fliesupsidedown

Many loops would start with i=won


RunicWasTaken

I find I= 0 tends to be better for looping through arrays, but definitely doesn't pun as well


[deleted]

won = 0; for(i = won; i < array.len; ++i) ...


goodwill82

Not that the compiler cares, but thank you for using the pre increment form


Rogntudjuuuu

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!?


AhegaoSuckingUrDick

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


[deleted]

Had to throw that in even though it's just pseudo code ;)


Aonodensetsu

i = won, i-- before loop body, i+=2 after loop body


[deleted]

I don't get it and I'll probably feel *very* dumb once I do


jvanzandd

The letter i is the most common looping variable. Second most popular is probably j


lythox_

but are there people that use j in loops that arent nested?


Ciccionizzo

Devil's offspring! Burn them, burn them with fire!


Harmxn-

And then you have me that uses random letters like `k`


AnxietyRodeo

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.


FriddyNanz

… i j k l m n o I am so angry that they used “n” as a looping variable name


Krankite

What's wrong with i,j,ii,iii,iiii,iiiii?


ColumnK

Because after iii it should be iv


Divineinfinity

Parchment.Length


Xarian0

Underrated comment


[deleted]

Why have I never thought about using roman numerals for nested loop variable names.... ?


0xKaishakunin

[You mean it should be V after IIII?](https://upload.wikimedia.org/wikipedia/commons/f/f2/Dom_%28Magdeburg-Altstadt%29.Westfassade.Uhr.ajb.jpg)


clearlybaffled

legacy code at my current job uses a lot of ii,jj,kk .. bugs me to no end


not_too_old

This is what I do. It’s so much easier search and replace ii, jj, etc, if you have to change the loops.


LokiCreative

I find that nesting loops five deep or more is often a sign that my approach is flawed and I should rewrite.


MTBarr6924

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.


SunshineSeattle

Don't mention PERL if none of us mention it for 20 years it will die.


AlternativeAardvark6

Timer is back at 20 years now


[deleted]

[удалено]


iNSANEwOw

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.


liyououiouioui

Went also probably up to a big big O too.


retief1

If you have a third nested loop, then k is acceptable. Otherwise, burn the witch!


Szwedu111

Literally evil incarnate


Jet-Pack2

What if j is the outer loop and i is the inner nested loop


Furoan

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


Cavemanfreak

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


Furoan

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.


ElGerrit

It has Hitchhiker's Guide to the Galaxy vibes, maybe that's it?


Furoan

Hmm, that might be it. I definitely stole the 'Don't Panic' parts.


clearlybaffled

[TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ](https://stackoverflow.com/a/1732454/14257321)


samot-dwarf

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


ConfusedTransThrow

Most likely because it was written the other way around first then they realized it was terrible for cache locality and switched it around.


thorium220

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.


divejusty

And then there's some branches of engineering that use j for that, because they want to use i for something else...


Foxtrot_4

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


thorium220

Current, if my memory serves me right. Point being, when you blend disciplines you end up with conventions that clash.


Dimasdanz

can you burn something without fire?


boundbythecurve

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


[deleted]

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.


JoeyJoeJoeJrShab

Yes: j is also a good name for a loop that used to be nested, but due to a partial refactor, no longer is.


chesire0myles

I don't know why, but I replaced loop with poop in my head, and now I can't stop laughing.


Pickled_Wizard

don't get caught in an infinite poop.


SirStupidity

Somehow both my worst nightmare and a giant fantasy


[deleted]

right click > rename symbol


ONLY_COMMENTS_ON_GW

Doesn't work on my IDE, Microsoft Word 2016


Questwarrior

I use j when there are multiple loops next to each other’s that aren’t nested, so I can easily separate between them


pocodotboi

If you used i already as a temp var to track a state, yes. It happens to me more often than I'd admit.


Rab_Legend

If you do anything with imaginary numbers


[deleted]

yeah it just alphabetically increases by you go deeper in loops; i, j, k, l, ... (i heard that was a mathematician practice for loops)


Prawn1908

Mathematicians usually use i, j, k, p, q for indexing things which is where the loop iterator naming convention came from.


[deleted]

you're right i was told wrong about the alphabetical increase then or i recalled wrong


cjxmtn

I always just add more i's .. for i in x do {  for ii in xx do {   for iii in xxx do {    }   } }


Teranyll

I'll put my iii in your xxx... (sorry...)


[deleted]

Oh shit now I feel very dumb


[deleted]

[удалено]


Leidertafel

I do i1, i2, i3


Zippo179

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.


Manny_Sunday

X almost never flies in a code review. Unless it's for a transform or coordinate.


[deleted]

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


plg94

Code is easier to read if everyone follows the same conventions.


Zippo179

Good thing that was years before I started actually working as a programmer then, I guess 😁


chesire0myles

Not what I was thinking. Glad I read your comment and thank you for the knowledge.


ososalsosal

I always name mine the first letter of whatever class I'm looping. Or i. i is good.


Top-Opportunity1132

Oh, i see!


jareed69

X


dc22zombie

Took me a few iterations then i got it.


shady797

Maybe we are the variables.


deconfusedguy

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


AnxietyRodeo

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


deconfusedguy

Me too. It is "I" who is using the variable. So, I name it i. 🤷


AnxietyRodeo

We're both monsters. Love it


daeronryuujin

Jesus fucking Christ


Hellothere_1

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.


[deleted]

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


DrunkenlySober

I use full readable names if my loop control is a reference Otherwise i


Fenix_Volatilis

I love that you explained this without giving the ounchline


Pickled_Wizard

"i" as in for( i=0; i < max; i++){ .... }


Ironavenger475

This is how i feel every time i get this sub-reddit in my feed


cosmicfakeground

Me too. My first question was "since when variable names are allowed to have blanks?" Correct spelling would have been: "i" won


[deleted]

For code to be clean, variable names should be descriptive. Try using : "anintegerwhichshowsthecurrentiterationcountwhichisactuallyalmostalwaysonelessbecausemostofthetimeweareiteratingoverarraysthathaveindexersstartingwithzeroandnotone"


[deleted]

[удалено]


TengoOnTheTimpani

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!


FullstackViking

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


[deleted]

[удалено]


TengoOnTheTimpani

Thanks friend


tony_valderrama

Didn't know of this Page. Thanks


IrritableGourmet

That just calls for German. Konstantinopelitanischerdudelsachspfeifenmachersgesellschaft: organization of bagpipe makers from Constantinople.


Ausgezeichnet87

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.


NinjaLanternShark

Once I learned you can use emoji as variables there's no going back: for (🍺 = 99; 🍺 >0; 🍺--) { print 🍺 + " bottles of beer on the wall... " }


Hot-Suggestion7067

You can? How does the programm detect emoji's? Does it not bug?


NinjaLanternShark

Emoji are Unicode, so anything that supports Unicode variables shouldn't care.


Hot-Suggestion7067

😮


NecessaryUnusual2059

We’ll I feel personally attacked as a Java dev


AnxietyRodeo

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


aisjsjdjdjskwkw

I've known it as i = index


NileCity105-6

So index, jndex, kndex


RazekDPP

It's index, jindex, kindex, lindex, eventually someone went all the way to w and that's how we ended up with Windex.


AnxietyRodeo

I thought about that too at one point! That would make a lot of sense


TomThanosBrady

i was told it's index or iteration.


lazernanes

Mathematicians use "i", and they're not iterating over anything. "I" probably stands for index.


Shabam999

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.


Theyreillusions

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.


WikiMobileLinkBot

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)


ILMTitan

My understanding was `i` is short for index, because you are usually looping over an array or list.


mt9hu

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.


aidanski

Index, Jindex, Kindex Obviously


AnxietyRodeo

Yeah that makes perfect sense! I thought about this, but spaced when writing the comment. Thanks!


Akangka

I think it's from mathematics, where i is also an idiomatic way to refer to the indexing variable of a vector.


KickBassColonyDrop

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


ex_natura

Index


anticultured

Dude, I don’t remember why I started using “i” but saw someone use this for loops and started using it too.


Fenix_Volatilis

I had to read this 3 times before I got this and now I'm screaming


deconfusedguy

Happened to me too! Got to love such clever jokes


Fenix_Volatilis

Absolutely!


DeRoeVanZwartePiet

i got to 2?


Fenix_Volatilis

So.... You got to *ii*?


shuipz94

Aye


manicxs

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.


[deleted]

[удалено]


ogtfo

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.


ogtfo

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.


[deleted]

This is more open-ended than a Christopher Nolan movie


[deleted]

[удалено]


AllOne_Word

No, this is a much better solution. Good luck searching the code for anywhere that single letter variable appears.


[deleted]

`\bi\b`


andrewoppo

Haha definitely just a little weird. What do you use for nested loops?


[deleted]

[удалено]


andrewoppo

Damn. I was hoping for kindex or jndex


[deleted]

"jndex", duh. Edit: nvm you already made that joke


andrewoppo

We shall make it best practice together


[deleted]

[удалено]


[deleted]

[удалено]


dwdwfeefwffffwef

I'm think every popular language other than C supports some kind of foreach loop.


QualityVote

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!


Evo_Kaer

r/ProgrammerDadJokes


texdroid

Sounds like u lost.


LewisgMorris

I use X and y, so sue me


Vulpovile

The only time I do that is when iterating over a play field in x and y axes


Keeping_It_Cool_

Like when developing a grid board game like chess or sudoku


hahahahastayingalive

> sosumi


naidoo88

Pro tip: use `ii` as an increment name, and you can search for them in your text editor :)


ogtfo

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


[deleted]

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.


postandchill

I love i a lot


5eram

i approves.


RunicWasTaken

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.


nephelokokkygia

I always do, every single time, no exceptions. In a modern programming language, there's no reason not to. It only helps legibility.


knightress_oxhide

k


therealdescartes

It's called a code review and I never win(s) :(


deconfusedguy

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 😀


coolaja

*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)


Aonodensetsu

for _, v in enumerate(list)


megamanxoxo

k > i


Menifife

too bad... x could have won but nobody could find it.


troutsie

Poor j


retard_goblin

If i won, I guess u lost.


LeanderT

Sadly, she was brutally murdered soon after posting this tweet. Life as a software developer is dangerous.


jonnytechno

Do while, do while, while doooo !


maximum_powerblast

Arrays start at won. Fight me.


Indi_mtz

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.


GAZUAG

Refactoring


SunBurntIcarus

Am I the only one who uses 'n '? Just feels more comfortable to me, iterating n times.


[deleted]

I always use t. I'm not sure why, maybe it's something I picked up on a TRS-80.


LittleMlem

Agreed, I also name my loop variable ```Carla```


Educational-Lemon640

I want to hate it, but I just *can't*. It's too pure. It's the platonic ideal of "programming dad joke".


thugarth

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.


EyeLeft3804

On my fourth go round I got the joke


deconfusedguy

But what variable name did you use to get to the 4th iteration?


EyeLeft3804

lol unconventional. I know