|
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
|
|
|
|
|
Yes, quite. BASIC in 1983, Pascal in 1985, COBOL in 1986, Fortran (77?) in 1987. But BASIC is the only one I've been paid to use, COBOL and Fortran I only touched in college, and Pascal I haven't used at all since becoming comfortable with C. C# pays the bills now.
|
|
|
|
|
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...
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
And, mainly, all the CS textbooks use i and j for loops.
|
|
|
|
|
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.
|
|
|
|
|
I now use 'loop' as it is easier to read the code though I did use i for many years just because it was the convention.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
But "loop" is a verb.
|
|
|
|
|
No, it's a word (noun and verb) that perfectly describes the intention of the code.
I try to use as much 'real' English rather than silly tokens in code: makes the intention clear and the code eminently more readable.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
silly tokens does depend on the reader.
for me, it's more clear what you mean if you use "i" than if you use "loop", but that's because i'm used to the former.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
"Given the chance I'd rather work smart than work hard." - PHS241
"'Sophisticated platform' typically means 'I have no idea how it works.'"
|
|
|
|
|
Exactly. Know your audience.
|
|
|
|
|
*legacy coder detected*
why exactly is "loop" harder to read then "i"? Cant you read?
Copy, paste, compile, erase
|
|
|
|
|
Bit like f u n e x? (You'll need to look that up if you don't know what I mean).
Using i is so 20th century.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
mark merrens wrote: Using i is so 20th century.
That and Apple will probably patent it before long...
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
i think it's alread patented...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
"Given the chance I'd rather work smart than work hard." - PHS241
"'Sophisticated platform' typically means 'I have no idea how it works.'"
|
|
|
|
|
We programmers are a self-centered bunch. It's never about the other person, it's always "I I I" this, "I I I" that. jk, jk. lol.
Hmmm...
I suppose the letters in preference would have to be: ijklo.
An expanding counter-clockwise spiral starting with "i"!
From this, we can ascertain the correct letters to use for each new level of loop nesting: ijklouhmpygntfbrdvescwaxqz.
Any other order is incorrect.
|
|
|
|
|
AspDotNetDev wrote: From this, we can ascertain the correct letters to use for each new level of loop nesting: ijklouhmpygntfbrdvescwaxqz.
How deep did you go into the spiral? I usually stop on the 'g'.
Greetings - Jacek
|
|
|
|
|
I've never had a need to go past "c".
|
|
|
|
|
|
Look at any mathematics text that is older than computers. You will find i, j, k, m, n rampant as indexes for just about any formula you can find. Also, x, y, z are common variables and A, B, C are commonly used as constants.
--
Harvey
|
|
|
|
|
I second the math heritage.
Remember the Capital Sigma sum sign like you see in Excel now?
<a href="http://en.wikipedia.org/wiki/Summation#Capital-sigma_notation">http://en.wikipedia.org/wiki/Summation#Capital-sigma_notation</a>[<a href="http://en.wikipedia.org/wiki/Summation#Capital-sigma_notation" target="_blank" title="New Window">^</a>]
PI is used for products.
<a href="http://en.wikipedia.org/wiki/Multiplication#Capital_Pi_notation">http://en.wikipedia.org/wiki/Multiplication#Capital_Pi_notation</a>[<a href="http://en.wikipedia.org/wiki/Multiplication#Capital_Pi_notation" target="_blank" title="New Window">^</a>]
|
|
|
|
|
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?
|
|
|
|
|
It could happen during testing, but I agree that using the table name is better.
|
|
|
|
|
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
|
|
|
|