Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Which one [language] next?

  1. Oct 6, 2013 #1
    I have just finished an intro course on Python. As most others, I have the goals of learning Java, C and C++. In what sequence should I learn them? I am inclined on learning Java first as it is a prereq for some courses that I am eager to take. Yet, is it what you would recommend?
    Note: I loved Python(if that would help in choosing which I should take first)
     
  2. jcsd
  3. Oct 6, 2013 #2

    phinds

    User Avatar
    Gold Member

    I suggest C first, as it is the only non-OO language on your list and is the syntactical basis for C++, Java, JavaScript, and other languages.
     
  4. Oct 6, 2013 #3

    jim mcnamara

    User Avatar

    Staff: Mentor

    I would second that suggestion. You also need to remember that in a career you will probably bounce around using different technologies and language frameworks. I started with COBOL and FORTRAN long ago. Now I use C and specialty languages like dtrace.
     
  5. Oct 6, 2013 #4
    Thanks!
     
  6. Oct 7, 2013 #5
    I third that suggestion. Learn C, then learn Java. Good luck.
     
  7. Oct 7, 2013 #6

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    I'm inclined to disagree with that. If you learn enough C to write useful programs, you will have to "unlearn" most of what you learned about pointers to write good C++, and all it to write any kind of Java.

    Just because C came first historically, that doesn't mean it's the place to start learning. Otherwise, why not start teaching 5 year olds Sanskrit and Latin in school, and leave Engiish till later on?
     
  8. Oct 7, 2013 #7

    phinds

    User Avatar
    Gold Member

    I agree w/ you about pointers but that's about the ONLY thing in C that's like that. My point is that it is best to learn the fundamental syntax of a language before you start piling on OO concepts which are a bit complex for beginners. AND, C is the basis for many modern languages.

    Why do you figure so many people agreed w/ my suggestion?
     
  9. Oct 7, 2013 #8
    I agree with Phinds. I learned C and knowing pointers did not slow me down in any way for learning Object Oriented Programming.
     
  10. Oct 7, 2013 #9

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    A different tack: Don't learn to program in another language. Learn to program, period. If you are going to college, almost every college will offer a course (or courses) in algorithms and data structures, and another course (or courses) in numerical methods, and yet another in structured programming. Those classes are worth a whole lot more than learning to program (badly) in yet another language.

    People at this site oftentimes have the mistaken notion that you can learn to program on your own. Yes, you can learn to program badly on your own. It's easy. I see these (non) programmers all the time. You can also learn to program badly by using cargo cult techniques where you follow examples by others who learned to program on their own.

    Can you learn how to program well on your own? Yes, but it's just about as likely as learning general relativity on your own.
     
  11. Oct 7, 2013 #10

    Cod

    User Avatar

    Is there a reason you want to learn another language? Why not go into some more advanced Python before moving on? Python is very robust and offers a lot to the science community via SciPy.

    Also, like D H stated above, learn to program and worry about language specifics second.
     
  12. Oct 8, 2013 #11
    Writing good C++ does not mean ignoring pointers. You have to know what they are, and you have to do your memory management. It is true that many good libraries (and to some extent coding styles and conventions) lessen the burden, but to appreciate their utility and even to choose rationally which one is to be used, one still has to be cognizant of these matters. Creating good C++ libraries, on the other hand, pretty much requires one to embrace all these intricacies.

    More generally, one principal difference between C/C++ and Java (or C#) is that the former works on the "bare metal", giving direct unsafe and unchecked access to memory, and supporting unsafe and unchecked type conversions. Learning and using this trait of the language is essential for mastery of C++; otherwise, there is simply no reason to bother ever studying it, because everything else can be done comfortably with a "safe" language.

    C and C++ are difficult as first languages, because one has to study "basic programming" and the language at the same time. A "Hello, World" program already uses pointers and it gets worse.
     
  13. Oct 8, 2013 #12

    harborsparrow

    User Avatar
    Gold Member

    Whatever language you use, it pays to learn what is really going on in memory. Python, and to some extent Java, try to protect you from needing to know that. But ultimately, it pays to know, especially if you ever need to be concerned about performance. C++ will require you to learn how things are being stored--and more detail than you'll like, so it will take longer to become competent with it. But likewise, in Java (and other object oriented languages) the way the objects consume memory (and their lifetimes in your programs) is very important.

    Good luck! All good languages.
     
  14. Oct 8, 2013 #13

    jedishrfu

    Staff: Mentor

    Or you could consider learning Scala which has been described as a better Java than Java. It has features of scripting languages and forces you to think more about how to do things in OO and in functional programming:

    http://en.wikipedia.org/wiki/Scala_(programming_language)

    The argument for C vs Java just reminds me of the decades old one of C vs Assembler... basically the new generation language versus the old generation language learned by the older generation.
     
  15. Oct 29, 2013 #14
    c# or java/scalar then c++
     
  16. Oct 29, 2013 #15
    C is still used for systems software and hardware drivers. Even if that may not interest you, there is still lots of existing C code that one may need to interact with, particularly libraries. Sometimes you can get away without actually writing C code (by using ctypes, cython, or other helpers), but you still need to understand C code.
     
  17. Oct 29, 2013 #16
    Why learn C if C++ exists? Not to be obnoxious or malicious...
     
  18. Oct 29, 2013 #17

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    If you want an obnoxious answer, ask Linus Torvalds.

    For a less obnoxious answer, C and C++ are very different languages that have some superficial similarities. It takes at least a year, and often two or more years, for a proficient C programmer to become proficient in C++. It's a hard transition. It takes even longer for a proficient C++ programmer to become a proficient C programmer. Going from C++ to C is even harder than going from C to C++.
     
  19. Oct 29, 2013 #18
    For most intents and purposes C can do anything C++ can do, considering that he's doing it for a hobby(I think). and C++ is easier than C as it shares more similarities with the other languages (I dunno about pythn have only done super simple calculating things in it.)
     
  20. Oct 29, 2013 #19
    C can do anything any other language do. So can C++. So can many other languages. This is mot a property that makes a lot of difference these days.
     
  21. Oct 29, 2013 #20
    But if c++ is easier and more widely used don't you think that's what he should learn?
     
  22. Oct 29, 2013 #21

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    The original poster has already learned one object oriented language, python. C++ is just another object oriented language. It's a good idea to learn a language from different paradigm rather than relearn one from the same paradigm. Switching paradigms forces a change in how one thinks. C is not object oriented. It's a procedural language. Another very different choice would be to learn a functional language. An example is Scala, mentioned in post #13. Others in this vein include the Lisp family of languages and Haskell.
     
  23. Oct 29, 2013 #22
    Okay I get your angle but then shouldn't he learn vbs or a scripting language? it'll give him the nessacary perpective and wont take long. If he actually wants to program something efficient he should use a OOL.

    Order of my languages : batch->vbs->java->Delphi->c#->c++(learning) but I have seen code exerpts form c and other languages.

    Never learn Delphi btw it's terrible. Programmers call it and I quote "a waste of brain space" I only learnt it because we had to at high school.
     
    Last edited by a moderator: Oct 31, 2013
  24. Oct 29, 2013 #23
    C++ is not a replacement for C. It didn't make C obsolete.

    C++ is not "easier" than C. It adds a huge amount of complex syntax. There is a lot of poor ad hoc design in the language. And after all that, you don't even get automatic memory management.

    And it's certainly not more common than C.
     
    Last edited: Oct 29, 2013
  25. Oct 29, 2013 #24

    Mark44

    Staff: Mentor

    How do you implement classes and inheritance, for example, in C? Or polymorphism, or friend relationships between classes, or ...?

    Given that C++ is a much larger language than C, in terms of keywords and concepts, I don't see how you can possibly say that C++ is easier than C. And it's debatable that C++ is more widely used than C.
     
  26. Oct 30, 2013 #25

    harborsparrow

    User Avatar
    Gold Member

    C++ is a superset of C. What was added was object-oriented capabilities; however, the inclusion of multiple inheritance, combined with the high risk of memory leaks, makes C++ a troublesome object-oriented programming language at best. Thus, when implementing an object-oriented design, many programmers prefer to use more modern OO languages such as Java or C#.

    Also, C++ is a very large language, with an extremely extensive set of libraries, and they can be quite complex. Thus, very few programmers truly "know C++". Instead, they have "used a small portion" of C++. For this reason, good C++ programmers tend to specialize specifically in C++ because it is such a large language with an extensive learning curve. In the past when I needed a component to be written in C++, I tended to farm it out to an expert who does C++ all the time, rather than attempt it myself.

    You need to learn about memory management and memory usage in either C or C++--because the issues there are the same, whether you use the additional capabilities and libraries of C++ or not. And also, you need to learn how to do good object-oriented programming. But IMO (and the opinion of many computer scientists), it is not desirable to create many new OO designs in C++ if you can, instead, use one of the improved languages. Even if you need libraries already written in C++, those can be called from the newer languages (assuming you really know what you are doing).
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook