Is C faster than fortran?

Discussion in 'C Programming' started by Nomad.C, Mar 26, 2007.

  1. Nomad.C

    Nomad.C Guest

    Hi
    I've been thinking of learning Fortran as number crunching kinda
    language for my Physics degree......but then looking around the
    internet, people are saying that the libraries/ Algorithms once used
    for number crunching is now slowly converting into C, so do you think
    I should stick with C, since I know C already, or should I proceed
    learning fortran??

    Any advice??
    Thanks
    Chris
     
    Nomad.C, Mar 26, 2007
    #1
    1. Advertisements

  2. This is a bit off topic, but:

    There was a thread on the perceived merits of Fortran for scientific
    programming in comp.fortran this month in which various parties gave
    their views. I posted a summary there and in comp.lang.misc. You could
    google for the latter - the title was "The merits of fortran" and the
    date was March 14 this annum.

    Briefly, though, Fortran is often faster for number crunching and is
    probably a more pleasant language to use for that purpose. Besides it's
    always worthwhile learning another language. If you do tackle it,learn
    Fortran 95 - the older versions are, ah, antique.
     
    Richard Harter, Mar 26, 2007
    #2
    1. Advertisements

  3. Nomad.C

    Chris Torek Guest

    Learning additional computer languages is often good. Note (as
    someone else did) that there are lots of different versions of
    Fortran, though. The current standard is F95.

    As for the question in the "subject" line, "is C faster than
    fortran?": the answer is the same as the answer to the question,
    "is chocolate ice cream tastier than strawberry?".
     
    Chris Torek, Mar 26, 2007
    #3
  4. Chris Torek said:

    And of course the answer depends on the quality of the chocolate and
    whether real strawberries are used. It's actually getting quite
    difficult to find strawberry-*flavoured* ice cream in UK supermarkets,
    let alone ice cream made with actual strawberries.

    Using this reasoning, I am forced to the inevitable conclusion that C is
    faster, except when it isn't.
     
    Richard Heathfield, Mar 26, 2007
    #4
  5. Nomad.C

    Nelu Guest

    I work 3 miles away from Ben & Jerry's original factory. They'll have
    their annual Free Cone Day in April or May. Care to taste some
    Strawberry Cheesecake Icecream? You can also visit Canada, it's two
    hours away :)).
    GSL is a nice topping...
     
    Nelu, Mar 26, 2007
    #5
  6. Nomad.C

    user923005 Guest

    The two main competitors here are C++ and Fortran. Fortran has been
    discussed elsethread.
    See also (for instance):
    http://portal.acm.org/citation.cfm?id=615718
    http://www.oonumerics.org/oon/

    Of course, you can do high performance work in other languages and C
    is not an exception.
     
    user923005, Mar 26, 2007
    #6
  7. Those are both c++ links. The time you lose there is not during execution,
    but development. Their standard is significantly thornier than is C's.
     
    Lane Straatman, Mar 26, 2007
    #7
  8. It is a lot easier to build an optimising Fortran 77 compiler than an
    optimising C compiler, largely because of the aliasing problem, but also
    because call by reference eliminates a lot of overhead.

    I have spent far too much of my time translating Fortan 77 programs to C,
    because although the Fortran will crunch the numbers faster, it is much
    harder to make algorithmic improvements. Then of course I have nearly twenty
    years' experince with C as opposed to one and a half with Fortran.

    However if you are going to do serious physics-based programming you will
    have to learn Fortran some time. You can't always choose the language to
    program in, for lots of reasons, technical and social.
     
    Malcolm McLean, Mar 26, 2007
    #8
  9. But the answer to that is obviously "yes", so I don't see how it
    applies.

    -- Richard
     
    Richard Tobin, Mar 26, 2007
    #9
  10. The question would seem to be regional. Chris Torek, IIRC, lives in
    cream-based Valley, with Cream of Weber and Aggie Ice Cream.
    You can't overlook the portability of Italian ice cream in Europe. It is
    not cream-based and, in many persons' informed opinion, tastier. As a
    consequence, these people ingest fewer calories and are therefore quicker to
    the street vendors than their American counterparts.
    How would I put "ice cream" in an array, run through the letters as chars,
    and have an integer tab to represent their total?
     
    Lane Straatman, Mar 26, 2007
    #10
  11. There's the rub. If you're in the math or physics communities, you're not
    going to get very far without at least _learning_ FORTAN. That's what a lot
    of the existing code (which you'll want to modify or reuse) is going to be
    in, and it may be all many of your associates know. The academic world
    thrives on sharing with your peers, and if you aren't using the same
    language as the people you need to share with, you're going to have a harder
    time solving your problems.

    When in Rome, do as the Romans do.

    (Note that the above has absolutely nothing to do with technical reasons to
    use one or the other or their relative speeds. You're probably better off
    asking in comp.lang.fortran for that kind of stuff.)

    S
     
    Stephen Sprunk, Mar 26, 2007
    #11
  12. Nomad.C

    SM Ryan Guest

    # Hi
    # I've been thinking of learning Fortran as number crunching kinda
    # language for my Physics degree......but then looking around the
    # internet, people are saying that the libraries/ Algorithms once used
    # for number crunching is now slowly converting into C, so do you think
    # I should stick with C, since I know C already, or should I proceed
    # learning fortran??

    Fortran is designed to simplify optimisers; it has more potential
    for running faster. What the compiler actually does is another matter.
     
    SM Ryan, Mar 26, 2007
    #12
  13. Nomad.C

    user923005 Guest

    That is true, of course. However, I am not aware of any recent C work
    for high performance numeric computation. Hence my comment "The two
    main competitors here are C++ and Fortran."

    A bugaboo when porting from Fortran to C (and vice versa):
    The row/column access order that is optimal in one language is not in
    the other.
    So if you port a program from one language to another, there are
    always lots of manual steps if you want it to run fast when you are
    done.
     
    user923005, Mar 26, 2007
    #13
  14. Nomad.C

    CBFalconer Guest

    Do it soon. Bush's inane passport moves are going to virtually cut
    off international travel unless somebody rapidly gains sanity.
    This will probably also reduce the viability of the Burlington
    economic area. It's going to play hell with Calais ME.

    (Note for other nationalities - the areas involved are Burlington
    VT. USA and Montreal PQ Canada. All accessible by ship, Atlantic,
    St. Lawrence, and Richelieu/Lake Champlain for Burlington.)
     
    CBFalconer, Mar 27, 2007
    #14
  15. Nomad.C

    CBFalconer Guest

    You forgot to bang your yes.
     
    CBFalconer, Mar 27, 2007
    #15
  16. Nomad.C

    Tim Prince Guest

    Did you ever hear of C99? Most of the performance features are
    implemented in current compilers. Much as I hate to admit it, this puts
    C at least even with Fortran in respect of availability of compilers
    supporting latest standard features.
    Back in the early days of C, there were plenty of automatic tools, both
    commercial and open source. f2c may be as antiquated as C89, but it
    avoids performance snafus on translation of Fortran array syntax.
     
    Tim Prince, Mar 27, 2007
    #16
  17. The Bush policy is solid in this respect. What I wouldn't give to see our
    secretary of state affirm this instead of prattle on with her Pollyanna Iraq
    crappola.
     
    Lane Straatman, Mar 27, 2007
    #17
  18. Nomad.C

    Nelu Guest

    I am not a US resident so I need a Canadian VISA on my passport
    anyway... and it's up from $75 to $100 right now, I believe. But let
    me know if you happen to visit the Stowe - Waterbury area.

    .... and stop with the politics. Everyone is a liberal in VT and I'm
    growing tired of it :)) (Oh, it's also OT).
     
    Nelu, Mar 27, 2007
    #18
  19. Nomad.C

    Nelu Guest

    I am not a US resident so I need a Canadian VISA on my passport
    anyway... and it's up from $75 to $100 right now, I believe. But let
    me know if you happen to visit the Stowe - Waterbury area.

    .... and stop with the politics. Everyone is a liberal in VT and I'm
    growing tired of it :)) (Oh, it's also OT).
     
    Nelu, Mar 27, 2007
    #19
  20. Nomad.C

    Al Balmer Guest

    [OT}
    Is there some reason you aren't eligible for a passport? IMO, this
    should have been done years ago. BTW, Bush is also lobbying to add 22
    more countries to the visa waiver program, which certainly won't hurt
    international travel.
    [OT]
     
    Al Balmer, Mar 27, 2007
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.