Click here to Skip to main content

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: for(int i=0; i<size; i++)memberMember 46088983 May '13 - 19:46 
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.
GeneralRe: for(int i=0; i<size; i++)memberAmarnath S29 Apr '13 - 23:48 
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#.
GeneralRe: for(int i=0; i<size; i++)memberRosenne30 Apr '13 - 20:18 
AFAIK it started with the first FORTRAN - there were no type declarations then.
 
See https://en.wikipedia.org/wiki/Fortran#FORTRAN[^]
GeneralRe: for(int i=0; i<size; i++)membergreldak30 Apr '13 - 21:47 
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.
GeneralRe: for(int i=0; i<size; i++)memberdg6yhw111 May '13 - 5:32 
Fascinating!
 
I know and still use that convention but had no idea what that particular set of letters was chosen until now.
 
Thanks.
 
Murray
GeneralRe: for(int i=0; i<size; i++)memberdusty_dex30 Apr '13 - 0:26 
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.

GeneralRe: for(int i=0; i<size; i++)professionalPIEBALDconsult30 Apr '13 - 1:56 
I was using i for index before I was introduced to Fortran.
GeneralRe: for(int i=0; i<size; i++)memberjsc4230 Apr '13 - 23:49 
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
GeneralRe: for(int i=0; i<size; i++)professionalPIEBALDconsult2 May '13 - 2:26 
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.
GeneralRe: for(int i=0; i<size; i++)mvpOriginalGriff30 Apr '13 - 3:03 
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 | :laugh:
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid