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

Transitioning from Java to C

  1. Sep 3, 2009 #1

    I'm selecting courses for University right now. I have two options for my computer programming course. I can selected either two programming classes (one fall, one winter) that is designed for beginners with no prior programming experience or I can selected just one class (which is an accelerated class that combines the two) and have one less class during my winter semester. Both choices begin with the C programming language and moves onto C++ language except one does everything faster. I've taken Java for a year and a half so I'm wondering if the transition to C++ would be difficult.

    Thanks for any help that you can provide
  2. jcsd
  3. Sep 3, 2009 #2
    The higher level features of C++ are not as user-friendly as in Java -- in particular you will need to learn how to structure your code so that it does not contain circular dependencies, and learn how to manage your own memory without garbage collection. There are also some more complexities with inheritance.

    C++ does not pressure you to use object oriented concepts, but you can if you want. The standard library provided by C++ is not nearly as comprehensive as Java, and there are usually a multitude of alternative options for doing anything...or sometimes there is no built in way to do commonly needed things. This can cause a beginner to waste a lot of time early on by trying to re-implement things or not choosing the best tool for the job.

    Because C++ offers so much freedom, a C++ program could be as simple as a C program...lacking in high level features, or with template meta programming it can get extremely complicated. Template meta programming is the primary advantage of C++, and will take many years of experimentation and frustration to master.

    As a result of the complexity of C++, you will be hard pressed to find a program written by anyone that cannot be criticized in a million different ways. This is because it does take many years to fully master, and everyone has their own opinions about what is the right way to do something.

    On the one hand it can be frustrating because you have to continually look back on code you previously wrote in disgust in light of the new revelations you will have invariably learned since you wrote the old code, but on the other hand this means your code is always improving in terms of style and efficiency...and the only limits to your program's performance are your machine and your knowledge, unlike Java where you don't have so much control and your code is executed through the JVM.
  4. Sep 7, 2009 #3


    User Avatar
    Gold Member

    Even if you are a very good Java programmer, most folks can expect the transition to C or C++ to be rough. So I would take the course that go slower. C and C++ have pointers and no automatic garbage collection; this causes much more difficulty than one has in Java. People who have only seen Java before often get really frustrated when they find out what it's like. I like to say, it's like walking on a tightrope with no net (in C or C++) because it is quite easy and common for programs to fail silently, apparently intermittently, or with little realistic indication of what went wrong. So unless you have a very firm understanding of what is going on in the computer's memory, programming in C or C++ will take a while to master.

    I would recommend that you take a beginning computer architecture class before taking C programming if at all possible. Things may make a lot more sense if you do.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook