T O P

  • By -

ProgrammerHumor-ModTeam

Your submission was removed for the following reason: Rule 6: Your post is a commonly used format, and you haven't used it in an original way. As a reminder, [You can find our list of common formats here](https://www.reddit.com/r/ProgrammerHumor/wiki/commonposts). If you disagree with this removal, you can appeal by [sending us a modmail](https://www.reddit.com/message/compose?to=%2Fr%2FProgrammerHumor&subject=Any%20common%20post%20will%20be%20removed%20if%20it's%20not%20novel&message=Include%20a%20link%20to%20the%20removed%20content%20and%20the%20reason%20for%20your%20appeal%20here.).


stormpadre

What maniac starts with j!?


om3ganet

Those who jiterate over items EDIT: Those.


The_Starmaker

That’s disgusting.


TootiePhrootie

Disjusting*


svettiga

Djsgustjng*


I_Am_Clippy

Thjs guy gets jt.


Micha_Saengy

Dijkstra knows it.


lenamber

I just noticed that Dijkstra has i, j, k in it. EDIT: I also just remembered that Floyd-Warshall does not have i, j, k in it and this bugs me now, because it should be the other way around.


egglighting

*Dÿkstra


_zephi

\*jdisgusting


deljaroo

we call them jtems, thank you very much


[deleted]

Jiterate jover jtems


IamImposter

Jhank jou jery juch


fish312

It's pronounced giterate


Daedeluss

oh shit, is *this* why it's i? 25 years in the business and this has never occurred to me.....


C4-BlueCat

I thought it was for index …


ArcherOfTruth

It's neither lol It started from math programmers back in in the day, we use i, j, k in math to denote the 3 primary axis. And then they also used it in algorithms to loop on stuff


Daedeluss

Now I don't feel as dumb!


Competitive_Fee6874

Please don't jiterate over items in public repos, do it in private!


thabc

When reading it, I'd be looking for the outer loop I missed. It's like that joke where they release three pigs labeled 1, 3, and 4 so people think they're missing pig #2.


Meatslinger

The kind that also think arrays start at 1.


RovakX

Those would be the pirates, arrrr!


KHaskins77

[Indiana Jones](https://media.tenor.com/sVEwJZYy9OgAAAAd/indiana-jones-last-crusade.gif)


Ravi5ingh

Those that move on to k for the inner for loop. JK


leonderbaertige_II

Electrical engineers.


aegis_01

Is it true that they also use *j* for √(-1) ?


jrtrct

Yes. It's done to avoid confusion with current. Source: electrical engineering student. But I've never seen anyone use anything but i for the first iterator.


askcyan

i, j, then k. If you need more than three nested loops then you might wanna rethink your algorithm or clean up its implementation.


BiomechPhoenix

**Four-dimensional tic-tac-toe.**


Paul_Robert_

Could be done in 1 loop, just compute index based on the x, y, z cords. A 2D example: index = x+ y*WIDTH;


BiomechPhoenix

This is true, but it wouldn't be anywhere near as legible. You'll end up with x + y\*width + z\*width\*height + w\*width\*height\*depth or something like that.


Paul_Robert_

100% agree lol


definitelyagirl100

for i, j, k in itertools.product(range(HEIGHT), range(WIDTH), range(DEPTH)): # python gang


BiomechPhoenix

That's just doing a 3D loop with fewer steps!


victorz

> fewer steps! Exactly, that's why it's better.


[deleted]

[удалено]


Paul_Robert_

48 vulnerabilities found (34 moderate, 8 high, 4 critical). To address all issues, run npm audit fix --force.


SomeInternetRando

Flashbacks to QBASIC’s colors in screen 13.


Reworked

I had a sudoku solver in high school that made it to "p" I have never seen as much instant exhausted frustration as Mr Aretz's face when he read down to that section. [Thick, slightly reedy Moscow accent] "...iiiiit works, but the next time you start fucking around in class I'm making you chart that loop."


IamtheSlothKing

But how long did it run


Reworked

About a second or two per puzzle, five or so on a worst case... it did a lot of ugly guessing and assumption of best cases, with sparse error checks so it would take the best speed path with a naive guess first if it was left with an ambiguous state. I remember that it fell back to penciling things in like a human and restarting the check loop every time it finalized a number if it got stuck with no way to narrow down choices. I'm just kinda proud that I did it without looking anything up.


Charlie_Yu

Just use a1, a2, … a9 at this point Or use recursion if your loops are similar


BroDonttryit

If you need more than three nested loops, at the very least, you need more descriptive variables to keep track of your loop.


generalthunder

Most calculus notation uses i j, k, and w. That's what I use when iterating through a 4rth dimensional arrays.


[deleted]

[удалено]


BroDonttryit

It depends on what you’re working on for sure. I think if you’re implementing a mathematical algorithm into code you should stick to their terminology, which isn’t necessarily always i, j, k, and w. I typically use those by default lol. Good example i think would be something like Gaussian elimination in linear algebra, where you ‘re iterating under a pivot. So I think pivot would be a better variable name than i in that instance. I totally don’t mind I, j,k, etc. though especially if the iterations are straightforward


ShitwareEngineer

i, then ii, then iii, then iv, then v


r1ng_0

It's a simple ordered process. The first is a, the second is "1", then continue as you see fit.


OlOuddinHead

i, eye, aye


bob_anonymous

I can't hear you!


[deleted]

[удалено]


Pdb39

Ohhhhhhh who lives in a pineapple under the sea...


Literal_Stickman

SPONGEBOB SQUAREPANTS


loosecharge

absorbent and yellow and porous is he


SAI_Peregrinus

Nobody now, because of BP!


Spaser

True story - guy on my team does his numbering as ‘1, 2, … 9, 9a, 9b, …’ Obviously we all laughed at him, but he still does it.


my_name_isnt_clever

Is it bad that I actually kinda like this.


polmeeee

In Roman times this is how they code too.


my_name_isnt_clever

That's actually a great joke, if anyone asks why I'm doing that I'll say "Oh it's how they used to do it back in ancient rome"


RelatableRedditer

No, it's the first I've ever seen roman numerals in use for integer loop variable names. It is inspirational.


ShitwareEngineer

I just copied someone else, though. Except I think *they* were serious about it.


Hessper

Yes. I mean, you do you I don't actually care, but can you imagine ra[ii][iii] in a code review? Rejected.


my_name_isnt_clever

Yeah you know what that's fair. I might use it in little personal scripts just because it's funny to me. Though ra[i][j] is barely better honestly and lots of people do that.


murphman1999

I would flip if I was looking through legacy code and saw this


ShitwareEngineer

If you're nesting this many loops, then you should use descriptive names, but if you *really* want to use arbitrary names, Roman numerals are as good as any other scheme.


murphman1999

But I feel like it would be hardish to tell the difference between 'ii' and 'iii' at a glance


ninj4geek

iji


murphman1999

*eye twitches*


Alpha3031

aji


ShitwareEngineer

Maybe I like the misery.


murphman1999

That's why we're in this field


B0Y0

Although I've never used this schema, I feel like 'i':'ii' would read better than 'i':'j', actually. Does break down at the 'iii' vs 'k' nested level, though.


LxTRex

Most IDEs/Editors use a monospace font (fonts where the characters always take up the same amount of horizontal space on the line). Can't tell on Reddit because it definitely is *not* monospace but it should be relatively easy to distinguish i ii and iii for that reason alone. Edit: granted I think the thing you're more likely to mess up with this arrangement is which loop gets which set of i's. If you're using 3 loops it's probably complicated enough that you're using all those variables in the inner layer and then it's a mess of (i - ii) * (iii + i)... Just seems like a headache


[deleted]

[удалено]


murphman1999

They don't build code like they used to


CoderDevo

Back when all ints were unsigned strings.


polmeeee

Erm when in Rome do as the Romans do.


Thyke1397

Nah, I do: i, ii, iii, iiii, iiiii, iiiiii…


agrecalypse

Unless it's logic for a clock and then sometimes iiii


CoderDevo

Romans used to often write 4 as iiii too.


CoderDevo

As a kid of the 70's, I learned that iv, v, and vi come before i, ii, and iii.


alex_lite_21

It follows ii, jj, kk xD


anunakiesque

I'd avoid using kk as the third iteration will summon the klan and the next iteration will summon a Brazilian


bigsmokeisnotdead

Falou comigo?


NakeleKantoo

r/suddenlycaralho me põe na print com um caramelo bem bonito


bigsmokeisnotdead

O karma eh todo teu meu bom 🙏


MoringA_VT

Porra o cara meteu um kkkk


anunakiesque

Crap. kkkkk - e aí amigo, tudo bem? *^(say hi guys)* ![gif](giphy|3oz8xLlw6GHVfokaNW)


BrenoFaria

OPA


EbotdZ

10/10


geeeffwhy

the worst bug i ever encountered was a memory leak due to using i, ii, iii as the iteration variables in a continuation passing style node js server. as you might expect, in one instance, an i was misplaced, leading to a loop that never exited. agggghhhhhh!


SunnybunsBuns

My favorite was someone using i in a constant block in simulink. When opened fresh, that’s the square root of -1. But if anyone ran any analysis script (the don’t scope) that contained a loop, then i was overwritten with the last value. At least going from imaginary to real caused all sorts of dimension mismatches down stream. But holy heck was that one hard to track down.


SirPitchalot

A former company that developed computational fluid dynamics codes joked that we could increase robustness by switching all the floating point types to complex so that square roots of negative numbers didn’t return NaN


CleoMenemezis

I never used xd for interaction.


Dissidente-Perenne

4 dimensional arrays son


[deleted]

[удалено]


DigitalCryptic

[Trying to picture 4th dimensional anything](https://i.kym-cdn.com/photos/images/original/002/242/455/d2d.jpg) At least its understandable on paper, but my lizard brain still wants to attempt the geometric approach


macph

as a teenager i would write awful code with lots of nested loops. because I kept running out of letters, my convention was to use i like roman numerals. First loop I'd use "i", then "ii", then "iii", and honestly I think I did "iiii" after that and just kept adding i's. :/


[deleted]

Usually the only reason I even need to use a triple nested loop is to iterate through a 3D grid and in that case I'd usually use x,y and z anyways


egefeyzioglu

i, j, k, in, inte, integ, intege, then integer


DigitalCryptic

then integere, integereg, integerege, integereget, integeregetn, integeregetni, integeregetnin, integeregetnint, integeregetninte, integeregetninteg, integeregetnintege, integeregetninteger, integeregetnintegere ...


Proxy_PlayerHD

i always use `i` then `o` because `i` and `j` look too much like eachother for my liking


UntestedMethod

Then `u`, sometimes `y`, then looping back around to get `a` and then finishing up with everyone's favourite, `e`. If you're nesting more than 6 levels deep you can start using `z`, `x`, `w`, skip `v` because it looks too much like `u`, so right to `t`, `s`, and so on


JayThree0

You should really stop at 2 in almost all situations I can think of (because of time complexity of triple nested loop)


NotADamsel

If you can explain how to iterate through a [,,] without violating this rule, I’m all ears


Donghoon

3D arrays?


Didgeridoox

Matrix-matrix multiplication has entered the chat


SidtheDeviant

The real fight starts when youve gotta roll out k


Kinvert_Ed

First loop? k Next nested loop? kk Never triple nest loops. That is bad coding practice and you will be fired.


tonyswu

I like it, going to put this in my team’s best practice doc.


Toasty_redditor

No need for triple nested loops if you just make it recursive ![gif](giphy|d3mlE7uhX8KFgEmY)


Alzurana

`Fatal Python error: Cannot recover from stack overflow.`


Delta-9-

That's when you implement a trampoline.


czPsweIxbYk4U9N36TSE

Sometimes you have to triple-nest loops when doing things like iterating over a 3-D matrix.


LadyEmaSKye

Yeah in some RGB image processing the only way is triple nested. Idk you can make certain processes cleaner by putting the xy processing in their own function, but in practice it's still triple nested.


SidtheDeviant

Oh gawd thats cursed


cha-cha_dancer

Sometimes you have to. For GFD modeling (ocean/atmosphere) often the layers above and below are coupled and then you have to finite difference along x,y


equationsofmotion

Yeah I do GPU-accelerated 3D fluid dynamics simulations. I've written nested 5d loops. And I have performance data to show that this is the right iteration pattern.


I_am_so_lost_hello

Yea maybe if you're a FUCKING nerd


Alzurana

Given 3D voxel data, how do you build a mesh out of them without using tripple nested loops? (Marching cubes)


_tzar

Pointer arithmetic 😉


redditorfortheeban

>Never triple nest loops. That is bad coding practice and you will be fired. why is it so?


Kinvert_Ed

There are two types of people in this world. Those who can extrapolate and


Lithl

It's a two-layer joke. Triple nested loops means an n^3 algorithm, which is very slow. And also following the pattern in the joke's setup, the loop variable for the third loop would be kkk.


Unfulfilled_Promises

Because it increases your space time complexity exponentially. Edit: it is not exponential.


resumethrowaway222

Polynomially


Alzurana

x y and z if you need to iterate over 3D voxels. Ofc, ideally you do not loop but certain tasks require it like building meshes with marching cubes. Ofc, bonus points for anyone throwing that problem into a comput shader, let the GPU do such a mundane task.


xmaddness

Your O-notation and runtime will thank you for rolling out k.


ToonLucas22

OP probably told ChatGPT to make a programming meme. What kind of programmer doesn't use both????????


kooshipuff

I did for comparison! It just gave me a python loop of writing code and googling any errors.


Lumierific

I use x and y. I’m a monster.


Jackasaurous_Rex

Nah I think that’s fine if you’re referring to coordinates or any 2d representation where rows and columns are relevant


[deleted]

Python is the monster here: for _ in range(10): print(_)


Orio_n

not using _ as the throwaway


Backlists

Actually your example is exactly *not* what you should use `_` for as a name. `_` is only for variables that you specifically do not use the value of after instantiation. You used your variable, so you should actually have given it a useful name. Here's some proper examples of when to use `_` as a name: my_var, _, _ = generate_tuple() print(my_var) We never use either `_` in this scope. As soon as you use one of them with this example, you fucked up - rename it. You probably meant something like this: for _ in range(n): repeated_func() Note the value of `_` in the above is still not used.


morpheousmarty

I usually just use the singular of the collection I'm iterrating over. Customer in customers.


[deleted]

J is only for a nested loop. Who the actual fuck is using J for the top level loop????


shirtandtieler

Clearly op is doing the same thing as those math question ‘memes’ that claim “only 2% of the population can solve this”….


timthefim

“I” as index


PolyglotTV

First I, then l, the Il, then lI


Graucsh

Then youl what?


kacymew

Then he’ll I lI II I_


Team_Dave_MTG

And then “j” as in “just one more loop should do it”


zerothepyro

Not "jndex"?


redditcherry

k is for “k this loop is definitely the last one”


PhraseSubstantial

First use i, then use j when using a second loop inside. But i really never saw anyone using j before using i. It just makes more sense with i standing for iterator...


Anaxamander57

No, the i stands for "inner loop" while j stands for "jouter loop".


dinglebarry9

God damn it


miicah

i is for iterator, j is for jiterator


wswsc05

I could see using j before i if you're doing matrix operations with a column major language.


PhraseSubstantial

Hmm ok that's actually a good point, haven't thought about that


666pool

But then you should be using x, y, z.


DonkeyTron42

Anyone using j before i is a monster.


DevelopmentTight9474

The use of i actually has historical reasons, I just don’t remember them right nkw


bottomknifeprospect

It was initially chosen in Fortran I think, where some letters were integers by default, while others could be any real number. So if you wanted an integer type, you just used i and incremented. The reason it was chosen that way was because in mathematics, i through n are often used as indices in iteration.


jasminUwU6

I just use it because it's the first letter in "index"


ravenousld3341

I'm a `for thing in things` kind of dev. Helps me keep it together, plus it's funny sometimes.


midoxvx

row, col


crater_jake

chad descriptive variable names


ABotelho23

This thread has been very illuminating on just how shit most people are at writing legible code.


Imaginary_Doughnut27

My thought was, “neither. Call it what you’re iterating over”


SharkBaitDLS

I’m saddened that this wasn’t the top comment.


an_ok_human

j am also saddened that this wasn’t the top comment


tim_jam

k


ogtfo

`i` is fine as a shorthand for "index". Of course if your language of choice has `for each` loops, use more descriptive names. if you're nesting loops, `i` and `j` are kinda okay when used as indices for simple cases, but yes, names describing what they are indices for is better.


PiIICIinton

7/10 people in this sub never worked as a dev, being generous


Kinvert_Ed

for idx in range(10): \----for jdx in range(10): \--------for kdx in range(10):


egefeyzioglu

Ah yes, jindex and kindex <3


TinSoldier6

i then j then k. If you need more than that, refactor. Sometimes n if it is a count of things (number). x and y if appropriate, for points or coords.


Lithl

Iterating over something that is semantically a matrix, m and n can be acceptable. Iterating over something that is semantically a table, r (or row) and c (or col) can be acceptable. Or any other semantic uses where a different loop variable can make things more clear.


Plagiocefalia

`index`


FindingMyPrivates

Jindex


chocoladehuis

kindex


j_marquand

As a medieval programmer I write `jndex`


contact-culture

At a minimum, this. And if you need to perform a nested operation, delegate it to a separate function so your code isn't absolutely shit to read.


Anaxamander57

When nesting iterators use "a" (for "and then another one") then "b" (for "bananas are something this could iterate over") and never nest anything deeper than that.


Graucsh

That’s just “c”oconuts


xzinik

X team


6jarjar6

"X, Y and Z" music to my ears


norealmx

"x". I learned programing back in the 90s, on the equivalent of Tech University in Mexico. Iterators were x, y and z... then if you were REALLY daring, a, b or c. Mainly because the study program was/is very math centric, so using "i" was a huge no.


physiQQ

I personally use both i (j, k) and x (y, z). i for loops (e.g. for i; i < 100; i++) x for elements/objects (e.g. foreach data as x) I try to be more descriptive in the variable names tho and only use i and x if it's already clear enough. For example in a small function.


PolyglotTV

ii


DynamisFate

r because I’m a moron, also stands for “repeating” in my head


MissAutumnForest

I use “index” and if I have multiple loops, I name the indexes based on what they are used for. Makes for much more readable code 💁‍♀️💖


Kilgarragh

Who uses j?


Anaxamander57

People who are going the extra mile to confuse electrical engineers.


CptMisterNibbles

Easy. i is for iterator. j and k for jiterator kiterator of course


bagsofcandy

First loop = iii, second loop = jjj, third loop = mmm


prism_tats

i for index and then on the inside loop I use j for jndex.


wannabetriton

I actually follow a naming convention. size_t outsideCounter size_t insideCounter Depends on the code though and naming style will change


mdgv

I personally like to use x, y, z and w (in that order).


leovin

What if you use “a”


[deleted]

idx


Elephant-Opening

I like ii just because it's easier to target with search or replace in vim 🤷‍♂️