r/ProgrammerHumor • • Nov 12 '20

Removed: Repost It's the law!

Post image

[removed] — view removed post

10.9k Upvotes

378 comments sorted by

•

u/dejaydev Nov 14 '20

Hi there! Unfortunately, your submission has been removed.

Violation of Rule #2 - Reposts:

All posts that have been on the first 2 pages of trending posts within the last month, is part of the top of all time, or is part of common posts is considered repost and will be removed on sight.

If you feel that it has been removed in error, please message us so that we may review it.

1.1k

u/boboprobo Nov 12 '20

i is iterator, j is jiterator, k is kiterator

16

u/murtaza64 Nov 12 '20

index and jndex

9

u/calcopiritus Nov 12 '20
for index, i in enumerate(list):
    for jndex, j in enumerate(ljst):
        for kndex, k in enumerate (lkst):

3

u/TwoAndHalfRetard Nov 12 '20

s is separator

3

u/[deleted] Nov 12 '20

L is literature

10

u/progrography Nov 12 '20

o is offender, p is predator, q is queer, r is [removed], s is seducer, t is transformer.

5

u/SilverDem0n Nov 12 '20

u is *unzips*

→ More replies (3)
→ More replies (37)

436

u/[deleted] Nov 12 '20 edited Nov 12 '20

It's just like mathematicians being obsessed with x,y,z i,j,k a,b,c f,g,h t,u,v,w m,n p,q,r

232

u/[deleted] Nov 12 '20

α,β,γ ε,δ π

161

u/nubenugget Nov 12 '20

Compilers must dislike you

23

u/Penki- Nov 12 '20

Compilers are known for their hatred of Greeks.

→ More replies (2)
→ More replies (7)

26

u/tod315 Nov 12 '20

Excuse me what kind of deranged mathematician would use π as a variable

→ More replies (11)

10

u/ByteArrayInputStream Nov 12 '20

Don't forget λ and θ

→ More replies (1)

36

u/YOBlob Nov 12 '20

When in doubt, use phi

41

u/SilverDem0n Nov 12 '20

I like to assign any huge constants as epsilon to annoy colleagues

→ More replies (10)

5

u/Gidelix Nov 12 '20

Phen meeting a physicist and in doubt, use theta.

18

u/chepas_moi Nov 12 '20

No, it's more than that. i, j, k are for integers where x, y, z are for floats. Knuth said so.

16

u/Cyberwolf33 Nov 12 '20

A small table of common uses for those interested (source: math graduate student)

x,y,z: Real variables, generally in a function.

i,j,k, (l if desperate): indices for sums, products, and general collections of things. Capital I,J,K are often ideals.

a,b,c (and others): simple variables (like in a small system of equations ) or geometric objects/angles (angles uppercase, sides lowercase)

f, g, h: functions, or more generally, morphisms. Capital G can also be a group, and H a subgroup.

u,v,w: first use, linear algebra vectors. Capital U, V, W for the vector spaces themselves. Also work as desperation variables.

m,n,p,q,r: Integers. m,n often the upper index of a sum or product, and used when referring to addition of integers. p, q often used for multiplication. r for radius of a sphere too

Bonus Greek letters! (Lowercase unless specified)

(Var)phi, psi: A morphism

alpha, beta, gamma: Elements of something, often when the above letters are exhausted elsewhere or certain lead to confusion.

epsilon, delta: smöl bois.

pi: pi.

Pi (uppercase): Products

sigma, tau: a permutation (a bijective function from a set with some amount of elements to itself)

Sigma (uppercase): sums

theta: an angle

lambda: Eigenvalues of a matrix

zeta, xi: “Jesus I have so many variables floating around what the hell do I even call this?!? UGH FINE XI IT IS”

Edit: And a variety of others that I have not thought to include. Feel free to add or contest, these are just what I’ve regularly seen

→ More replies (2)

29

u/SilverDem0n Nov 12 '20

You can use emoji for variable names in a bunch of languages. You can pick an emoji that has a different semantic meaning than the purpose of the variable if you want to be particularly awkward, and I am sure you do.

48

u/Lame_Goblin Nov 12 '20

var 😍 = 🍆 + 💦

22

u/Harbltron Nov 12 '20

Thanks, I hate it

→ More replies (1)

9

u/[deleted] Nov 12 '20

Also, the lennyface ( ͡° ͜ʖ ͡°) is a valid name

4

u/Gornarok Nov 12 '20

I think lots of it has to do with physics which hogs most characters...

→ More replies (9)

181

u/WowSuchEmptyBluh Nov 12 '20

I could do k. Don't you dare to ask for any more.

78

u/Snykeurs Nov 12 '20 edited Nov 12 '20

Also use k, v for dictionary

47

u/nubenugget Nov 12 '20

If it's a Map (or dictionary in Python) I use "key" and "value" or something based off of what is stored as key/value

16

u/[deleted] Nov 12 '20

Nested loops are the future. I’m sure Intel’s next processor will be able to take a billion functions pushed onto the stack for each onClick event handler!

6

u/lightheat Nov 12 '20

lmao big O go brrrrr

4

u/mostlyBadChoices Nov 12 '20
while(k < MAX_VALUE) {
   for(int k1=k; k1 >= k; k1++) {
       int k2 = k1*k;
       for(int k3=0; k3<k1 && k3>k2; k3++) {
          ... 
       }
       ...
    }
}

81

u/saschaleib Nov 12 '20

Actually an interesting point: what other "default" variable names are you guys using?

Like, if I'm iterating over objects, I always call them "it", as in (pseudocode):

for each it in objectarray
   if it is null ...

57

u/DoktorMerlin Nov 12 '20

i mostly use "item" if there is no other obvious name, but mostly it is like

foreach(phoneState: PhoneState in phoneStates)
    if(phoneState != null)

16

u/Khaare Nov 12 '20

That kind of naming quickly gives me semantic satiation and I get dizzy.

→ More replies (2)

13

u/Eolu Nov 12 '20

i is the only default variable name I use that I can think of. For the kind of iterator in your example I always give a meaningful name.

for each balloon on balloon_array

i seems reasonable to me because an index is an int counter no matter where you use it, whereas the it is a different thing depending on what’s being iterated through.

→ More replies (1)

39

u/nubenugget Nov 12 '20

Iterator > iter

Random > rand

Anything that I'm using to store an object/value in temporarily > temp

8

u/Embr-Core Nov 12 '20

Wait are you intending me to read this as “iterator is better than iter” or “use iter for the iterator variable”

→ More replies (1)
→ More replies (3)

6

u/n0tKamui Nov 12 '20

funny thing, because in Kotlin, the default single parameter name of a lambda is it

(0..10).forEach { println(it) }

is strictly equivalent to

(0..10).forEach { x -> println(x) }

→ More replies (5)

3

u/Superbead Nov 12 '20

I sometimes use f (file), o (generic object), s (string), r (return value) and v (value) to keep verbosity down, especially in short functions or as the only obvious parameter to a clearly-named function, but only where it's unambiguous.

If I had two files in the same routine, I'd give them clearer names.

→ More replies (1)

3

u/trezenx Nov 12 '20

that's actually pretty clever maybe it will help me with my loop-struggles, thank you

→ More replies (19)

73

u/Nall-ohki Nov 12 '20

i is fine as an index variable, not as a value.

One letter variable names are appropriate to sub-function scopes such as loops where their context is entirely grokable at a glance.

7

u/TheGreatSalvador Nov 12 '20

Thanks for the new vocab word!

12

u/RavioliConsultant Nov 12 '20

What the fuck is a variable?

→ More replies (1)

7

u/dpash Nov 12 '20

The other acceptable use is if the domain uses those names. Coordinates and scientific equations spring to mind.

But then where possible, coordinates should be in a point class so there's extra context attached. And as you say, scope should be limited.

→ More replies (1)
→ More replies (4)

24

u/drdrero Nov 12 '20

I rarely use for loops, but when I do, it is related to the amount of iterations and not directly the iterated object. Therefore, i is fine.

20

u/[deleted] Nov 12 '20

In my next life, will name my first daughter Eye, and the second Jay.

9

u/devils_advocaat Nov 12 '20

Planning on the snip before Kay, Elle and Em arrive?

→ More replies (1)
→ More replies (2)

49

u/ManuelRav Nov 12 '20

I use i, ii, iii etc. I used to use k, kk, but the third one didn’t look to good when reviewed...

5

u/LJChao3473 Nov 12 '20

I prefer i, i2, i3. I sometimes used j, j2. But never k

→ More replies (2)

6

u/Comesa Nov 12 '20

i ii iii iv v vi vii viii ix x...?

→ More replies (1)

81

u/olafurp Nov 12 '20

I use index because I hate single letter variables

186

u/[deleted] Nov 12 '20

Usually I'd agree with you but in

for (int i = 0; i < limit; i++)

writing "index" or "iterator" instead of "i" doesn't add any useful information.

It's such a universal snippet that everyone will immediately know what i is.

But if someone writes

Class A

{

private int i;

}

then fuck that person.

9

u/AceSLS Nov 12 '20

Class A

{

private int i;

}

I'm waiting fingers crossed

27

u/TSPhoenix Nov 12 '20

It isn't about adding information, it is so when I CTRL+F my loop variable I get only my loop variable. Yes I know a better IDE solves this, but we don't always get to choose.

57

u/nasaboy007 Nov 12 '20

If your loops are long/complicated enough that you need to ctrlF your index variable, that sounds like a code smell itself.

→ More replies (1)
→ More replies (3)
→ More replies (2)

14

u/hessenic Nov 12 '20

Only if it's an index, iteration is also a good choice.

→ More replies (4)

3

u/renrutal Nov 12 '20

The length of a variable name is usually proportional to its scope.

I'd use i in small scopes and index in slightly wider ones.

3

u/dpash Nov 12 '20

i is so ingrained for loop indexes, in okay with using it in just those situations. Also acceptable if the domain typically uses that letter (x and y for coordinates or in scientific equations).

But list iteration (foreach etc) is preferable to indexes if your language supports them.

→ More replies (2)

25

u/wunderbraten Nov 12 '20

m and n are also some nice variables, especially for looping inside of a loop

3

u/ShlomoPoco Nov 12 '20

I like x and y for 2d arrays, because my brain is cursed and turns matrices to coordinates system.

a[y][x] is like the point (x,y).

I might be abit weird tho

→ More replies (4)

7

u/sociallyawkwarddude Nov 12 '20

Because i, j and k are commonly used in vectors and matrices?

6

u/_Screw_The_Rules_ Nov 12 '20

I like to use x, y, n and i the most

2

u/MadMax2230 Nov 12 '20

x y n and i can be rearranged to spell n i x y

nixy is a misaddressed or illegibly addressed piece of mail

motherfuckers have alleged voter fraud with mailed ballots

twitter is a social media platform

reddit is a social news aggregation website

your username is screw the rules

trump also likes to screw the rules

and the working class

your comment is a subliminal message

by the bourgeoisie

trying to sway my modus operandi

and i will not take

the mind control medicine

the doctor prescribed me

begone thot, and may we be rid of your devilish variables

6

u/Cley_Faye Nov 12 '20

Me: "Ok enough of this, now we'll properly name loop variable for what they mean to improve readability"

Me, a bit later: "Screw that, I'm not coming up for another name for that, everyone knows 'i' anyway"

17

u/checkeredfire Nov 12 '20 edited Nov 12 '20

Others: why do you always use i,j variabes in loops? Programmers:

[Photo of Mr Moseby from Zach and Cody, speaking to London Tipton, with his mouth open looking passionately frustrated.]

ITS THE LAW

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

3

u/nubenugget Nov 12 '20

Thank you~

→ More replies (2)

5

u/Pixelmod Nov 12 '20

At best, I find i acceptable solely for self-contained loops with no nesting and no use of the variable outside the loop. And then again I'd advise using index at the very least.

If you have nested indexes, please give them proper descriptive names. Pseudocode:

for (let categoryIndex = 0; categoryIndex < categories.length; ++categoryIndex) {
    const category = categories[categoryIndex]

    for (let itemIndex = 0; itemIndex < category.items.length; ++itemIndex) {
        // Do your thing
    }
}

This isn't math class, readable code is more important than your keystroke-saving shenanigans anyways. If you're too lazy to type your variable names completely, get an autocomplete. We have plenty of those, and some even have AI that can guess your var names for you.

2

u/TropicalAudio Nov 12 '20

This does depend on the type of nesting. In image analysis, you sometimes want to iterate over different dimensions, but those might not always correspond to rigidly oriented x/y/z/t data. If you use x/y/z in a loop that gets fed rotated data, debugging can get really confusing, as your x might correspond to t, y to z and z to x, or any other combination. If your input can be an arbitrary dimensional slice in an arbitrary orientation, i/j/k iterators will be just as clear as dim1/dim2/dim3.

→ More replies (1)

9

u/wrossi81 Nov 12 '20

I learned C++ in high school and Java in college, and wasn’t a fan of the latter. When I had to write code in Java I would use c as my iterator, so the for statement said c++.

4

u/Borthralla Nov 12 '20

“i” is for iterator/index, j and k come alphabetically after i.

4

u/JuanGee1G Nov 12 '20

I always thought of them representing the vector components i, j, k, etc. because of how they can index arrays/vectors/matrices/lists.

3

u/lucifer7557 Nov 12 '20

Hooch is crazy !!!

3

u/[deleted] Nov 12 '20

We also don't use A or B as drive letters anymore. But that's more to honor our fallen drive comrades.

→ More replies (1)

3

u/hessenic Nov 12 '20

Afaict its a hold over from the days where storage was EXPENSIVE. There's a lot of older code that has abbreviations because the cost of learning the abbreviations and contractions was much less than the cost of storing the source code.

2

u/SilverDem0n Nov 12 '20

Some early language implementations only used the first couple characters in identifiers and ignored the rest - for space/speed like you say. Some of the 80s BASICs just used the first two characters of any variable name at most, and ignored the rest.

And small terminals don't have much space to waste on long names.

→ More replies (2)
→ More replies (1)

3

u/hemispace Nov 12 '20

It's to be able to remember how to spell Dijkstra!

2

u/MajorBarnulf Nov 12 '20

Index1 Index2 Index3 group there

2

u/goingtosleepzzz Nov 12 '20

for item in whatever_list

→ More replies (3)

2

u/[deleted] Nov 12 '20

but do you pre-increment or post-increment your loops?

→ More replies (1)

2

u/RaghadR Nov 12 '20

If it’s a single loop, then I use ‘n’. If it is 3 or more level nested, then I use ‘i1’, ‘i2’, ‘i3’,...

But yes, for 2 level nesting, i j is all time favourite.

2

u/ribbonsofeuphoria Nov 12 '20

Why was Dijkstra so good at algorithms?

His name has i, j, and k in it.

You will never misspell Dijkstra again. You're welcome.

→ More replies (1)

2

u/samspot Nov 12 '20

What a vulgar display of explicit iteration.

2

u/sora4d Nov 12 '20

I use x and y

2

u/MrJod2002 Nov 12 '20

Is x not ok? Asking for a friend

2

u/SilverDem0n Nov 12 '20

CS came from mathematics, and mathematicians use these single letters for indices as they have to write them on blackboards.

Also, early languages and implementations ignored anything beyond the first few letters of identifiers, so longer identifier names may have actually clashed to the surprise of programmers.

1

u/injuomatic Nov 12 '20

Because in Fortran you've to add 'implicit none' to use other letters as intenger

1

u/[deleted] Nov 12 '20

i use w because satan is my dad

1

u/SSUPII Nov 12 '20

i used to name counters count

1

u/[deleted] Nov 12 '20

Javascript be like: "okay let's place "x" here..."

1

u/braytag Nov 12 '20

it's the law, unless I'm doing cartesian for my game (ex.: grid), then it's x,y.

1

u/xbt_ Nov 12 '20

I don’t always use variabes but when I do I actually use variables

1

u/BlackTorr Nov 12 '20

When i started coding i would use i, n, or x, in an inconsistent mess, now i use ndx short for index, witch has (almost) all 3.

1

u/FinnT730 Nov 12 '20

LONDON, WHY ARE YOU SO....

1

u/daisybelle36 Nov 12 '20

for thing in working_list: ....

1

u/assassinsorrow Nov 12 '20

I feel like I am the only person who uses n in loops

1

u/GeneMayo Nov 12 '20

ijk might come from BASIC if not earlier. They are used as iterator named for more than three decades, IIRC.

→ More replies (1)

1

u/alumunum Nov 12 '20

It stands for increaser.

1

u/Masol_The_Producer Nov 12 '20

What does

next mean?

1

u/Hahohoh Nov 12 '20

I write lnterger (with lower case L) just to piss myself off

1

u/Sexual_tomato Nov 12 '20

I always thought it was because I, j, and k usually denote the basis vectors in 3d space when doing matrix math, and most early computing was done by mathematicians who would visualize a 3d array as a cube.

1

u/Tukurito Nov 12 '20

For clearer code use i1, k2 and j4.

1

u/erickweil Nov 12 '20

I don't use j, just i and k.

If is 3 nested loops, x,y and z.

And if more than 3 nested loops, I quit.

1

u/krillxox Nov 12 '20

for each: Am I a joke to you?

1

u/[deleted] Nov 12 '20

Oh I miss writing loops. I think I haven't written a for loop in years.

1

u/Saihardin Nov 12 '20

i, j, k

And if one still requires more then for some reason we go back to a, b, c

1

u/MarryUhna Nov 12 '20

Except for when working with coordinates, then you obviously use

x, y, z. Anyone else is a maniac

1

u/[deleted] Nov 12 '20

Btw, it's a stupid law, it's really easy to confuse i and j

1

u/beardMoseElkDerBabon Nov 12 '20

I always break the law. r for rows, c for columns. x,y,z,w... iWhatever rWhatever cWhatever xWhatever ...

1

u/MyHamburgerLovesMe Nov 12 '20

It comes from Mathematics where "i" is used in Summation notation and also used that way for collections of things, like if you have a bunch of variables x1, x2, ... xn, then an arbitrary one will be known as xi.

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

1

u/jm434 Nov 12 '20

So if anyone has taken physics, they know that i,j are popular variables as well.

If anyone has done Dynamics, they know that i,j are used A LOT and confusing them leads to bad things and hours of headache.

Now simple reader, try to imagine the lecturer you have is not a very good one, they're poor at explaining and don't provide adequate supporting material.

My lecturers i and j were indistinguishable.

Sigh. That was a stressful module.

1

u/Dabbelju Nov 12 '20

Related: "God is real, unless declared integer."

An old joke for old people...

1

u/qroamer Nov 12 '20

I use x, y, and z for number placeholders. “i” is saved for when I run out of the first three.

1

u/notsohipsterithink Nov 12 '20

I used to do that until I hit n bugs, then I was like screw it, use descriptive iterator names.

1

u/Radfordhound Nov 12 '20

Am I the only one who uses i/i2/i3...?

I personally think it just makes more sense but I’ve had multiple programmer friends freak out about it lol

1

u/intentionallyawkward Nov 12 '20

I use h and i so my code says hi to me occasionally.

1

u/FlyingSwedishBurrito Nov 12 '20

Aiterator, biterator, citerator, diterator

1

u/gdavtor Nov 12 '20

I think the reason those are commonly used is that back in the FORTRAN days, the variables I through N were by default integers (maybe because they are the first letters of 'integer').

1

u/[deleted] Nov 12 '20

Whatever happened to X and Y?

→ More replies (1)

1

u/fgam4r Nov 12 '20

Most of the times i use n

1

u/javellin Nov 12 '20

I used to use Star Wars characters as variables in my programs. My teacher didn’t like it.

1

u/[deleted] Nov 12 '20

index, jndex. Simple. Sometimes kndex.

1

u/ElCerebroDeLaBestia Nov 12 '20

Can you believe the linter we use at work will complain about variables with just 1 char?

1

u/peanut_peanutbutter Nov 12 '20

It's convention, which is not the law, but makes it easier for anyone who looks at your code to reason through it.

1

u/[deleted] Nov 12 '20

i and j being the imaginary number in MatLab is the real reason why I hate that language.

1

u/pcparticle Nov 12 '20

Absolutely, i j k w and other letters

1

u/Julio974 Nov 12 '20

I use in order i, j, k, l, then I start wondering why the fuck I have so many nested loops

1

u/TechnoloJelly Nov 12 '20

i use i and a

1

u/LavaSquid Nov 12 '20

n = "number" for me, when just iterating a count. f = "float" when I need that.

1

u/R3D3-1 Nov 12 '20

It can make sense for abstract algorithms. Which is more readable?

A(i,j) = SUM([( B(i,k)*C(k,j), k = 1, N )])

outputMatrix(row, column) = SUM([( &
    leftMatrix(row, sumIndex)*rightMatrix(sumIndex, column), &
    sumIndex = 1, numberOfColumsFirstMatrix )])

It is also quite acceptable, when the value has no specific meaning.

DO i=1, numberOfItems
    item => itemArray(i)
    doSomethingWith(item)
END DO

Though in the latter case I'd use iItem over i at least.

1

u/apkul7 Nov 12 '20

This is the way...

1

u/puppy_sprinkles Nov 12 '20

That’s the law according to the rules.

Edit: Initially misquoted Dwight.

1

u/MoreNMoreLikelyTrans Nov 12 '20

Its cause the J is a modified I. With a little choopchick on the end.

1

u/1OO_percent_legit Nov 12 '20

He doesn't use K for integers PauseChamp

1

u/mcbergstedt Nov 12 '20

Lol for some of my fortran code I would use i, j, and k then i1, j1, j1, and so on.

1

u/94_ny_rangers Nov 12 '20

Try that in MATLAB and see what happens to your complex numbers

1

u/teamruski Nov 12 '20

I use ii, jj, kk.

Why? A lot easier to search for.

1

u/noise256 Nov 12 '20

It is from index. In the sigma notation for summing, i, is the index of summation.

1

u/joshmaaaaaaans Nov 12 '20

Ay don't get me start on this 'foo' 'bar' trash

1

u/[deleted] Nov 12 '20

I always used x 0.o

1

u/thenerdygeek Nov 12 '20

I've always preferred i0, i1, etc.

1

u/siraajgudu Nov 12 '20 edited Nov 12 '20

1

u/bob5654 Nov 12 '20

real gamers use i,v

1

u/longinuslucas Nov 12 '20

sometimes I use _

1

u/[deleted] Nov 12 '20

Would you like AMMMMM or FMMMMM?!

1

u/teknobable Nov 12 '20

When I started at a new place after college, we had to do a little development in the role. I turned in something early on and was asked to change my iterator variables to something more clear, like "count"

1

u/LionMcTastic Nov 12 '20

x, y, and z motherfucker

1

u/[deleted] Nov 12 '20

I exclusively use vowels

1

u/[deleted] Nov 12 '20

To be honest, modern Code rarely uses it anyway since you rarely need the current index of your iteration. You either want to iterate over every element (no index needed) or you are doing a lookup for a specific element in your collection. In both cases no index is necessary since most languages provide the element of your iteration.

1

u/[deleted] Nov 12 '20

I use i and f lol

1

u/sonotrev Nov 12 '20

I'm not sure how related but almost all mathematics books dealing with tensors or matrices always use i j k for element positions. I have a copy of a tensor analysis book which was translated from Russian after the wall fell and even that uses i j k. I don't know whether math has influenced programming or vice versa.

1

u/[deleted] Nov 12 '20

I, j, k are mathematically used as indices by convention

1

u/DrRocketWizard Nov 12 '20

1

u/RepostSleuthBot Nov 12 '20

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

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

Searched Images: 169,714,524 | Indexed Posts: 647,522,542 | Search Time: 0.72282s

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

View Search On repostsleuth.com

1

u/Pyramused Nov 12 '20

This is the way

1

u/[deleted] Nov 12 '20

The j stands for "just refactor it"

1

u/anujfr Nov 12 '20

Whoa whoa! Isn't x, y, & z the king of variable name including in loops? Who the fuck uses i, j, & k?

1

u/JaCraig Nov 12 '20

I start with x because if I have a nested loop that needs to go past z, I've done something horribly wrong and need to refactor.

1

u/DanTheMan827 Nov 12 '20

What about when you have more than two loops going at once?

1

u/patrdesch Nov 12 '20

Variabes, my favorite breakfast food.

1

u/killzdesu Nov 12 '20

I'm the one who use a, b, c for iteration for 11 years. Of course, my friends hate me and rejected my pull requests

1

u/auchnureinmensch Nov 12 '20

I use ii and jj, because I feel weird to overwrite the imaginary number. I use Matlab, though, so I'm obviously no programmer.

1

u/txjacket Nov 12 '20

I always thought it came from matrix math

1

u/Beach-Devil Nov 12 '20

i stands for index

1

u/Bosslibra Nov 12 '20

I feel lost if I don't use them

-1

u/Sudhanva_Kote Nov 12 '20

When I was in 2nd year of engineering (it was introduction to C) our teacher asked " can we use anything else other than i in (for i=0; i<n;i++). One girl who is also topper of the class said no. So everyone else collectively said no. Me and my friend knew we can use any variable. We still sometimes tell her "I'm going to use k in a for loop".

1

u/DrRocketWizard Nov 12 '20

In what college are you?

→ More replies (1)
→ More replies (2)

0

u/DanteMiw Nov 12 '20

I know "i" stands for "index", but "j"? It's because is the subsequent letter on alphabet?

3

u/SilverDem0n Nov 12 '20

naming convention from vectors I guess

3

u/vjx99 Nov 12 '20

j stands for jindex.

-6

u/[deleted] Nov 12 '20

actually using single letters is a bad practice, you should get used to using proper names.

0

u/[deleted] Nov 12 '20

[deleted]

2

u/[deleted] Nov 12 '20 edited Nov 12 '20

Exactly. Not only is it harder to read, it becomes more prone to mistakes and after you will come back to some advanced code after several months where you were using i,j,k etc you will need to waste time trying to understand wtf is going on. Seems like people downvoting me know better lol. Pretty much every decent company will tell you to use proper naming conventions which obviously includes iterators.

0

u/[deleted] Nov 12 '20

[deleted]

14

u/SilverDem0n Nov 12 '20

so you're asking him to... STOP THE COUNT?

2

u/-_entity_- Nov 12 '20

Your teacher is probably just trying to make the concept as concrete as possible.

2

u/Rinehart128 Nov 12 '20

Yeah if I were teaching I’d never use single-letter variable names