for(int i=0; i<size; i++)
-
I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?
-
Yes - for me it is a Fortran language practice. In Fortran IV, any variable starting with I, J, K, L, M, N is an integer (case-insensitive), whereas a variable starting with any other letter is a float. This continued for me, through C, Java, C++, C#.
-
I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?
As someone already stated, I think it's i for iterator / index. But it also makes it easy to accidentally place a 1 in there e.g. dataset.Tables[1] and not spot a mistake. Sometimes I'll use r and c if iterating through rows and columns e.g. dataset.tables[0].rows[r][c]
-
It's also from FORTRAN for me, but we used just "i" rather than "index" partly because it saved time and space. We didn't have IDE's in those days, but punched cards (or paper tape) and is was a lot quicker to type a single character variable name on a punched card than a longer one. Saved waste as well if you mistyped "index" as "inedx" you had to chuck the card and type a new one. With paper tape each character occupied 1/10th inch of tape, so "index" used 5 times the paper each time you typed it. With a long subroutine, that could get significant and make the roll a lot bigger (and heavier) and harder to roll back up again when it spooled off the end of the reader... We only had 6 character variable names anyway... :laugh:
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
And, mainly, all the CS textbooks use i and j for loops.
-
It's also from FORTRAN for me, but we used just "i" rather than "index" partly because it saved time and space. We didn't have IDE's in those days, but punched cards (or paper tape) and is was a lot quicker to type a single character variable name on a punched card than a longer one. Saved waste as well if you mistyped "index" as "inedx" you had to chuck the card and type a new one. With paper tape each character occupied 1/10th inch of tape, so "index" used 5 times the paper each time you typed it. With a long subroutine, that could get significant and make the roll a lot bigger (and heavier) and harder to roll back up again when it spooled off the end of the reader... We only had 6 character variable names anyway... :laugh:
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
Oi vey, us oldies that have worked with paper tape. I've never used it in programming, but way back, when I was in the SA Air Force, I used to man a station that relayed HF radio data from Antarctica to the SA weather bureau. My main comms with down south was a teletype machine at 50 baud after error correction through a (I think Siemens) Elmux machine. If the comms were bad and the data link failed, they'd send the weather data straight to me, to capture on paper tape and later relay to the weather people.
-
As someone already stated, I think it's i for iterator / index. But it also makes it easy to accidentally place a 1 in there e.g. dataset.Tables[1] and not spot a mistake. Sometimes I'll use r and c if iterating through rows and columns e.g. dataset.tables[0].rows[r][c]
But I shudder to think why someone would venture right across the keyboard for a '1' instead of an 'i'. Yes, dataset.Tables[1] will work, but why, oh the humanity, why, are you not using the table name?
-
I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?
I tend to use
Index
instead ofi
(I definitely like verbose identifiers). And when I need several indexes, like in nested loops, I naturally call themJndex
,Kndex
,Lndex
... (not kidding). I have not yet come to the point that I useNumber
andMumber
for counts. -
AFAIK it started with the first FORTRAN - there were no type declarations then. See https://en.wikipedia.org/wiki/Fortran#FORTRAN[^]
-
I tend to use
Index
instead ofi
(I definitely like verbose identifiers). And when I need several indexes, like in nested loops, I naturally call themJndex
,Kndex
,Lndex
... (not kidding). I have not yet come to the point that I useNumber
andMumber
for counts.If it wasn't for our coding standard, I would employ index, jndex... today. I like that idea.
Matt
-
But I shudder to think why someone would venture right across the keyboard for a '1' instead of an 'i'. Yes, dataset.Tables[1] will work, but why, oh the humanity, why, are you not using the table name?
-
I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?
i am using 'i' and 'j' for iterating 2D arrays because 'i' and 'j' mean x and y in Cartesian coordinates. :) http://butterfly.blog.ir[^]
-
If it wasn't for our coding standard, I would employ index, jndex... today. I like that idea.
Matt
-
i am using 'i' and 'j' for iterating 2D arrays because 'i' and 'j' mean x and y in Cartesian coordinates. :) http://butterfly.blog.ir[^]
-
I was using
i
for index before I was introduced to Fortran.If you were using 'i' before being introduced to FORTRAN, you must have been late being introduced. When I started, there was no lowercase! After some assemblers, FORTRAN IV (aka FORTRAN 66) was one of the first high level languages that I learnt and so I (like everybody else) used I, J, and K as loop variable names. I also used FORTRAN II at college. Shouldn't for(int i =0; i
-
maybe but I don't think so. horizontal -> h not 'i' & vertical ->v not 'j' the 'i' and 'j' are symbols for horizontal and vertical vectors.
-
maybe but I don't think so. horizontal -> h not 'i' & vertical ->v not 'j' the 'i' and 'j' are symbols for horizontal and vertical vectors.
-
:omg: Hmmmmm...
-
But I shudder to think why someone would venture right across the keyboard for a '1' instead of an 'i'. Yes, dataset.Tables[1] will work, but why, oh the humanity, why, are you not using the table name?
Brady Kelly wrote:
But I shudder to think why someone would venture right across the keyboard for a '1' instead of an 'i'.
Bad habits from the type writer era. http://www.flickr.com/photos/textlad/3564672292/[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?
I think you are right. If not otherwise defined FORTRAN would default to integer variables whose names started with "I" through "l" (ell) I believe. Not too sure about the ending letter as all *good* programmers defined their variables. After years of programming I still use "t" for temporary variables (like creating a value for the debugger to see) and "t.t" for file names for the same sort of thing - temporary names while developing. This comes from the old TRS80 system. Old habits die hard, eh?
-
I am sure this was one of the hello-world codes for many of us ... But I wonder why the letter "i" .. I mean why on earth? With "a" the leading character why "i" ... After sometime I found out that Fortran language (which was/is historically used for scientific calculations) use "i" as a starting character for all integer type variables, and the quickest varible to write would be "i" Most authors and coders continued to use "i" even in C and then to C++ and then to C#, Java etc ... Is this an interpretation?
I always use index and sometimes preppend it with the object or value i am indexing. It leads to a bit more verbose code but it is a hell of a lot easier to understand. Just my opinion.