Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. for(int i=0; i<size; i++)

for(int i=0; i<size; i++)

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpc++javaquestion
67 Posts 44 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P PIEBALDconsult

    But "loop" is a verb. :~

    R Offline
    R Offline
    R Giskard Reventlov
    wrote on last edited by
    #39

    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

    S 1 Reply Last reply
    0
    • G greldak

      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.

      D Offline
      D Offline
      dg6yhw11
      wrote on last edited by
      #40

      Fascinating! I know and still use that convention but had no idea what that particular set of letters was chosen until now. Thanks. Murray

      1 Reply Last reply
      0
      • W WPerkins

        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?

        H Offline
        H Offline
        H Brydon
        wrote on last edited by
        #41

        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

        W 1 Reply Last reply
        0
        • T tumbledDown2earth

          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?

          R Offline
          R Offline
          RafagaX
          wrote on last edited by
          #42

          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...

          1 Reply Last reply
          0
          • H H Brydon

            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

            W Offline
            W Offline
            WPerkins
            wrote on last edited by
            #43

            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.

            1 Reply Last reply
            0
            • R R Giskard Reventlov

              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

              S Offline
              S Offline
              Sentenryu
              wrote on last edited by
              #44

              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.'"

              P R 2 Replies Last reply
              0
              • J jsc42

                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

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #45

                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.

                1 Reply Last reply
                0
                • S Sentenryu

                  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.'"

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #46

                  Exactly. Know your audience. :thumbsup:

                  M 1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    Exactly. Know your audience. :thumbsup:

                    M Offline
                    M Offline
                    Member 9975613
                    wrote on last edited by
                    #47

                    *legacy coder detected* why exactly is "loop" harder to read then "i"? Cant you read? ;)

                    Copy, paste, compile, erase

                    1 Reply Last reply
                    0
                    • T tumbledDown2earth

                      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?

                      C Offline
                      C Offline
                      Carlosian
                      wrote on last edited by
                      #48

                      Yes, as others have said for many it was a carryover from FORTRAN. Nothing formal that I know of, just using i in FORTRAN and then out of habit using it in 'C' as programmers moved over to that and other newer languages.

                      1 Reply Last reply
                      0
                      • S Sentenryu

                        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.'"

                        R Offline
                        R Offline
                        R Giskard Reventlov
                        wrote on last edited by
                        #49

                        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

                        OriginalGriffO 1 Reply Last reply
                        0
                        • R R Giskard Reventlov

                          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

                          OriginalGriffO Offline
                          OriginalGriffO Offline
                          OriginalGriff
                          wrote on last edited by
                          #50

                          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 have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                          S 1 Reply Last reply
                          0
                          • OriginalGriffO OriginalGriff

                            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)

                            S Offline
                            S Offline
                            Sentenryu
                            wrote on last edited by
                            #51

                            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.'"

                            1 Reply Last reply
                            0
                            • T tumbledDown2earth

                              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?

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #52

                              When I first learned about mathematical functions f(x)(a dozen years before my first programming class) I was told mathematicians used "i" for the first incrementing variable, "j" for the next and so on. When I started to learn programming languages, a FORTRAN professor (FORTRAN as in "FORmula TRANslation") who (of course) was a member of the Math department, said something along the lines of "This is not the theology department but using anything other that "I" for the first incremental etc is heresy. Those who want to use 'meaningful words' should consider being English or Philosophy majors and take Professor So-and-So's COBOL class." So, 'I' as an index did not start with FORTRAN, it started before FORTRAN, but it fit nicely because those who used FORTRAN knew its meaning from math studies.

                              R 1 Reply Last reply
                              0
                              • F Freak30

                                When I started I thought it was i for integer.

                                M Offline
                                M Offline
                                Member 4608898
                                wrote on last edited by
                                #53

                                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.

                                1 Reply Last reply
                                0
                                • T tumbledDown2earth

                                  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?

                                  N Offline
                                  N Offline
                                  Nicolas Dorier
                                  wrote on last edited by
                                  #54

                                  Maybe you'll also be interested about the story of the unknow 'x' in math : Explanation on ted talk[^] ;)

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    When I first learned about mathematical functions f(x)(a dozen years before my first programming class) I was told mathematicians used "i" for the first incrementing variable, "j" for the next and so on. When I started to learn programming languages, a FORTRAN professor (FORTRAN as in "FORmula TRANslation") who (of course) was a member of the Math department, said something along the lines of "This is not the theology department but using anything other that "I" for the first incremental etc is heresy. Those who want to use 'meaningful words' should consider being English or Philosophy majors and take Professor So-and-So's COBOL class." So, 'I' as an index did not start with FORTRAN, it started before FORTRAN, but it fit nicely because those who used FORTRAN knew its meaning from math studies.

                                    R Offline
                                    R Offline
                                    robocodeboy
                                    wrote on last edited by
                                    #55

                                    Yes, it is so: i, j and k are standard notation for mathematical arithmetic progressions and series. From well before FORTRAN. But FORTRAN was designed by mathematicians, so we programmers are carrying over the notation. a,b,c -> constants x,y,z -> unknown terms (or real coordinates in cartesian plane) k,j,i -> INTEGER indexes or vector coordinates. I think Gauss was already using this conventions, more than 100 years ago. Gauss wins. As always.

                                    1 Reply Last reply
                                    0
                                    • T tumbledDown2earth

                                      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?

                                      P Offline
                                      P Offline
                                      peterchen
                                      wrote on last edited by
                                      #56

                                      Fortran probably got it from math. Now math... I don't know.

                                      ORDER BY what user wants

                                      1 Reply Last reply
                                      0
                                      • T tumbledDown2earth

                                        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?

                                        D Offline
                                        D Offline
                                        DanielSheets
                                        wrote on last edited by
                                        #57

                                        I've always used 'x'. Why? Because a "Programming in C" book I started with used it. So I just got used to it I guess.

                                        1 Reply Last reply
                                        0
                                        • T tumbledDown2earth

                                          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?

                                          D Offline
                                          D Offline
                                          DerekT P
                                          wrote on last edited by
                                          #58

                                          It was also a feature of some early BASIC implementations. There were 26 variables available; A through H were floating point, I through P (??) were integers; R(??) through Z were also floating point. The only explicit type declarations were to suffix one of the single-letter variables with the $ symbol to indicate string. "I" was commonly used for loop control as being the first integer variable. It's a habit I learned in the 1960s and I still use it (very occasionally). Old habits die hard...

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups