1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C or C++

  1. Jun 25, 2011 #1
    Which one is better for a physics/astrophysics major? I will be taking Fortran as well.
     
  2. jcsd
  3. Jun 25, 2011 #2
    I got the advice to learn C++ from a postdoc, but he gave no particular reason for that other than he'll be using it for dataselection. I don't know what is suitable for simulations.

    A friend of mine used Fortran for his thesis where he modeled airflow in windmillparks.
     
  4. Jun 25, 2011 #3
    C+=2 is my personal favorite.

    But really, C++. Very few scenarios where you actually need C and I doubt, being a physicist, that you will be doing much systems programming.
     
  5. Jun 25, 2011 #4

    Astronuc

    User Avatar

    Staff: Mentor

    C++ and Fortran is a good combination. Knowledge of basic C is useful.

    In scientific programming, there seems to be two schools - proponents of C++ and proponents for Fortran. I think the Fortran school represents legacy programmers (old-timers).
     
  6. Jun 25, 2011 #5

    Borek

    User Avatar

    Staff: Mentor

    Downgrading from C++ to C is probably easier than upgrading from C to C++.
     
  7. Jun 25, 2011 #6
    I'm not too sure how it works in the physics world, but in finance C is outdated and no one really uses it anymore. Hope that helps.
     
  8. Jun 25, 2011 #7

    phinds

    User Avatar
    Gold Member
    2016 Award

    C is the basis for C++. C is not object oriented, C++ CAN be object oriented, or you can just use C and say that you are using C++. If you want a language that forces you to be object oriented whether you like it or not, go with JAVA.

    I think C++ is best and what follows from Borek's statement is that if you learn C++, you will then already know C it's just that if you then want to program in C, you'll have to remember that you can't use any of the object oriented methodologies.
     
  9. Jun 25, 2011 #8
    Cool! Thanks eXorikos
    Thank you so much PhDorBust
    Thanks a zillion Astronuc
    lol Thanks Borek
    Yes this is helpful, thank you very much.
    Thanks so much phinds, this is very helpful! I take it then that once one has taken C++, one will also know C from what you have said here. We worked with Java in intro programming, but of course it wasn't exhaustive.

    I appreciate your response everyone! I will take C++.
     
  10. Jun 25, 2011 #9

    phinds

    User Avatar
    Gold Member
    2016 Award

    Yeah, the fundamental underlying language of C++ is just plain old C, so you don't have any choice but to learn C on the way to C++, but C++ overlays all kinds of cool capabilities based on making it object oriented. You don't always need them but when you DO need them, there just isn't any substitue in basic C.
     
  11. Jun 25, 2011 #10

    Borek

    User Avatar

    Staff: Mentor

    Yes. The only problem is to learn which parts of what you know you have to forget.
     
  12. Jun 25, 2011 #11
    In my experience, this is much harder than it sounds.
     
  13. Jun 25, 2011 #12

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor

    Personally, I think it is much better to know how to program than any (or many) particular language(s). I know people who can program badly in many languages.
     
  14. Jun 25, 2011 #13

    Borek

    User Avatar

    Staff: Mentor

    Count me in. While I have learned to not use goto back in eighties, I am afraid most of my code has nothing to do with languages I am using. I bogged down somewhere between Pascal and C++.
     
  15. Jun 25, 2011 #14

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor

    As they say, some people can write FORTRAN in any language.
     
  16. Jun 26, 2011 #15
    Thanks again phinds. For some reason my school is not offering C++ in the Fall. There is only C, C#, and Object Oriented Programming with Java. They had it in the Spring, but not in the summer, and I thought they would have it for Fall. I'm not sure why they are not offering it.
    @_@
    I am asking because I did intro to comp programming last semester, and the only other courses being offered are language courses and object oriented programming with Java :/ I just found out there is no C++. I was also wondering because some fields use some languages more than others, so I was wondering which is best for the field I want to go into.
     
  17. Jun 26, 2011 #16
    C++ is also object oriented, so Java might be a good idea. Object oriented programming is something totally different from other languages.

    Learning C has the advantage of learning how to manage your memory you use. Java does this automatically, but C++ doesn't.
     
  18. Jun 26, 2011 #17

    bcrowell

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    The argument against C++ is that it's simply a bad language. The reason it's a bad language is that they tried too hard to maintain backward compatibility with C. C is actually quite a nice language; it's a simple tool specialized for certain specific jobs.

    More global advice for science grad students: don't waste your time learning lots of computer languages or doing lots of coding. Spend your time doing science.
     
  19. Jun 26, 2011 #18
    Thanks eXorikos! I'm all confused now...so sorry if this is overkill...Do you think I should do both C and object oriented with Java? Maybe it's not necessary to take all these classes, and I can take the OOP w/Java and learn C++ by other means? I wonder if it is necessary to take the course to "prove" that you have learned it.
     
  20. Jun 26, 2011 #19
    Thanks Ben.
     
  21. Jun 26, 2011 #20
    If you take one programming course that will be sufficient and it doesn't matter what language. It's impossible to learn every language. You'll learn other languages if you should ever need them. Basic programming skills is what you need, not syntax.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: C or C++
  1. Retaking a C (Replies: 6)

  2. Thoughts on C++ (Replies: 15)

  3. Help! Ap physics c (Replies: 8)

  4. Physics A, B or C (Replies: 5)

Loading...