Author Topic: Where does the i come from?  (Read 2570 times)

0 Members and 1 Guest are viewing this topic.

Offline toRch

  • Major
  • *
  • Posts: 55
  • <3
Where does the i come from?
« on: January 08, 2008, 02:45:20 am »
Hello.
Well the name for the counting variable in a for-loop almost everytime is "i".
Everyone's using it. Tho other variables work, too.
Does anyone know WHY? Perhaps because it is/was taking less memory in program languages?
The history of it would be interesting(I guess).
Sorry, I didn't find a proper category for this thread.

Offline bja888

  • Flagrunner
  • ****
  • Posts: 745
  • Working
    • Bja888.com
Re: Where does the i come from?
« Reply #1 on: January 08, 2008, 03:22:26 am »
"i" is short for intager.

So the single "i" is used for the most temporary of integers.


... at least thats what I always thought.

Offline mar77a

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1295
  • mad
    • random stuffs
Re: Where does the i come from?
« Reply #2 on: January 08, 2008, 05:54:36 am »
That's like asking why are foo bar and baz metasyntactic variables hehe.

Offline Clawbug

  • Veteran
  • *****
  • Posts: 1393
  • 1184!
Re: Where does the i come from?
« Reply #3 on: January 08, 2008, 08:14:30 am »
wtf are foo and bar anyway? Where do they come from?
Fight! Win! Prevail!

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Where does the i come from?
« Reply #4 on: January 08, 2008, 04:57:33 pm »
it is clearly stated in EnEcSe's help doc that:

foo
bar
is
for
noobs

but if you want the wiki:
http://en.wikipedia.org/wiki/Metasyntactic_variables



OU812?



I sometimes use b for bytes, and I use j if I need another array number (I usually capitalize B if I capitalize the word "byte" in the rest of the script, just a habit...)

I just use i because everybody else does, so it's easiest to pick up...
« Last Edit: January 08, 2008, 05:03:47 pm by Kavukamari »
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: Where does the i come from?
« Reply #5 on: January 08, 2008, 05:30:27 pm »
I use "i" as short for "index", as array access is typically common usage for such a variable. This is also in line with it's usage in mathematics; ie: Capital-Sigma notation for summation, which uses i, m, and n to represent the index of summation, lower bound, and upper bound respectively.

Note that as far as programming goes, a simple loop should be the only acceptable place that you use a single letter variable for; it's bad programming practice to use single letter variables anywhere else. There is no runtime cost overhead for using descriptive variable names.

Offline Radical Terrorist

  • Camper
  • ***
  • Posts: 375
  • The Turr'rst
Re: Where does the i come from?
« Reply #6 on: February 03, 2008, 12:23:26 am »
You folk must be some of them there computer-geniuses.

I almost wish I had given up science and Law for some Computer stuff.
Never take life seriously. No one ever gets out alive.

Offline rfreak

  • Soldier
  • **
  • Posts: 152
Re: Where does the i come from?
« Reply #7 on: February 19, 2008, 09:03:23 pm »
Radical Terrorist
 
why not do Science Law and computer? That's what I'm doing
R the coolest game ever