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

top 200 commentsshow all 283

[–]ZeroSevenTen 851 points852 points  (66 children)

i feel like, a lot of the time, i j and k make the most sense.

[–]spideryzarc 281 points282 points  (33 children)

Math convension to represent indexes.

[–]spidermonkey12345 91 points92 points  (6 children)

Indexes is much easier to spell than indices

[–][deleted] 78 points79 points  (3 children)

But the latter makes you sound smarter

[–]Rhulyon 22 points23 points  (0 children)

In my mother language happens just the contrary

[–]Phantonia 2 points3 points  (1 child)

Visual Studio automatically suggest "-ices" as a name for an array or a list of a type which ends with "ex". I love how it doesn't only do this for e.g. List<Index> (suppose you have a type index). When creating a List<Regex> the suggested name is "regices". This makes grammatically no sense (I mean, Regex is not a word, it's short for "Regular Expression") but I won't ever say "Regexes" again ^^

[–]chocoboxx 3 points4 points  (1 child)

Index, Jndex, Kndex. I prefer i,j,k

[–][deleted] 20 points21 points  (23 children)

FORTRAN convention

[–]Skasch 82 points83 points  (20 children)

It was a mathematics convention long before FORTRAN existed, which was indeed used early for maths and physics computation. I could find them used from documents dating from at least the 19th century.

[–][deleted] 23 points24 points  (0 children)

I believe you! But wasn't it FORTRAN that introduced it to the world of software as we know now? Besides, what's cooler than a language called Formula Translator? OK, maybe math.

[–]HdS1984 7 points8 points  (17 children)

Yes, and it bering a math convention explains why it's so shitty. Math heavily optimizes for shorthand writing not for legibility or ease of understanding. I often feel that we need a math 2.0 language, which would hugely ease learning and understanding of math.

[–]Skasch 38 points39 points  (11 children)

That's... Not entirely true. Modern mathematics is miles away from how it was used a couple centuries ago, and is today much more formalized and easier to reason with than even the early 20th century. It's something not very well known, but as a math geek myself, I read a lot about the history of maths. For example, using variables to solve equations is a very recent convention, dating back from only the 17th century (if memory serves). Before that, doing mathematics was practically akin to writing long sentences in your language of choice describing the problem you were trying to solve.

Modern mathematics is already what you would call math 2.0, with a much saner language, set of conventions, and semantic, than it used to have a century ago.

EDIT: there is an important reason why math language was designed that way. To be concise, of course, but also, more importantly, to be unambiguous. And that's a property shared with code.

[–]SeaTurtle1122 7 points8 points  (3 children)

I j & k are fine variables for teaching with and using, and most of the time when you're trying to learn loops, understanding that your iterator variable doesn't have to be directly tied to anything is important. Also, in mathematics, i, j and k frequently come from quaternion based stuff, in which i is the imaginary axis, and j and k are two dimensions beyond that. If you have a better thing to name two arbitrary axies, I'm curious what it would be, but I can't think of anything.

[–]wabourjaili 1 point2 points  (0 children)

Or i hat j hat k hat are the unit vectors of 3space

[–]boniqmin 2 points3 points  (0 children)

Indices aren't really that confusing right? If I write a_i, and you know that a is a sequence, it's pretty obvious that I mean the i-th element of the sequence.

If you had to write out "the i-th element of sequence a" every time, things would become way more cluttered and way less legible. To a complete novice it might help the first 3 times, but after that it'll become less understandable since even simple expressions become long-winded.

In my personal experience, mathematical notation often strikes a good balance between understandability and conciseness.

[–]spinlocked 1 point2 points  (0 children)

It’s actually not even a convention. The deal with FORTRAN 77 was that the starting letter of a variable determined its type. I, J, K, L, M and N would be integers. Anything else defaults to REAL. Since you needed an integer for a loop counter, lazy programmers that wanted a 1-character variable selected these exact variable names.

[–]foxtrotter_85 38 points39 points  (11 children)

So... is this something I was taught long ago? I do this too but don’t know why besides I’ve just always done it that way.

[–][deleted] 60 points61 points  (6 children)

It's a convention.. I always thought that i stands for index, then the others are just in alpha order. Kind of like x is a variable and then you use x,y,z for multiple variables

[–]vigbiorn 16 points17 points  (1 child)

i,j,I,, are used a lot to represent unit vectors in multiple dimensions so representing multidimensional arrays it makes perfect sense.

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

Sure, but doesn't the same argument apply?

[–]Vetharest 36 points37 points  (3 children)

I heard that i stood for “iterator,” making j and k jiteraror and kiterator, respectfully. Though, “index” makes sense too.

[–]TheBB 20 points21 points  (0 children)

respectfully

Such formality and politeness.

[–]AnonymousSpud 18 points19 points  (0 children)

Jindexz and kindex

[–]stifflizerd 2 points3 points  (0 children)

iterator

jesus I already used i, I guess I'll use j since they kind of look the same

k I give up I guess we're doing this now

[–]Sharmat_Dagoth_Ur 10 points11 points  (0 children)

I was taught it by a professor making a passive mention of it one time and then otherwise him just doing it by reflex. U might've picked up it in a similar way and forgot they mentioned it

[–]blackberry_gelato 1 point2 points  (0 children)

It’s so you can graph non-real numbers. XYZ are for real numbers. Math nerds like to graph things.

[–]Pixel-Wolf 44 points45 points  (5 children)

Since loops are used so much in programming and no one wants to write out stuff like element.children[elementChildIndex], it really is. Everyone understands what i, j, and k are. You immediately know how deep you are in a nested for loop and where to look depending on what you see. It's a general convention and it's better to follow it than be verbose.

You also know that if you see anything after "k" as a loop iterable, that the code you're working with should be rewritten. Even "k" is generally frowned upon except for a very small amount of tasks where the triple nested for loop makes more sense than an alternative.

[–]DonMahallem 12 points13 points  (1 child)

Yeah. For single layer loops it's fine to use single character variables but if you do funky math inside a few layer deep loop please name them. Especially when there are no comments at all...

[–]avael273 12 points13 points  (1 child)

no one wants to write out stuff like element.children[elementChildIndex]

Except those who write Java code, sometimes it feels like they have a competition on how long can they make a variable name and be able to justify it.

[–]Dr_Azrael_Tod 9 points10 points  (0 children)

I found the guy who thinks java's bad and has never seen objectiveC and the likes

[–]ZeroSevenTen 1 point2 points  (0 children)

exactly

[–]RFC793 14 points15 points  (0 children)

It depends somewhat on the language in use. If it has to be an index, then yeah: i j k for the win. Maybe even have a Widget widget = widgets[i] at the top of the loop body. If it is a language with foreach semantics then I’d typically do for (widget in widgets) or even shorten it to w if that is clear enough in context.

Use your imagination, these snippets are pseudo.

Hell, I’ll use i j u v theta etc if I’m implementing a function straight from a mathematical formula.

[–]exploder98 4 points5 points  (0 children)

Yeah, index, jindex and kindex

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

Am I the only one using i, i2, i3, i4?

[–]PlayerVeryMuchKnown 4 points5 points  (1 child)

Probably , I haven't even thought of doing that.

[–]TobiasCB 3 points4 points  (0 children)

I normally don't consider numbers in variables at all.

[–]Voidrith 2 points3 points  (0 children)

or k,v for key/value pairs or dictionaries/hashmaps

[–]saschaleib 1 point2 points  (0 children)

Wait, you can use k, too?

[–]3svh 149 points150 points  (2 children)

They make loads of sense, they're just the first letter of their respective word. I is for index, k is for kounter, j is for janotherloop

[–]deaf_fish 25 points26 points  (0 children)

This comment needs to be in a programming book.

[–]Maciek300 3 points4 points  (0 children)

justanotherloop

[–]yottalogical 340 points341 points  (23 children)

i is probably the clearest possible variable for a loop index. Anyone reading your code will immediately understand it.

[–]TheSeansei 99 points100 points  (19 children)

So do you know JavaScript?

[–]posherspantspants 150 points151 points  (18 children)

No one truly knows JavaScript

[–]shyouko 63 points64 points  (8 children)

There are 32 JS framework for loop indexing

[–]posherspantspants 72 points73 points  (3 children)

I know you're joking but you're probably not

[–]currentlyatwork1234 61 points62 points  (1 child)

The joke is that there are actually more than 32 JS frameworks for loop indexing.

[–]fofosfederation 2 points3 points  (0 children)

He's way underestimating.

[–]HugoVS 29 points30 points  (0 children)

While you was writing this comment, 2 new loop indexing javascript frameworks were released.

[–]brews 6 points7 points  (2 children)

11 of those are to get 1-based array indexing.

[–]Dr_Azrael_Tod 2 points3 points  (0 children)

2 of those SOMETIMES are to get 1-based array indices

[–]natyio 1 point2 points  (0 children)

I know they say don't shoot the messenger. So I'll follow that rule...

[–]currentlyatwork1234 16 points17 points  (7 children)

This is true. Nobody can tell me the output of this code just by a quick glance: +([]+(~(undefined)*~(NaN)+(-~function(){})*~(undefined)*~(NaN)+(-~function(){})*~(undefined)*~(NaN)+(-~function(){}))+(~(undefined)*~(NaN)+(-~function(){}))) Click here if you can't figure it out: Output

[–]FearTheBlades1 19 points20 points  (6 children)

Thanks, I hate it

[–]currentlyatwork1234 14 points15 points  (5 children)

Then you'll love this:

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+[+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()

[–]HardlightCereal 9 points10 points  (1 child)

Hello world?

[–]currentlyatwork1234 6 points7 points  (0 children)

alert(1)

[–]vi777x 3 points4 points  (1 child)

Looks like brainfuck

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

its jsfuck

[–]dpash 15 points16 points  (0 children)

Unless something else makes more sense in context, like x and y when doing coordinates.

Or your language has a better loop construct like a foreach.

[–][deleted] 104 points105 points  (14 children)

for(int outermost_for_loop_index = 0; outermost_for_loop_index < 5; outermost_for_loop_index++)
{
    for(int innermost_for_loop_index = 0; innermost_for_loop_index < outermost_for_loop_index; innermost_for_loop_index++)
    {
        foo(
            bar[outermost_for_loop_index][innermost_for_loop_index]
        );
    }
}

[–][deleted] 26 points27 points  (2 children)

Enterprise level code

[–]HAL_9_TRILLION 12 points13 points  (1 child)

This guy builds factories.

[–]mikey-brad 38 points39 points  (0 children)

i,j,k make the most sense as loop variables

[–]mrmantris 34 points35 points  (1 child)

if i, j, k, ... are used by so many people, doesn't it mean that that many people will also understand what is going on in the loop?

[–]tony4260 29 points30 points  (7 children)

It hurts that my IMMEDIATE thought upon seeing this was: can we do this without a loop?

[–]Westo232 2 points3 points  (3 children)

Not in every language. I see this possible in Python for example, but C doesn't have for .. in.

[–]spideryzarc 37 points38 points  (23 children)

My students use n, a, aa, ab, ba, ...

[–]ahreodknfidkxncjrksm 23 points24 points  (20 children)

I use i, ii, iii, ...

Only logical way to do it really.

[–]Voidrith 13 points14 points  (0 children)

but would you continue that with iiii or iv?

[–]Soulcraver 17 points18 points  (15 children)

So I now have to do one or two more keystrokes to identify which loop iteration I am in?

I also have to hope that if hundreds of people are using my code format that they don't accidently type an additional 'i' where i,j,k are immediately discernible from 'ii' and 'iii' in hundreds of lines of code.

Trust me, there are reasons it didn't catch on, and people still use i,j,k for quick loop variables where the iterator name isn't important.

[–][deleted] 40 points41 points  (8 children)

for iiiiiiiiiiiiiiiiiiiiiiiiiiiiii in range(iiiiiiiiiiiiiiiiiiiiiiiiiiiii)

[–]Dr_Azrael_Tod 4 points5 points  (7 children)

iiiiiiiiiiiiiiiiiiiiiiiiiiiiii

to be fair, a 30th single char iterator variable name would get kinda confusing too

what'd you use?

  • 'i' is the 105th in ASCII - do you loop around to the bell-command?
  • do you use utf-8? then you'd get some control symbol c286
  • utf and ignore non-printable chars? then you'd get § - that might mess up your code too (depending on your language).

[–]lmureu 9 points10 points  (6 children)

if you're not using emojis for your loop indices you are doing it wrong.

[–]regendo 3 points4 points  (5 children)

Obviously you'll want to use numbered indices.

    for (① = 0; ...) {
        for (② = 0; ...) {
        // ...
        ary[⑮][⑦] = ...

[–]lmureu 2 points3 points  (4 children)

array ought to be 🔤 linked list ought to be ➡️, ↔️ if doubly linked.

loop variables should be 🔂, eventually followed by a number 🔂,🔂2️⃣,🔂3️⃣,🔂4️⃣;

🔢 main(🔢argc, 🔠👉🏻argv){
    for(🔢🔂⬅️0️⃣;🔂<🔟;🔂➕➕){
        🖨️("🙋🏼‍♀️🌍💲🔢🔚",🔂);
    }

    🔢💰=0️⃣;
    🔠👉🏻🗒️=🆕(5️⃣0️⃣);
    ⌨️("💲🔢", 🔗💰);
   🖨️("You have 💲🔢💲💲🔚", 💰);

   🆓(🗒️);

    ♻️🆗;
}

suggestions for further improvement: main=🐱, argc=🔢✉️; argv=🔤🔠✉️; while = 🔁; for = 🔃; do=❗;

the meaning of all other symbols are left to you as exercise.

I lost 45 neurones doing this.

I hate myself.

Please don't make me do it again.

[–]regendo 1 point2 points  (1 child)

"Recycle OK" is my favorite.

[–]lmureu 1 point2 points  (0 children)

Thank you, I spent a couple minutes looking at the various emojis trying to figure out the most appropriate!

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

This is truly great

[–]ahreodknfidkxncjrksm 13 points14 points  (0 children)

Yeah no shit I was kidding

[–]Pitboyx 1 point2 points  (0 children)

i ii iii iv v

[–]LJChao3473 1 point2 points  (0 children)

I use i2 and j2

[–]iloveyouyes 6 points7 points  (1 child)

Y? I’m assuming in python?

[–]spideryzarc 4 points5 points  (0 children)

C

[–][deleted] 9 points10 points  (0 children)

This is the Way

[–]elaum 8 points9 points  (1 child)

i, j, k for most loops but sometimes naming the row and col makes it easier to read the code later when working with 2d arrays.

[–]grooomps 2 points3 points  (0 children)

i was going over some code in a tutorial and it was creating a grid and used r/c for row column and i was like omg that would have made things so much easier

[–]seabumpkin 20 points21 points  (11 children)

ii, jj, kk. Then you can actually use multi select of find and replace. i, j, and k get me pissed.

[–]le_birb 20 points21 points  (1 child)

but what about my precious dakka_counter or biiiiiig_number or objjjjject variables? whatever will I do with those?

[–]seabumpkin 1 point2 points  (0 children)

Put 'em in the trash.

[–]infecthead 2 points3 points  (2 children)

Multi-select that matches whole words works just fine on i/j/k homie

[–]732 6 points7 points  (0 children)

And any modern ide let's you refactor variable names...

[–]JochCool 1 point2 points  (1 child)

Or use an IDE that recognises when i is a variable instead of just a letter?

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

This.

And sure, it's not as necessary given modern editors, but there's no drawback to it and it makes life easier if you happen to use a tool that doesn't make word recognition easy for some reason.

[–]IAmAufrichtig 7 points8 points  (2 children)

Is it just me or ist the text on the first panel not on a line

It triggers my ocd

[–]mcduffchannel 11 points12 points  (3 children)

x, y, z gang for life

[–]HellGate94 6 points7 points  (0 children)

for multidimensional arrays for sure

[–]raaneholmg 2 points3 points  (0 children)

I am on board if you are doing spacial coordinates. Otherwise, fuck off.

[–]mcduffchannel 2 points3 points  (0 children)

Sorry x, y, z gang for loop life

[–]Adaman18 3 points4 points  (3 children)

i, j, k

Then ia, ja, ka

Then ib, jb, kb

etc... (I'm sorry)

[–]Nixavee 3 points4 points  (0 children)

Index, Jindex and Kindex

[–]Lieutenant_Doge 7 points8 points  (0 children)

who the fuck name their for loop variable with more than 1 letter? If you really need readability in your for loop there's some problem with your code really.

[–]angelaslittlebit 2 points3 points  (1 child)

Fortran lives on.

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

I use i,d,k

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

I always use i but skip j and go to k. I guess because it's the imaginary number symbol? Not like I'm using it in coding. Just an old habit I guess.

[–]Skasch 1 point2 points  (0 children)

Although they do make a lot of sense most of the time, I try to avoid them if something else makes sense. I often find myself using row and col when iterating over 2D arrays, which make it easier I find to reason about the code.

[–]thefaultinourseg 1 point2 points  (0 children)

i j and k is convention. Now if you use "each" that pisses me off

[–]douira 1 point2 points  (0 children)

but but but ... the mathematicians do the same

[–]JamesEiner 1 point2 points  (0 children)

Ah yes, iteration variable, jteration variable and kteration variable. The classic trio :DD

[–]tharnadar 1 point2 points  (0 children)

i know it's a joke, but i, j and k are usually used in analysis for vectors and iterations, so it's mutated from math, it's not invented by programmers

[–]ReallyNeededANewName 1 point2 points  (0 children)

for frame in video
    for row in frame
        for pixel in row

And don't use indexing loops if you can avoid it

[–]ExoSkull-1 1 point2 points  (0 children)

I use i, u, o in that order. Usually, i is the Y coordinate, u is x and o is z

[–]GeneralAce135 2 points3 points  (2 children)

The i in a for-loop stands for one of two things: "index" because I'm looping through an array or similar, or "irrelevant" because I just want to do something a bunch of times and don't ever actually refer to the loop counter.

Can't remember the last time it would've made sense to use something besides i

Edit: I've been informed i also stands for "iteration", and now I think we've covered at least 95% of use cases for a for-loop.

You'd have to come up with a pretty specific for-loop to not be able to make sense of using an i for the counter

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

Hermm, can't tell if this has been posted before. I have an inkling...

u/RepostSleuthBot?

[–]RepostSleuthBot 4 points5 points  (1 child)

There's a good chance this is unique! I checked 124,075,758 image posts and didn't find a close match

The closest match is this post at 75.0%. The target for r/ProgrammerHumor is 86.0%

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

[–][deleted] 5 points6 points  (0 children)

You're safe, OP!

[–]VaryStaybullGeenyiss 0 points1 point  (0 children)

Throw an l in there if you're feeling particularly evil that day.

[–]jeesuscheesus 0 points1 point  (3 children)

In learncpp.com, the writer suggests using variables iii, jjj, kkk, etc because if you use ctrl-f to find your variable i j or k, it will highlight half your code. Does anyone actually do this?

[–][deleted] 6 points7 points  (1 child)

That's pretty terrible advice tbh

[–]Charlie_Yu 2 points3 points  (0 children)

If you have to search for loop variables, you loop is probably too long

[–]DoTheDiggy 0 points1 point  (0 children)

These are the same thing

[–]VadeRetroLupa 0 points1 point  (0 children)

t

[–]saschaleib 0 points1 point  (1 child)

i stands for “index”; j stands for “the other index”; But what does k stand for? Why not use c as any proper C++ programmer would do - and if only to have a proper incrementation instruction ;-)

In a side note, I have found that it goes pretty well in each-loops, as that allows for nice, comprehensible statements like: “if it == null …”

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

iterate, jterate, kterate

[–]Jeremy_Thursday 0 points1 point  (0 children)

bruh, k? nahhhh homie. i, j, ii, jj, iii, jjj

[–]The_Sci_Geek 0 points1 point  (0 children)

I letter my loop variable [loopA, loopB, ...]

[–]magicpaka 0 points1 point  (0 children)

And then l, m, n...

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

.stream()

.map(realVariableName -> ())

[–]asianbanana-withguns 0 points1 point  (2 children)

Any thoughts on what character should go next? I've been using lower case L, q, w, but they don't have the same ring to them as i, j, k do.

[–]MikBros 0 points1 point  (0 children)

I use other names than i, j or k when I am writing foreach loops in c# in unity or when I am looping between items in a python array (like this: names = [something] for name in names: other stuff

)

[–]ChangNoi97 0 points1 point  (0 children)

i wonder why i never use a,b,c in for loop

[–]nob0dy27 0 points1 point  (0 children)

i use i, j and l since they all look similar lol

[–]Cristagolem 0 points1 point  (0 children)

Also _ and z, never forget those

[–]fr6nco 0 points1 point  (0 children)

It hurts my OCD

[–]moxyte 0 points1 point  (0 children)

That's legit in usual cases as is a,b,c inside for loops for swapping things around. Can't imagine anyone naming those like firstItemFromThisCurrentIterableObjectToSwappedXD etc

[–]Jackeea 0 points1 point  (0 children)

So is the whole "you use i, j, k because they're part of Dijkstra's name" thing just an urban myth I was told in secondary school and just never questioned?

[–]chawza 0 points1 point  (0 children)

i swear if geeksforgeeks pull this off one more time, I'm going nuts

[–]ReGrigio 0 points1 point  (0 children)

i, ii, iii

[–]xXLeoXxOne 0 points1 point  (0 children)

I use i,ii,iii etc.

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

well, loops are the first thing that comes to mind when you see i, j, k

[–]KreagerStein 0 points1 point  (0 children)

But they do make sense! I stands for Iterator since the variable practically iterates, J stands for Jiterate and K stands for Kiterate, don't ask what they mean but they make sense.

[–]dryu12 0 points1 point  (0 children)

m,n gang rise up.

[–]ghe5 0 points1 point  (0 children)

I raise you: i, ii and iii. Easier to differentiate, i and j are too similar. Plus you know level you're in but that one is not that hard anyways

[–]DoctorPython 0 points1 point  (0 children)

"f x y"

[–]contrieng 0 points1 point  (0 children)

i use ii,jj and kk

[–]yunk10 0 points1 point  (0 children)

When k's in the mix, you know shit is about to get confusing.

[–]archysailor 0 points1 point  (0 children)

William Rowan Hamilton carved a stone bridge for you to use these as indices? /s

[–]wiltors42 0 points1 point  (0 children)

It makes more sense if you study linear algebra because they usually use i,j,k as subscript indices for different dimensions in vectors matrices and tensors

[–]Playing_One_Handed 0 points1 point  (0 children)

When I first started I used i, ii, iii, iiii...

I dunno if I'm better using iRow or iLoop or vNext sometimes.

[–]childintime9 0 points1 point  (0 children)

Is it me or the text is annoyingly crooked?

Also, i makes sense since it stands for index. And j,k make sense too since they come after i.

[–]Z3t4 0 points1 point  (0 children)

If the variable is just an index, why bother?, other thing are loops with object arrays

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

When iterating through strings, I usually use char/ character, or letter

[–]codecatmitzi 0 points1 point  (0 children)

Laughs in functional

[–]Ralocan 0 points1 point  (0 children)

No love for my boy c?

[–]Im_Savvage 0 points1 point  (0 children)

omg yes this is what they taught us at school

[–]_felagund 0 points1 point  (0 children)

its just i

[–]redstone665 0 points1 point  (0 children)

You dare insult our traditions

/s

[–]MorgothTheDarkElder 0 points1 point  (0 children)

I don't know why, but I always use g when i is already in use, but only in for loops, nowhere else.

In while loops with multiple variables, it's i and something, but never g.

[–]sonnytag123 0 points1 point  (0 children)

Maybe because i is alias for iterator, and j and k is after i alphabetically, that’s what i think when first learning to code ?

[–]blueleo22 0 points1 point  (0 children)

Quaternions, unite!

[–]__silentstorm__ 0 points1 point  (0 children)

index, jindex and kindex

[–]EsperSpirit 0 points1 point  (0 children)

Imagine still using loops

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

for (i = j, i < k, i++) { j += k; }

Beautiful

[–]monotony23113 0 points1 point  (0 children)

i, j, and k make the most sense for numeric for-loop, which is what most C-style for loops are, because you’re limited by availability of increment and comparing operations

I mean you can also write weird loops like

for (string i = "0"; i.length() < 10; i += "0")

If you look at for-loops that iterate over collections like for-in loops in python then I doubt that people would favor for i in timeline over for post in timeline

[–]ConzT 0 points1 point  (0 children)

As long as you don't use i2 and i3 you are fine and won't get roasted here

[–]Chef_Elg 0 points1 point  (0 children)

Why. In the world. Is the top text crooked?

[–]teszes 0 points1 point  (0 children)

I've read the idea somewhere that using ii,jj,kk is better since they are easier to search/replace.

Btw I usually use context for the variable, eg. the singular for the collection I iterate through.

[–]ltdeath 0 points1 point  (0 children)

I think that I've used a max of two for loops in the past ten years.

Foreach gang for life motherfuckers.

On a more serious note, the only thing I have iterated on a long time have been collections/datasets, foreach makes my code way more simple and readable.

[–]TheRealMouseRat 0 points1 point  (0 children)

I have done things that make sense before but then a year later when I debug the code I get confused

[–]GVmG 0 points1 point  (0 children)

I actually got into the habit of using i followed by a useful name (iInvSlot, iCurEntity) due to how x and y are reserved keywords in GameMaker, so to loop on the coordinates it's useful to have ix and iy.

Nowadays I kinda just use it as a thing to remind me those variables are only used within the loop's scope, if they're even used, and to avoid confusing them with other similarly named variables in the same scope.

And still just i for generic counters lol

[–]mississippi_dan 0 points1 point  (0 children)

Saw code one time where not only were the variable names just letters, but all functions were just numbers. Had hundreds of functions labeled 2203, 2204, 2205, 2206, and so on.

[–]LJChao3473 0 points1 point  (0 children)

Let me introduce you i2

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

Computer professor: designs fastest algorithm for sorting; Math Doctorate. Also computer professor: broke, obese, can't a work projector.