I am a Hobbyist Java programmer and I would like to further my programming skills by learning C or C++ and Python.

I have read many C vs C++ articles but none of them contain the information I'm looking for.

I would like to know if it is better to learn C or C++. In most articles I read most people recommend C++ saying that it is better because it is OO and is easier to write GUIs in or they don't recommend C saying that you will learn bad FO habits.

But I can program in Java which is OO so the FO habits won't stick. As for the GUI, I think python might be better suited at handling that.

I would also like to know which is better for python. i.e. which works more well with python or which runs faster with python etc.

Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.
If this question can be reworded to fit the rules in the help center, please edit the question.

3

Site FAQ : and it is not about… what language you should learn next
–
vivekJan 7 '12 at 22:02

9 Answers
9

You know a OOP language already and if you want to learn as hobbyist C will keep you more interested. You can learn C++ any time you want. Also learning C might give you better idea of internal working of Linux machine that you may delve into being a hobbyist programmer.

As for what language is better. It would be bad question and possibly worst answer if I choose
any. They both are adept at doing what they do.

There is much more to C++ than "C with object-orientation(OO)". In fact, I think the OO isn't very important! Given a choice between Java and C++-without-OO, I would take C++-without-OO. I like all the other non-OO stuff that C++ has that Java doesn't have. "You know a OOP language already" and "You can learn C++ any time you want" imply that C++ and Java are more similar than they are.
–
Aaron McDaidJan 7 '12 at 23:55

2

The point here was that C++ is definitely closer to Java than C. So to have a fresh perspective I recommended C. I agree C++ is very different from Java. If C++ would have been Java, Java wouldn't have been there.
–
ExpressionsJan 8 '12 at 6:37

Ok, the correct answer is: "It depends", mostly on what you want to do.

From the sounds of it you want to "improve your programming skills", what do you mean by this?

If you mean you want to find good tools to get stuff done, and solve problems or do something fun/useful, you should choose Python for higher level stuff. Don't worry about performance so much as you can always optimize it later.

Python is a joy to program with as you don't need to worry about much of the cruft in other languages and typically can focus on the application logic itself. Python will mainly improve your programming skills in the area of designing/implementing an entire application, OO concepts, and functional concepts as well as introduce a lot of syntactic sugar. I recommend running import this to get an idea of what the Python community is about. Python is a different mindset from Java, one where the programmer is treated as an adult that knows what they are doing. There are very little arbitrary decisions made for you. Python typically has chosen the simplest/easiest to understand solution for the problems any language needs to solve. It remains very explicit relative to other scripting languages, so it's very easy to comprehend and read once you get past the syntax difference between it and Java/C/C++. Python also has bindings to many of the C/C++ libraries/APIs.

If you want to see why Java was created you can code in C++ :). I really cannot think of a good use case for C++ that doesn't involve a bunch of pre-existing C++ programmers or a great C++ library/api (ie. http://qt.nokia.com/products/). I personally consider it one of the most complicated programming languages there is. However, if your goal is simply to learn, it's a pretty darn good language for that, as there a lot of problems to solve and things to know to get your code working well.

C is a great language for learning for many of the same reasons as C++, but the language itself isn't nearly as complicated. C and C's concepts are everywhere. C compliments Python, Java, AND C++ so for a pure learning experience, I would recommend C over any of them. Memory management and pointers are critical concepts to fully grasp.

Depends on what you want and need to learn. C++ is fairly "concept compatible" with Java, so you can come up to speed with it more quickly. But learning C will force you to learn about pointers and storage management more quickly and deeply.

Also, you state that you're considering using Python for your GUI, but I've not heard that Python's GUI tools are any better than Java's Swing library, one that I feel is quite powerful if you know it well and can be used to good effect.

If anyone has hard data that suggests I'm wrong, please post the link. I'm all about learning.

As C is a subset of C++ you should concentrate on just learning C++.
I know both languages. I learned C first.
Today I would definitely not start a new project using C instead of C++.
It is important that you learn to use pointers and you can do so with C++, no problem.
You can learn the non object-oriented features of C++ first so that you don't bypass them (stuff like pointers, structures, pointers to structures, arrays, references). Then move on to classes and templates.

By the way, it is easier to learn the Java language having known C++ already than I imagine it would be the other way around. This is mainly because of the pointer arithmetic facility in C++.

I you learn C first. You will gain a better understanding of how a computer program works, and eventually a better understanding of how C++ works.

I you start with C++. You have to do it carefully because, having the same power than in C, you could get exposed to errors you won't be able to understand without a proper understanding of C concepts. On the other hand, you will directly have the tools to write safer programs (exception, RAII, memory management ...). You will also open your eyes to the whole complexity of this language. C++ is not only a Object Oriented language. It allows generic programming, meta-programming, procedural programming, ...

My personal point of view is that you cannot program in C++ if don't know C. But you never program the C way in C++.

Finally, C, C++, and Java are fairly compatibles with python through SWIG and Jython (for Java).

Since you would like to improve your programming skills and already have skills in Java you could go with either of them, c++ will be easier but here is a list of reasons for why you might want to learn C