I want to find out how easy or hard the transition to C / C++ is for a mid-experienced Java programmer.

I've already read the questions about "C++ for Java Programmers" and "Is it necessary for Java programmers to learn some C/System programming?".

Everything sounds very interesting, but I want to specifically add the aspect I have experience in Python programming as well. I'm aware that you are able to run python on the JVM with jython, but I think it will provide better experience to get exposed to new concepts and to explore Python's origins. My target environment is mainly Linux.

Could you estimate (perhaps even tell from your own experience) how hard it would be and especially give a hint as to whether it would be better to go with C or C++ in order to interact with Python?

  • 1
    They way I see it, there are two questions being asked here: "How easy is it for a Java programmer to learn C/C++" and "Should I learn C or C++ to best interact with Python". I think the first question is answered by the posts you linked to. I am not sure additional Python knowledge changes the answer much. In my experience with extending Python this is done best in C rather than C++. See the article for details. – PersonalNexus Jan 12 '12 at 17:57
  • 3
    You need to be specific about C or C++. They're very different languages. – DeadMG Jan 12 '12 at 18:33
  • Oh look, another question I would have liked to seen answers to that got closed because... [insert ironically ambiguity-citing form-letter here] – Erik Reppen Jun 14 '13 at 4:15
  • 1
    C will definitely be a culture shock - no garbage collection, primitive text processing toolkit, no language or library support for networking, graphics, sound, almost no generic facilities, no structured exception handling, unspecified expression evaluation order that will bite you in the ass, etc. It's like going from a Prius to a '60s era British roadster; a lot of the driver assistance features you're accustomed to simply aren't there. – John Bode Jul 3 '17 at 12:30

C is a very small language, so any experienced programmer willing to put enough effort and time should be able to become proficient in it in 3 months in my opinion (this includes creating some medium to large projects using the language, or at least studying some created by experienced C programmers).

C++ is a whole different story, though, given its size and complexity of features. I am not that experienced with the language, but I would guess you would need at least one year working with it to say you have a decent grasp of the language, and 3+ years to say you have mastered it.

Considering you are coming from Java I would also not recommend to skip C and jump directly into C++, as you might lose some interesting insights C provides.

As for interacting with Python, I believe C would be easier.

  • 1
    C and C++ are two very different languages, and I don't recommend learning one to facilitate learning the other. I would recommend jumping directly into C++, assuming that it's taught right (some people teach it as C with Classes, which it isn't). – David Thornley Jan 12 '12 at 19:00
  • @David Thornley, I don't recommend learning C to facilitate learning C++, but rather because C itself is worth learning, and if you jump straight into C++ you can't say for sure you know C. – Daniel Scocco Jan 12 '12 at 19:10
  • @daniels: That's fine. There's little, or no, reason to know C instead of C++. It's dead- move on. – DeadMG Jan 12 '12 at 19:16
  • 1
    @daniels: There's reasons to learn C, and (somewhat different) reasons to learn C++. There's no reason to learn one as a steppingstone towards the other one. I don't think there's a good general reason to learn C instead of C++. – David Thornley Jan 12 '12 at 20:40
  • @DeadMG: It's practical to use C when writing code that needs to run on the 25-cent microcontroller in a $2 toy. While some compilers for such processors can accept a C/C++ hybrid, a full C++ implementation would require a more powerful controller, which would in turn cost more. If something sells a million units, every penny saved in manufacturing costs is $10,000 earned. – supercat Feb 13 '14 at 22:45

Since C++ can use C interfaces perfectly well, and C++ offers many very useful additional features (to the point where C's original features are almost completely useless in comparison) there's absolutely no reason to use C instead unless you're trying to compile for a target where no C++ compiler exists.

Now, it's going to be a hard transition. Java and C++ share some syntax, and that's about it. You'll have to become intimately familiar with the god-awful, like the compilation model, and the glorious, like templates.

However, more fundamentally, C++ uses static, strong value typing, whereas Java uses relatively weak reference typing, and there's virtually no such thing as good Java code which is also good C++ code. In addition, C++ programmers are expected to be familiar with a much wider range of techniques, including expression templates, functional interfaces, etc. This makes for a pretty hard trip.

  • +1 - comparison of C++ uses static, strong value typing – Dipan Mehta Jan 12 '12 at 18:53
  • Linus would say otherwise! – Andrew Sep 25 '15 at 20:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.