for(int i=0; i<size; i++)
-
If it wasn't for our coding standard, I would employ index, jndex... today. I like that idea.
Matt
Why not just skip to "spa"
-
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?
same thoughts
-
Yes, it started in FORTRAN and leads to the following joke: God is real unless declared integer At least now you have the context so you can see the humor :)
Sorry, I still don't see the humour! (Sound of tumbleweed blowing)
-
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?
In my mind, it was because of FORTRAN. Back in the day, we didn't have all that many languages to choose from and most of us wrote in 360 assembler, FORTRAN, or COBOL. As others have said, while FORTRAN did have typing, variables starting with i-n were defaulted to integers so we just used i - followed by j, k, l in nested loops - for simplicity. We also used foo, foobar, and jane for "temp" variables. foo and foobar were common for IBM programmers and jane was common in DEC code.
-
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? http://en.wikipedia.org/wiki/Summation#Capital-sigma_notation[^] PI is used for products. http://en.wikipedia.org/wiki/Multiplication#Capital_Pi_notation[^]
-
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've never used fortran, I always thought of 'i' as an unnamed integer. A throw-away variable.
-
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?
now that you made me think of it, I realized of my habit of using "t" instead of "i" as my favorite looping variable. It's because I learned of FOR loops back in 1984 when typing BASIC programs on my Commodore VIC20. The user manual had several sound-effects example listings, mostly composed of a FOR T=something statement, where T stayed (I guess) for time. I typed many of them and eventually got the habit of the "t" variable. Effects were something like this:
10 REM LUNAR LANDING EFFECT
15 POKE 36878,15
20 FOR T=200 TO 120 STEP -1
30 POKE 36876,T
40 FOR I=1 TO 100:NEXT I
50 NEXT T(for the curious ones, 368678 was for volume "up" and 36876 for playing tone).
-
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
-
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.
-
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 use i because I was taught so in school, also every example in any book use i (j, k, etc.) as loop variables so I assume it seems natural to me. By the way I always thought i stood for index.
CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...
-
WPerkins wrote:
If not otherwise defined FORTRAN would default to integer variables whose names started with "I" through "l" (ell) I believe...
Right, and this spawned the expression "God is real (unless declared integer)".
-- Harvey
I just asked Him, he said "Don't Fret It, Dude". Amazing how much hold over there is. IBM PCs in the mid 1980s had screens that were 25 rows by 80 columns... same dim as punch cards. I wonder how much hold over we've gotten from APL and ADA - even those of us who never wrote any APL or ADA. Topic for another thread perhaps. I am currently working on a big project in Delphi 7 - circa 2005 code. I thought Pascal had died about the same time as Milli Vanilli... guess not. Disco rocks, by the way.
-
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.'"
-
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.
-
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. :thumbsup:
-
Exactly. Know your audience. :thumbsup:
*legacy coder detected* why exactly is "loop" harder to read then "i"? Cant you read? ;)
Copy, paste, compile, erase
-
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?
-
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.'"
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
-
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)
-
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.'"