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 Insider News
  4. What Fortran does better than C-like languages

What Fortran does better than C-like languages

Scheduled Pinned Locked Moved The Insider News
c++javaphpcomquestion
8 Posts 5 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.
  • K Offline
    K Offline
    Kent Sharkey
    wrote on last edited by
    #1

    Craft of Coding[^]:

    C-like languages (C, C++, Java) can do many things, but over the decades nothing much has changed with the inadequacies of some of their control structures.

    Avoid ending lines in semi-colons?

    D J M 4 Replies Last reply
    0
    • K Kent Sharkey

      Craft of Coding[^]:

      C-like languages (C, C++, Java) can do many things, but over the decades nothing much has changed with the inadequacies of some of their control structures.

      Avoid ending lines in semi-colons?

      D Offline
      D Offline
      David ONeil
      wrote on last edited by
      #2

      I remember learning Fortran in college. I also remember disliking having to declare all variables at the top of the routine, and back then everything had indentation requirements (although I never used punch cards). C was a breath of fresh air. And C++ was the monkey's tail!

      Our Forgotten Astronomy | Object Oriented Programming with C++

      M T 2 Replies Last reply
      0
      • K Kent Sharkey

        Craft of Coding[^]:

        C-like languages (C, C++, Java) can do many things, but over the decades nothing much has changed with the inadequacies of some of their control structures.

        Avoid ending lines in semi-colons?

        D Offline
        D Offline
        David ONeil
        wrote on last edited by
        #3

        Also, contrast that to this old article: [On Choosing a Language for the User Client Functions](https://www.msri.org/publications/sgp/jim/software/mesh/desc/lang.html). Trying to figure out if Fortran has the equivalent of virtual functions, and came across it. It seems modern Fortran does have some OO abilities, but did not see the answer to my virtualquestion.

        Our Forgotten Astronomy | Object Oriented Programming with C++

        1 Reply Last reply
        0
        • K Kent Sharkey

          Craft of Coding[^]:

          C-like languages (C, C++, Java) can do many things, but over the decades nothing much has changed with the inadequacies of some of their control structures.

          Avoid ending lines in semi-colons?

          J Offline
          J Offline
          jeron1
          wrote on last edited by
          #4

          I took Fortran after BASIC, to say it was a breath of fresh air would be an enormous understatement! Not dissing BASIC, the instructor I had seemed to encourage the spaghettification of code, to the point of insanity, it was my first programming class and it was painful. I had a math instructor who talked me into taking a Fortran class, wow what a (pleasant) eye opener! This has nothing to do with C or C++, but sometimes I think Fortran gets a bad rap.

          "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

          1 Reply Last reply
          0
          • D David ONeil

            I remember learning Fortran in college. I also remember disliking having to declare all variables at the top of the routine, and back then everything had indentation requirements (although I never used punch cards). C was a breath of fresh air. And C++ was the monkey's tail!

            Our Forgotten Astronomy | Object Oriented Programming with C++

            M Offline
            M Offline
            Marc Clifton
            wrote on last edited by
            #5

            David O'Neil wrote:

            And C++ was the monkey's tail!

            And now the monkey has us by our tail!

            Latest Articles:
            ASP.NET Core Web API: Plugin Controllers and Services

            1 Reply Last reply
            0
            • K Kent Sharkey

              Craft of Coding[^]:

              C-like languages (C, C++, Java) can do many things, but over the decades nothing much has changed with the inadequacies of some of their control structures.

              Avoid ending lines in semi-colons?

              M Offline
              M Offline
              Marc Clifton
              wrote on last edited by
              #6

              Make pretty pixel art on punch cards? And of course you can exit a nested loop!

              try
              {
              for (i=1; i<=10; i=i+1)
              for (j=1; j<=10; j=j+1)
              for (k=1; k<=10; k=k+1)
              if (x[i][j][k] == 0)
              throw new LoopyExit();
              }
              catch(LoopyExit)
              {
              }
              // moving along...

              :laugh: Stunningly, I (and I suspect "we") have all seen this done, but of course not by us! :~

              Latest Articles:
              ASP.NET Core Web API: Plugin Controllers and Services

              D 1 Reply Last reply
              0
              • M Marc Clifton

                Make pretty pixel art on punch cards? And of course you can exit a nested loop!

                try
                {
                for (i=1; i<=10; i=i+1)
                for (j=1; j<=10; j=j+1)
                for (k=1; k<=10; k=k+1)
                if (x[i][j][k] == 0)
                throw new LoopyExit();
                }
                catch(LoopyExit)
                {
                }
                // moving along...

                :laugh: Stunningly, I (and I suspect "we") have all seen this done, but of course not by us! :~

                Latest Articles:
                ASP.NET Core Web API: Plugin Controllers and Services

                D Offline
                D Offline
                David ONeil
                wrote on last edited by
                #7

                I was also tempted to reply something like this:

                Quote:

                In C-like languages exiting from a deeply nested loop isn’t exactly trivial (without the use of goto, so don’t even go there).

                exitloop = 0
                for (i=1; i<=10 && !exitloop; i=i+1) {
                for (j=1; j<=10 && !exitloop; j=j+1) {
                for (k=1; k<=10 && !exitloop; k=k+1) {
                if (x[i][j][k] == 0)
                exitloop = 1;
                }
                }
                }

                Dumb. The dummy actually made a case for goto. So I will.

                for (i=1; i<=10; i=i+1) {
                for (j=1; j<=10; j=j+1) {
                for (k=1; k<=10; k=k+1) {
                if (x[i][j][k] == 0)
                goto exitloop;
                }
                }
                }
                exitloop:
                //do something amazing:

                It is cleaner than his code. Don't be hung up over trivial bullshit, and get the job done. (Not that I would do it this way, but every tool has a use.)

                Our Forgotten Astronomy | Object Oriented Programming with C++

                1 Reply Last reply
                0
                • D David ONeil

                  I remember learning Fortran in college. I also remember disliking having to declare all variables at the top of the routine, and back then everything had indentation requirements (although I never used punch cards). C was a breath of fresh air. And C++ was the monkey's tail!

                  Our Forgotten Astronomy | Object Oriented Programming with C++

                  T Offline
                  T Offline
                  trønderen
                  wrote on last edited by
                  #8

                  David O'Neil wrote:

                  I also remember disliking having to declare all variables at the top of the routine

                  My immediate response is "That can't be Fortran that you are talking about??" Fortran was the language that made me hate implicit declaration of variables. "GOD is real unless declared integer"! (IMPLICIT NONE is the only statement related to implicit declaration that I like.) If you want me to do any programming job in a language with implicitly declared variables, I will demand double pay ... Even Fortran guys have come to their senses nowadays. On the other hand, during the discussions around what to include in Fortran 77, C.A.R Hoare remarked that "I don't know what programming languages will look like in year 2000, but they will be called Fortran. He hit the nail on the head.

                  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