Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

So do you recommend C and python and java or C++ and Python and Java

P.S I do most of my programming on linux.

share|improve this question
3  
Site FAQ : and it is not about… what language you should learn next –  vivek Jan 7 '12 at 22:02
add comment

migrated from stackoverflow.com Jan 7 '12 at 20:18

This question came from our site for professional and enthusiast programmers.

closed as off topic by Yannis Rizos, ChrisF Jan 7 '12 at 22:39

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.

9 Answers

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

  • Useful for low level interactions with hardware ( It's useful for interfacing with electronics )
  • Useful for appreciating ( and understanding ) other programming languages and paradigms ( like OOP )
  • Useful for learning how memory management works and the problems associated ( something you might take for granted in garbage collected environments like Java )
  • Systems programming ( Linux tools like Lex which generates Parsers and many many other tools are C based )
  • Stuff that are in other languages ( like Mutabality and Reference types Vs Value types ) will be more clear

So if you want to learn a lower level language go for C and anyway you will have python for a high level scripting language

share|improve this answer
add comment

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.

Edit: Since I couldn't think of a good use case for C++ I found a great thread where C++ programmers state why they use it :) http://lambda-the-ultimate.org/node/663. But since I cannot condone C++, personally, I also have to link to this funny interview http://harmful.cat-v.org/software/c++/I_did_it_for_you_all

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.

share|improve this answer
add comment

Both C and c++ are very exigent languages.

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).

share|improve this answer
add comment

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++.

There are free compilers for Linux.

share|improve this answer
add comment

Depends on what you want to program.

C is often used for stuff like kernels, UI toolkits...etc.

C++ is used for browsers, games, applications that have special performance requirements (CAD, 3D design and the like).

The two languages are really different from one another, even though you can write C programs in C++, the mindset is very different.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Learn C.

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.

share|improve this answer
3  
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 McDaid Jan 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. –  Expressions Jan 8 '12 at 6:37
add comment

Since you appear to want to learn lots of languages at once, you could try learning Python, C and C++. This way you would be able to answer your own question from experience.

share|improve this answer
    
And risk a brain hernia? I think not. –  Hovercraft Full Of Eels Jan 7 '12 at 20:26
    
Learning just C++ instead of C and C++, will make a huge difference ;) –  Peter Lawrey Jan 7 '12 at 20:29
add comment

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.

share|improve this answer
add comment

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