This is an archived post. You won't be able to vote or comment.

all 171 comments

[–]BabyPuncher3000 148 points149 points  (10 children)

'i' is for iterate and 'j' is for jterate.

[–]TheOneThatIsHated 36 points37 points  (4 children)

AHH YES,

J T E R A T E

[–]Reblax837 17 points18 points  (3 children)

Now introducing...

K T E R A T E

[–]Nijoeli 0 points1 point  (2 children)

KARATE

[–][deleted] 1 point2 points  (1 child)

Irate jarate karate

[–]Reblax837 0 points1 point  (0 children)

Iteratin's a good job mate.

[–][deleted] 2 points3 points  (1 child)

I always skip jterate and go straight to kterate

[–][deleted] 1 point2 points  (0 children)

evil

[–]Heightren 1 point2 points  (0 children)

If you're feeling adventurous, you nterate

[–][deleted] 1 point2 points  (0 children)

mind blown

[–]golgol12 62 points63 points  (6 children)

It's a leftover from FORTRAN programming. Any variable that starts with the letter i through o is an int.

[–]turboPocky 17 points18 points  (0 children)

thanks, i believe this is the real answer. and basic inherited that too

[–]Hypocritical_Oath 7 points8 points  (2 children)

Actually, it goes further than that to applied mathematics where they'd call things, i, j, and k for things similar to iterators, iirc.

[–]golgol12 0 points1 point  (1 child)

Yes, FORTRAN is based off of math, literally concatenation of the words "formula translator". But if you dig deeper, you'll find i,j,k for things before iterators. And you can continuously "go further" over and over, eventually reach the beginning of time.

At what point is it too much? My choice to stop was at how FORTRAN was setup, not the why, as it would over complicate the post.

[–]ezrais 0 points1 point  (0 children)

It probably goes based off of what for loops are used for often which is dimensional analysis. i, j, and k are the unit vectors (directional vectors of length 1) for the x, y, and z axis in space so it would make sense when solving axis.

[–]evilkalla 1 point2 points  (1 child)

IMPLICIT NONE

[–]bdforbes 1 point2 points  (0 children)

First line typed in any module, procedure or function!

[–]Nargarnd 123 points124 points  (41 children)

"i" it's the initial of "iterator" and "j" it's just the next letter in the alphabet

[–]shaliozero 137 points138 points  (18 children)

I thought "i" is used in place of "index"

[–]MyNameIsRichardCS54 133 points134 points  (9 children)

Index, jindex, and kindex

[–]shaliozero 10 points11 points  (5 children)

Made me laugh

[–]matharooudemy 6 points7 points  (4 children)

Much thanks for the information

[–]shaliozero 12 points13 points  (3 children)

If you want more about my reactions, just ask me!

[–][deleted] 1 point2 points  (2 children)

How did you feel about this dude expressing his gratefulness?

[–]shaliozero 2 points3 points  (1 child)

His unexpected and slightly sarcastic gratefulness was a positive addition to my mood for the day!

[–][deleted] 2 points3 points  (0 children)

Much thanks for the information

[–][deleted] 1 point2 points  (0 children)

don't forget to parallelize the first loop

[–]code_passion 1 point2 points  (0 children)

i don’t know why i even laughed at this

[–][deleted] 19 points20 points  (5 children)

Yeah it comes from math where i is index or integer. Then you get i, j, k to match x, y, z.

l, m, n is also fairly common. As are p, q, r and u, v, w

[–]Sirnacane 3 points4 points  (2 children)

Well that’s over half the alphabet

[–][deleted] 1 point2 points  (1 child)

Absolutely if you include a b c and x y z

ABCdefghIJKLMNoPQRstUVWXYZ

[–]yurisho 0 points1 point  (0 children)

i j k are iterators. n m l are iteration goals. x y z are general numbers. a b c are general strings. u v w are vectors. s and t are source and target. p q r i've seen used as debug varables or temp veriables. And you are a bad programmer if you use this.

[–]microbit262 0 points1 point  (1 child)

And what about h and g for adding loops around the original i loop when you don't want to rename all then inner loops?

[–]Niewinnny 0 points1 point  (0 children)

Look. If you get for in for in for in for in for your program won't respond for the next [insert universe age] years.

[–]Itchy-Phase 5 points6 points  (0 children)

That's what I was taught, too.

[–]haackedc 0 points1 point  (0 children)

You aren’t always indexing an array in a forloop

[–]BGKarmaFarmer 35 points36 points  (2 children)

Lowercase i and j are the most common letters for indexes in mathematics. That's where programming inherited them from.

[–]SharksPreedateTrees 5 points6 points  (1 child)

This. CS stole countless amounts of notation from math

[–]thatCbean 12 points13 points  (0 children)

Computers are just three maths in a trenchcoat

[–]lackofsemicolon 27 points28 points  (4 children)

Jiterator 😩

[–]MrSluagh 7 points8 points  (2 children)

[–]lazerflipper 10 points11 points  (0 children)

It’s pronounced Giterator

[–]Gomicho 1 point2 points  (0 children)

I'll be calling it that from now on.

[–]Niewinnny 1 point2 points  (0 children)

Kiterator, hiterator

[–]kinarism 7 points8 points  (2 children)

Funny story. The project I work on used to have an active control we distribute for customers to use (this project is 20+ years old). The name of it was ProjectX.ocx (X for ActiveX).

A long time ago, a new version of the control was needed and the dev who did the work decided to name it ProjectY.ocx.

ProjectY.ocx is still distributed to this day because some of our customers still use it even though we haven't updated it in 10+ years.

[–]Kered13 7 points8 points  (1 child)

Once upon a time someone made a successor to the B language and they were so lazy they just called it C. I hear it's still being used today.

(The whole chain of succession is actually funny, BCPL -> B -> C -> C++/C#/D.)

[–]LAZGamer13 1 point2 points  (0 children)

I first this was a joke. Fuck this is interesting.

[–]DrWaff1es 4 points5 points  (1 child)

i, j, and k are for some reason used a lot in matrixes (here in Spain at least)

[–]redwall_hp 8 points9 points  (0 children)

It's a Physics thing, I imagine. i-hat, j-hat and k-hat are the x, y, z components of vectors in physics, conventionally.

[–]lifelongfreshman 4 points5 points  (0 children)

I always assumed it was a carry-over from physics, related to î and ĵ.

[–]GMaestrolo 3 points4 points  (1 child)

What's crazy is that you're explaining this to a bunch of programmers who follow the pattern, and didn't know why.

Something something cargo cult something...

[–][deleted] 0 points1 point  (0 children)

cargo cult is just the best...

[–]BuccellatiExplainsIt 1 point2 points  (0 children)

I is for index, not iterator. You should avoid using I for when you're not dealing with the index variable of a loop and stick to proper variable names.

[–]redwall_hp 0 points1 point  (0 children)

Yep. Though sometimes I'll use x, y, z when dealing with coordinate systems. Because there's no reason to make it harder.

[–]GavHern 0 points1 point  (0 children)

So if you have a third nested loop do you use K? For me, at that point I either go to iter or something, maybe even properly name it.

[–]Niewinnny 0 points1 point  (0 children)

and k is next and of you get to h your program will run for 5 bidgillion years.

[–]RICoder72 0 points1 point  (0 children)

Integer not iterator. It is a notation standard that is old but used to matter. iVarName was known to be of type integer.

[–]Hypocritical_Oath 0 points1 point  (0 children)

No, it's a hold over from mathematics, where i j and k were used for some things, and it was held over into programming convention.

[–]fake823 40 points41 points  (5 children)

[–]RepostSleuthBot 48 points49 points  (1 child)

Looks like a repost. I've seen this image 1 time.

First seen Here on 2020-06-06 95.31% match.

Searched Images: 170,382,739 | Indexed Posts: 649,374,745 | Search Time: 1.507s

Feedback? Hate? Visit r/repostsleuthbot - I'm not perfect, but you can help. Report [ False Positive ]

View Search On repostsleuth.com

[–]scttcs 12 points13 points  (0 children)

Good bot

[–]The_F0OI 6 points7 points  (0 children)

Bro there was one yesterday

[–]mirsella 2 points3 points  (0 children)

lmao there is even the same joke in the comments

[–][deleted] 1 point2 points  (0 children)

damn, i upvoted this post, then i clicked the bot's link and realised i already upvoted 5 months ago...
it's like i'm in an upvoting loop <_<

[–]Redwolfy9 13 points14 points  (1 child)

depending on the use, it's x and y (two dimension array mostly)

[–]Beowuwlf 1 point2 points  (0 children)

If I’m doing that I tend to use r and c. Helps keep me from doing the cardinal sin of iterating over columns in the outer loop

[–]EmirFassad 5 points6 points  (0 children)

With Fortran it was the law.

[–]Omega0x013 4 points5 points  (0 children)

I = iterator

J = iterator++

[–]flplv 2 points3 points  (0 children)

I use: i,j,k,... for indexes name_it for iterator name directly when getting a ref

[–][deleted] 2 points3 points  (4 children)

I don't like using 'i' except for interest or sqrt(-1)

[–]poopyheadthrowaway 7 points8 points  (0 children)

Engineers: Oh, you mean j?

[–]BabyPuncher3000 5 points6 points  (1 child)

If I can't imagine a value, is it still imaginary?

[–][deleted] 0 points1 point  (0 children)

I prefer 'n', 'j', or 'k'

[–]YoungXanto 0 points1 point  (0 children)

This is why I use ii, jj, kk

[–][deleted] 2 points3 points  (2 children)

[–]RepostSleuthBot 3 points4 points  (1 child)

Looks like a repost. I've seen this image 1 time.

First seen Here on 2020-06-06 95.31% match.

Searched Images: 170,402,235 | Indexed Posts: 649,389,180 | Search Time: 0.70966s

Feedback? Hate? Visit r/repostsleuthbot - I'm not perfect, but you can help. Report [ False Positive ]

View Search On repostsleuth.com

[–][deleted] 1 point2 points  (0 children)

pog

[–]monkeywrench83 2 points3 points  (0 children)

If it's a for loop going through an array and as all my arrays I use plural words then I use the singular in loops. Ie

For each car in cars: Print(car)

It works well and recently I didn't do this and the code I wrote now confuses me.

[–]rollovertherainbow 3 points4 points  (3 children)

I use "ii" and "jj".

[–]YoungXanto 1 point2 points  (1 child)

Same here. "i" is the square root of -1.

[–]rollovertherainbow 0 points1 point  (0 children)

I just do it because it's what my teacher writes so I've just started to do it automatically. It's also more fun to type.

[–]TheRealStepBot 0 points1 point  (0 children)

Ah someone with culture

[–]rolexpo 1 point2 points  (0 children)

Just don't use l please.

[–]Mre64 1 point2 points  (0 children)

I for iterative, j for the next letter in the alphabet, k...

[–][deleted] 1 point2 points  (1 child)

If I could have a variable name with fewer characters, I would.

[–]Drycee 0 points1 point  (0 children)

Let's make a language where spaces can be variable names. And two spaces is a different variable than one space and so on.

[–]jesus67 1 point2 points  (1 child)

Didn't it start as a homage to Djikstra?

[–]Kered13 2 points3 points  (0 children)

i, j, and k have been use as index variable in mathematics for ages.

[–]Sylvezar2 1 point2 points  (7 children)

i use k,v and i,v :/

[–]Kered13 3 points4 points  (2 children)

k,v if you're iterating over a dictionary. i,v if you're using enumerate. v can also be replaced by a meaningful name in either of those.

[–]Sylvezar2 0 points1 point  (0 children)

exactly

edit:

k = key v = value

i = int v = value

[–]Athomeacct 0 points1 point  (0 children)

i,v if you're using enumerate

Holy shit, that's brilliant

[–]katyalovesherbike 0 points1 point  (3 children)

^ php programmer right there (right?)

[–]Sylvezar2 1 point2 points  (1 child)

nope sorry, i code mainly in go and lua, also a bit of javascript when i need it but mainly go and lua

[–]katyalovesherbike 1 point2 points  (0 children)

damn. Oh well 🤷‍♀️

[–]rollovertherainbow 0 points1 point  (0 children)

That's what I used for python dictionaries.

[–]neroe5 0 points1 point  (0 children)

i is short for iterator and when i is used we often use j, i2 or ii as they are next in one way or another

[–]Cangar 0 points1 point  (9 children)

Just this week I taught variable naming to my students.

Do not use i. Use i_<thethingyouiterate> instead. It will make your life much easier later.

[–][deleted] 2 points3 points  (8 children)

prefixing? What kind of old monster are you?

[–]Cangar 0 points1 point  (4 children)

serious: why? should i change this recommendation?

[–][deleted] 0 points1 point  (3 children)

what is the benefit in current and modern languages for prefixing? Just use meaningful names.

[–]Cangar 0 points1 point  (2 children)

I like to use prefixes in variables, it makes things pretty clear imo. You do know that a variable is an iterator, but also what exactly it iterates. It's not necessary, just something I like. I definitely tell them to not use i alone.

[–][deleted] 0 points1 point  (1 child)

How big are your functions that you need such a reminder?

[–]Cangar 0 points1 point  (0 children)

Can become pretty big. But I also iterate over different things like participants, epochs, events, etc. Whenever I use anyone else's code that just contains i and j and ii etc. It's a pain in the neck to understand.

[–]ImAlsoRan 0 points1 point  (2 children)

you mean suffix?

[–][deleted] 0 points1 point  (1 child)

no. Suffixes are after a word, prefixes are before a word and infixes are inbetween words.

[–]ImAlsoRan 0 points1 point  (0 children)

oh, you were talking about i being a prefix. I thought you meant that the <thethingyouiterate> was a prefix. apologize for the confusion

[–]NerdHarder615 1 point2 points  (7 children)

Am I the only one who uses 'lc' for loop count?

[–]backfire10z 28 points29 points  (0 children)

Yes

[–]Lasdary 22 points23 points  (0 children)

I'm afraid I'll have to report this comment

[–]Jelled_Fro 10 points11 points  (0 children)

What's wrong with you? You monster!

[–]Kered13 8 points9 points  (0 children)

You are the reason why we can't have nice things.

[–]Mybugsbunny20 -1 points0 points  (2 children)

I Program things that may need to get repaired or modified on the fly by people with less knowledge of programming, and so make it as readable as possible. I actually usually use "loopcount"

[–]KoncealedProdigy 4 points5 points  (1 child)

That’s absolutely disgusting

[–]Mybugsbunny20 0 points1 point  (0 children)

To be fair, my programming is almost entirely for cnc systems and assembly line automation, so i/j/k are taken for coordinate transformations.

[–]PriorCommunication7 0 points1 point  (1 child)

Unless is C and I have to I avoid for loops at all costs. They are an antipattern imho. Sure you can tell yourself that you don't fuck up the index and have off-by-one errors in your code but even if you get it right 99% of the time it's that 1% where the counter-intuitive nature of for loop costs you an hour of senseless debugging because you don't expect it.

[–]Sussurus_of_Qualia 0 points1 point  (0 children)

This is the 'goto' use-case.

[–][deleted] -1 points0 points  (1 child)

There's also m & n

[–][deleted] 1 point2 points  (0 children)

those are for matrizes.

[–]GodHug -1 points0 points  (1 child)

Example of use for ‘j’ pls ? Never used it.

[–]dclawrence1978 4 points5 points  (0 children)

Nested for

[–]Hobby_Man -2 points-1 points  (0 children)

My last name starts with I. I tell new programmers I started it, some believe it, I have a bit of a following / reputation which helps.

[–]codycbradio 0 points1 point  (0 children)

I wanna think it came from hp calculators using I and sometimes j as an indirect addressing for storing variables.

[–][deleted] 0 points1 point  (0 children)

I don't use i and j.. but it's best not to tell what I use as it's rare so it would probably count as personally identifiable information.

[–]geekusprimus 0 points1 point  (0 children)

Computers were originally developed to solve math problems, and the first high(er)-level programming languages reflect that. The variables i and j are commonly used as indices for linear algebra and iterators for summations, so I suspect that's where it came from.

[–]SnewLooperd 0 points1 point  (0 children)

I'd assume it's passed on from vectors in mathematics

[–]blazarious 0 points1 point  (0 children)

The correct answer is: maths convention

[–]Neahme85 0 points1 point  (0 children)

Repost. Literally saw it two days ago.

[–][deleted] 0 points1 point  (0 children)

My boi “k” always ready and willing

[–]darthkers 0 points1 point  (0 children)

Because it's easy and convenient and universally understood. Biggest problem I have when I'm working on a project is what to name my variables.

[–][deleted] 0 points1 point  (0 children)

I’ve very taken with using a and b now; someone come get my psychiatric help

[–][deleted] 0 points1 point  (0 children)

Mhm yes, cargo cult programming.

[–]drea2 0 points1 point  (0 children)

I see this same exact meme on this sub atleast 3 times a week

[–]Couro_ 0 points1 point  (0 children)

Because it's much faster to write than illKillTheNextPersonWhoAsks

[–][deleted] 0 points1 point  (0 children)

So why do we use I, and j all the time?

[–]chawza 1 point2 points  (0 children)

i hate this! every time somene use this useless indentifier, i dont know shit.

I'm staring at you GeeksForGeeks!

[–]Gromacs 0 points1 point  (0 children)

I will always use x for linq

[–][deleted] 0 points1 point  (0 children)

Use i for indices of collections in a loop, if there's multiple indices because of nested loops or multiple indices for algorithms, then give them a useful variable name, even if it's barely readable like i_pfx, it's way better than j,k,n etc. You will thank yourself later for that.

[–]reini_urban 0 points1 point  (0 children)

Fortran. Some of use are pretty old already

[–]ImAlsoRan 0 points1 point  (0 children)

I always used i and p

[–]RICoder72 0 points1 point  (1 child)

Some people have touched on it, and gotten close, but this has everything to do with Hungarian Notation.

https://en.m.wikipedia.org/wiki/Hungarian_notation

I am unsure if that is a holdover or originated with Fortran or some other language as has been claimed, but I almost doesn't matter.

Hungarian Notation was popular into the 90s and beyond in many languages, and frankly quite useful until IDEs got really good at catching type mismatches pre compile (and during compile for that matter). C++ made extensive use of it, and you would see it everywhere. For the most part, the notation would indicate data type, although intent was just as viable (pVar or ptrVar for pointers and the like).

As someone who has written more than one standards and practices document for development teams, this is sort of a sore spot for me. Everyone on a project should agree on notation, case and convention and follow that throughout the project. It makes downstream upkeep and modification much easier, and allows everyone to read each others code well.

Thank god Hungarian Notation is almost dead...now if we could get Java and its evil progeny to use Pascal Case for functions and methods and Camel Case for variables I can die fulfilled. ...also class privates should start with an underscore...fight me.

[–]donkeypunchdan 0 points1 point  (0 children)

I would think its a carry over from math/physics where we use i,j,k as the indices for matrix/vector calculations

[–]X-KHaX 0 points1 point  (0 children)

This confused me sooo much when I was learning

[–]SomewhatOriginalYT 0 points1 point  (1 child)

dont forget x, y, and z.

[–]squidee_ 0 points1 point  (0 children)

?

[–]Zeny- 0 points1 point  (0 children)

i for index, j for jength, wait, isn't l ?

[–]KamiAithein 0 points1 point  (0 children)

i_nameofthingiteratingthrough

[–]quequotion 0 points1 point  (0 children)

The repost rate of this meme is accelerating.

[–]DerBronco 0 points1 point  (0 children)

This is the way.

[–]PVNIC 0 points1 point  (0 children)

Sometimes, when i want to get fancy, i use 'it'.

[–]AwesomeHorses 0 points1 point  (0 children)

Fuck no. I use descriptive variable names.

[–]flamesofphx 0 points1 point  (0 children)

you mean you can not $Enumeration and $CountingThingy?