|
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 for iterator/iteration. Or i for index, as in how far through the loop it is.
.-.
|o,o|
,| _\=/_ .-""-.
||/_/_\_\ /[] _ _\
|_/|(_)|\\ _|_o_LII|_
\._. |\_/|"` |_| ==== |_|
|_|_| ||" || ||
|-|-| ||LI o ||
|_|_| ||'----'||
/_/ \_\ /__| |__\
modified 30-Apr-13 4:25am.
|
|
|
|
|
When I started I thought it was i for integer.
|
|
|
|
|
It is from Fortran. Integers were i to n, everything else was real. i happened to be the very first integer letter. Everyone unknowingly just followed Fortran.
|
|
|
|
|
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#.
|
|
|
|
|
|
There were but they were implicit.
Any variable name beginning with a letter between (and including) the first two letters of INteger was an integer, any other variable was a real.
|
|
|
|
|
Fascinating!
I know and still use that convention but had no idea what that particular set of letters was chosen until now.
Thanks.
Murray
|
|
|
|
|
Some of the earliest computer pioneers were mathematicians, and integers are usually represented by i, j and k. I guess it was just a convention academics adopted to avoid having to mentally remap a limited set of typewriter symbols.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
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.
|
|
|
|