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

75

u/AbinPaulZackariah Nov 12 '20

and D is Dictator

0

u/[deleted] Nov 12 '20

[deleted]

8

u/AbinPaulZackariah Nov 12 '20

C is Client and also a C**t

→ More replies (1)

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)

2

u/Ozqo Nov 12 '20

According to that system, shouldn't i be iiterator?

→ More replies (36)

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)

8

u/EnglishMobster Nov 12 '20
#define π PI

7

u/netheroth Nov 12 '20

But Python 3's interpreter is just fine with it.

7

u/Kirlac Nov 12 '20

"You'll NEVER believe these PROGRAMMING tricks! Compilers HATE him!"

→ More replies (4)

26

u/tod315 Nov 12 '20

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

15

u/[deleted] Nov 12 '20

someone that is projecting. heyoooo!

10

u/prowness Nov 12 '20

It’s used at least in probability and number theory. I know, it was weird for me the first time I saw it too.

→ More replies (3)

11

u/sawyerwelden Nov 12 '20

It gets used fairly often. It's pretty obvious when it's not the constant.

→ More replies (5)

10

u/ByteArrayInputStream Nov 12 '20

Don't forget λ and θ

4

u/NeoMarethyu Nov 12 '20

I mean epsilon is only used in small places

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

6

u/Bassie_c Nov 12 '20

Is epsilon the Big E or the weird e?

→ More replies (2)

5

u/[deleted] Nov 12 '20

My hero

→ More replies (6)

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

3

u/kazneus Nov 12 '20

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

this is the answer. it comes directly from math

→ More replies (1)

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

5

u/SilverDem0n Nov 12 '20

That's more of a const for me, but I take what I can get

I can't help but think the 🍆 should be changed to a pointer, but then it is a cold day out there

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

2

u/[deleted] Nov 12 '20

Missed t

→ More replies (1)

2

u/necheffa Nov 12 '20

Some say it is because of Fortran's implicit type system. Variable identifiers starting with i thru n are integers, the rest are floats. Mathematicians are why you end up needing to use ii or iii as loop control variables instead of having sensibility designed code

2

u/R3D3-1 Nov 12 '20

Different problem domain. Good luck reading large equations, if the variables have descriptive names, and even the end-result suddenly spans half a page. Short-hands become a necessity, though they generally should be either well-established or documented in the publication.

Of course, this to some degree carries over to implementing those equations. Have fun trying to check if a version with descriptive names matches what was written on paper... At that point, reducing the difference between paper and implementation really helps.

→ More replies (3)

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)

3

u/nephallux Nov 12 '20

You can use long names it ok

→ More replies (2)

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.

3

u/saschaleib Nov 12 '20

Absolutely. If there is just one "File" object, there's usually no reason why it can't simply be called "f". If there's two of them, better use e.g. "sourceFile" and "targetFile" instead.

3

u/trezenx Nov 12 '20

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

2

u/[deleted] Nov 12 '20

Kotlin went as far as to include the keyword it as the implicit name of a single parameter, often times for use in higher order functions, like this:

objects.filter { it.hasProperty() }

2

u/Bl00dsoul Nov 12 '20

fd for file descriptor

2

u/matrix-doge Nov 12 '20

me: fOr eAcH obj iN oBjeCtARraY

Edit: seriously tho, I actually do that sometimes. Generally noun in singular form, and plural form for arrays

2

u/Victorino__ Nov 12 '20

Any variable that's supposed to count the number of elements in something: n. For example:

for i in array:

    if array[i] >= 0:

        n += 1

2

u/dpash Nov 12 '20
for(User user: users)

Collections are almost always plurals.

2

u/Orlando-- Nov 12 '20

I couldn't do that, because I mostly work in kotlin and "it" actually means something in some contexts. Even in other languages it bothers me using "it" as a variable

→ More replies (1)

2

u/Fufu-le-fu Nov 12 '20

When I have nested for loops and already used i, I use o. Using j just leads to me confusing it with i.

2

u/Sexual_Congressman Nov 12 '20

it is for iterables which are containers of ob as in

def flatten(it):
    return [
        ob
        for sq in it
        for ob in (sq if is_iterable(ob) and not is_string(ob) else [ob])]

fs/file for file strings, fp for abstract path objects, and fd for the actual thingamabob you read and write to:

with (fp:=Path(fs)).open() as fd: txt = fd.read()

src and dst have great symmetry as in os.symlink(src, dst)

When min and max are already in use, lo and hi: lo, hi = (b, a) if (b<a) else (a,b)

lists are li or sq if a generic sequence happens to be a list; dicts/mappings are dk/mp; stack types are sp or staq and deques in particular are dq; anything related to raw memory manipulation is a buf or mem; classes are tp/cls/typ/; numbers are nb sometimes

4

u/BadFurDay Nov 12 '20 edited Nov 12 '20

Oldschool coder / don't code too often anymore, but still using:

$i, $j and rarely $k as indexes for iterating through loops and nested loops

$temp for intermediate operations that don't need to be stored

$return when preparing a function/method/subroutine's returned data

$file, $data, etc. when working with temporary i/o stuff

$query for assembling a query's content before executing it

$id when passing an id to a clearly named function/method/subroutine, eg. user_get($id)

Everything else gets a name that properly and clearly identifies them as what they are, even randomly generated numbers ($random_user), element ids ($user_id), etc.

This "name things clearly" rule includes your example, I'd use a descriptive name instead of it, since the iteration is on a specific object and not on a throwaway temporary index. There's a major difference between index 7 and user 7, I don't mind the first one being $i but the second one has to be $user or $userdata or $userstate or whatever it actually contains.

→ More replies (1)
→ More replies (8)

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?

3

u/Nall-ohki Nov 12 '20

Each new cromulent word you learn embiggens your perspicacity!

(3 Simpsons references in one sentence? Yes!)

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)

0

u/[deleted] Nov 12 '20

[deleted]

→ More replies (1)

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)

11

u/Nuroyun Nov 12 '20

3

u/siraajgudu Nov 12 '20

Yes bro OP shamelessly copied my post and reposted without even crediting me :(

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

12

u/idekvro Nov 12 '20

Can't you specify that you need whitespace around i in your search?

→ More replies (1)
→ More replies (1)
→ 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

0

u/[deleted] Nov 12 '20

[deleted]

6

u/IAmTotallyNotSatan Nov 12 '20

As opposed to Iow and Jolumn?

0

u/[deleted] Nov 12 '20

[deleted]

16

u/techwiz5400 Nov 12 '20

Nnnnnnnnnnn

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.