mrs@netcom.COM (Morgan Schweers) (04/26/91)
Greetings, Can someone confirm (preferably in a post, so my MBX doesn't flood) the truth/falsity of FORTRAN being the starter of 'I' as a generic loop variable? I learned to program when I was really young, and I got used to using FOR I=1 TO 100, and such, from reading sample programs. I still use 'I' as a generic loop variable, and the funny thing is... ALMOST EVERYONE I KNOW DOES TOO. I first realized in HS that the teacher and everyone in the class was using 'I' as the loop variable. It almost never had any other meaning. Then when I finally took FORTRAN, I discovered a possible reason. I've never seen it documented anywhere, so I was wondering if my conjecture was right. Any opinions? (*IF* you are lucky enough not to have programmed in FORTRAN at any time, it's loops were only allowed to be done with INTEGER variables, and it's INTEGERS were hardcoded. I believe 'I' was the first integer, tho I don't remember too well after some 6+ years... It's interesting to note, also, that the standard structure that I've seen people go through is 'I', then 'J', then ofttimes to 'T'. Why? I dunno! <Grin> As for the person who screamed about 'C' programmers using 'i' in for loops, I've found that it makes it Real Clear(tm) that that is nothing more than an incremental loop counter. -- Morgan Schweers +----- Yeah, my programs for my boss have 'for(i' in them, what about it? ;-) -- mrs@netcom.com -----+
barmar@think.com (Barry Margolin) (04/29/91)
In article <1991Apr26.034205.27308@netcom.COM> mrs@netcom.COM (Morgan Schweers) writes: > Can someone confirm (preferably in a post, so my MBX doesn't flood) >the truth/falsity of FORTRAN being the starter of 'I' as a generic loop >variable? I assume Fortran programmers used it because mathematicians used it. Take a look at most math books, and you'll see things like: n ----- \ \ > formula using i / / ----- i=0 Translated into Fortran, this is DO 10 I = 0,100 statements using I 10 CONTINUE Mathematicians seem to use only single-character names for things, making extensive use of fonts, case and alphabetic ranges to denote categories. i, j, and k are integral indexes; m and n are index limits; a, b, and c are coefficiants; x, y, and z are real variables, C and K are constants; etc. The original programmers were mathematicians, so it's not surprising that they continued to use the same conventions. > Then when I finally took FORTRAN, I discovered a possible reason. I've >never seen it documented anywhere, so I was wondering if my conjecture was >right. Any opinions? (*IF* you are lucky enough not to have programmed >in FORTRAN at any time, it's loops were only allowed to be done with >INTEGER variables, and it's INTEGERS were hardcoded. I believe 'I' was >the first integer, tho I don't remember too well after some 6+ years... Actually, the rule was that by default, any variable whose name begins with I through N (I think N was the last) is an integer, and the rest are reals. Declarations are permitted to override this default for a particular variable, and the IMPLICIT statement can be used to change the default rule. > It's interesting to note, also, that the standard structure that I've >seen people go through is 'I', then 'J', then ofttimes to 'T'. Why? I usually see K used after J. Again, this just mimics what mathematicians do. I've always assumed that I is the default index because it is the initial of the word "index". -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar
cok@islsun.Kodak.COM (David Cok) (04/29/91)
In article <1991Apr26.034205.27308@netcom.COM> mrs@netcom.COM (Morgan Schweers) writes: >Greetings, > Can someone confirm (preferably in a post, so my MBX doesn't flood) >the truth/falsity of FORTRAN being the starter of 'I' as a generic loop >variable? The use of i as an index comes from conventional use in mathematics, not from programming languages. FORTRAN convention simply reflected that. David R. Cok Eastman Kodak Company cok@Kodak.COM
rh@smds.UUCP (Richard Harter) (04/29/91)
In article <1991Apr26.034205.27308@netcom.COM>, mrs@netcom.COM (Morgan Schweers) writes: > Greetings, > Can someone confirm (preferably in a post, so my MBX doesn't flood) > the truth/falsity of FORTRAN being the starter of 'I' as a generic loop > variable? FALSE, er, make that false, no 0, no, well anyway, you know what I mean. It's mathematical usage and has been for ages and ages. Letters i,j,k for indices in summation and product formulas, and m and n for ranges. Back in the olden days when computers were used for computing (instead of running microwave ovens and serving as crosses between TV's and typewriters) they were programmed by mathematicians and engineers. They set a trend that has been enshrined in universal habit. -- Richard Harter, Software Maintenance and Development Systems, Inc. Net address: jjmhome!smds!rh Phone: 508-369-7398 US Mail: SMDS Inc., PO Box 555, Concord MA 01742 This sentence no verb. This sentence short. This signature done.
wdr@wang.com (William Ricker) (04/29/91)
[Followup to Alt.Folklore.Computers, please!] mrs@netcom.COM (Morgan Schweers) writes: >Greetings, > Can someone confirm (preferably in a post, so my MBX doesn't flood) >the truth/falsity of FORTRAN being the starter of 'I' as a generic loop >variable? Fortran is indubitubly the first major highlevel language in which I was the generic loop index variable, since it was the first major HOL. 'I' was used in this context because it was the traditional index variable for vectors and matrices in mathematics/physics/etc. before computers, and thus was used, I'd be sure, in the pseudo-code written out for the machine-language coders in the pre-fortran Bad Old Days, just as it was in the give-it-to-a-room-full-of-frieden days and the dip-pen-and-foolscap days. The use of 'I' did not arise from fortran declaring it to be integer, but rather Fortran reserved I-N (or was it O?) for integer variables by default because that approximated existing usage in the domain of FORmulae that FORTRAN was to TRANslate into machine-language without the intervention of programers (who in those days hand-translated formulae into assembley and thence to ML, unless that step was performed by a lower assistant, the Coder). -- /s/ Bill Ricker wdr@wang.wang.com "The Freedom of the Press belongs to those who own one." *** Warning: This account is not authorized to express opinions. ***
dc@sci.UUCP (D. C. Sessions) (04/30/91)
In article <1991Apr26.034205.27308@netcom.COM> mrs@netcom.COM (Morgan Schweers) writes: >Greetings, > Can someone confirm (preferably in a post, so my MBX doesn't flood) >the truth/falsity of FORTRAN being the starter of 'I' as a generic loop >variable? You have it backwards. Mathematicians have used 'i', 'j', 'k', etc. for 'index' expressions since Newton (or so). I have seen some *old* math texts from before Von Neuman was a freshman, and summations across a range indexed by 'i' are all over the place. FORTRAN just adopted the prevailing mathematical notation. Recall that In The Beginning (tm) almost all integer arithmetic was for array indexing and similar housekeeping, and the default of 'i'..'n' makes sense. -- | The above opinions may not be original, but they are mine and mine alone. | | "While it may not be for you to complete the task, | | neither are you free to refrain from it." | +-=-=- (I wish this _was_ original!) D. C. Sessions -=-=-+
sabbagh@acf5.NYU.EDU (sabbagh) (05/01/91)
mrs@netcom.COM (Morgan Schweers) writes: > Then when I finally took FORTRAN, I discovered a possible reason. I've >never seen it documented anywhere, so I was wondering if my conjecture was >right. Any opinions? (*IF* you are lucky enough not to have programmed >in FORTRAN at any time, it's loops were only allowed to be done with >INTEGER variables, and it's INTEGERS were hardcoded. I believe 'I' was >the first integer, tho I don't remember too well after some 6+ years... This is correct for old FORTRANs (I believe WATFOR, FORTRAN IV, etc.) i.e., that DO loop counters could only be integer variables. Also, FORTAN uses *implied typing*; you don't have to declare the types of your variables. The convention is the variable names beginning with the letters I through N are integer, all the rest are reals. This is quite out of date now since there is character, logical, complex and double precision types supported. > It's interesting to note, also, that the standard structure that I've >seen people go through is 'I', then 'J', then ofttimes to 'T'. Why? >I dunno! <Grin> > > As for the person who screamed about 'C' programmers using 'i' in for >loops, I've found that it makes it Real Clear(tm) that that is nothing more >than an incremental loop counter. > -- Morgan Schweers It should be noted that FORTRAN started out as a language for mathematicians and scientists. They are still the largest users of that language. In mathematics, letters like I,J,K, etc., are often used as subscripts (except when I is used to represent sqrt(-1)) so that is the rationale for the language design. In many ways, it is still the best language for scientific use. Hadil G. Sabbagh E-mail: sabbagh@cs.nyu.edu Voice: (212) 998-3125 Snail: Courant Institute of Math. Sci. 251 Mercer St. New York,NY 10012 "Injustice anywhere is a threat to justice everywhere." - Martin Luther King, Jr. Disclaimer: This is not a disclaimer.
atekant@wimsey.bc.ca (Argun Tekant) (05/07/91)
>mrs@netcom.COM (Morgan Schweers) writes: > > Then when I finally took FORTRAN, I discovered a possible reason. I've >never seen it documented anywhere, so I was wondering if my conjecture was >right. Any opinions? (*IF* you are lucky enough not to have programmed >in FORTRAN at any time, it's loops were only allowed to be done with >INTEGER variables, and it's INTEGERS were hardcoded. I believe 'I' was >the first integer, tho I don't remember too well after some 6+ years... But there was a good reason for FORTRAN to use I & onwards for interegers which has nothing to do with mathematics. The first computer FORTRAN was implemented on (the name misses me) had 16 registers. The first 8 (registers A to H) were real number registers the rest (starting from register I) were integer registers. You could only have as many variables as your registers, and those were named A,B,C,..... . Hence the reason why I is an integer. And you can finish the story. QED. Argun.
diamond@jit533.swstokyo.dec.com (Norman Diamond) (05/07/91)
In article <1991Apr26.034205.27308@netcom.COM> mrs@netcom.COM (Morgan Schweers) writes: > As for the person who screamed about 'C' programmers using 'i' in for >loops, I've found that it makes it Real Clear(tm) that that is nothing more >than an incremental loop counter. If you use a more descriptive name, then the loop can say WHAT it's counting and thereby ease the burden on "countless" maintenance programmers. -- Norman Diamond diamond@tkov50.enet.dec.com If this were the company's opinion, I wouldn't be allowed to post it.
rockwell@socrates.umd.edu (Raul Rockwell) (05/07/91)
Morgan Schweers: > As for the person who screamed about 'C' programmers using 'i' >in for loops, I've found that it makes it Real Clear(tm) that that >is nothing more than an incremental loop counter. Norman Diamond: If you use a more descriptive name, then the loop can say WHAT it's counting and thereby ease the burden on "countless" maintenance programmers. Seems to me that WHAT it's counting is best determined by looking at where the loop starts and stops. (Unless maybe you've got a tremendously large loop body, and the loop header is going to be several pages back from where you use the counter.) Raul Rockwell
ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (05/14/91)
In article <1991May06.205831.7025@wimsey.bc.ca>, atekant@wimsey.bc.ca (Argun Tekant) writes: > But there was a good reason for FORTRAN to use I & onwards for interegers > which has nothing to do with mathematics. > The first computer FORTRAN was implemented on (the name misses me) > had 16 registers. The first 8 (registers A to H) were real number > registers the rest (starting from register I) were integer registers. > You could only have as many variables as your registers, and those were > named A,B,C,..... . Hmm. I thought Fortran became available on the IBM 650. This description is false of the 650. If it was the 709, the description is false of that machine too. Certainly the claim that you could have only as many variables as you had registers is not at all true of the first published description of Fortran. Fortran was, after all, designed to _hide_ the hardware. What's more, didn't Fortran I distinguish floating-point functions by means of a *trailing* F? The mnemonic I was taught _may_ have something to do with it: look at the first two letters of the word "INteger". -- There is no such thing as a balanced ecology; ecosystems are chaotic.
doug@netcom.COM (Doug Merritt) (05/23/91)
In article <5758@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: >In article <1991May06.205831.7025@wimsey.bc.ca>, atekant@wimsey.bc.ca (Argun Tekant) writes: >> But there was a good reason for FORTRAN to use I & onwards for interegers >> which has nothing to do with mathematics. [ machine-specific guesses >> deleted...] > >The mnemonic I was taught _may_ have something to do with it: >look at the first two letters of the word "INteger". Fortran a-h is real and i,j,k (at least) are integer because of long mathematical practice. I,j,k are universally used as subscripts and therefore integer, a,b,c,etc are real and therefore floating point. This motivation is well known, there's no need to speculate. (Sorry if this repeats a now-expired article.) Doug -- Doug Merritt doug@netcom.com apple!netcom!doug