https://www.quora.com/Which-one-should-I-learn-first-C-or-C++

Which one should I learn first - C or C++?

I am very much proficient in Python but I've never learned either C or C++ and I am confused.
34 Answers
Nathan F Yospe
Nathan F YospeC++ standards expert, fluent in Python, Fortran, Matlab, C, Java, C#
26.5k Views • Nathan has 120+ answers in Computer Programming
Strong disagreement with all of the C proponents here. C++11 first. Learning C first teaches you a number of bad habits and archaic practices, and, like coming from a pure Java background, stands a good change, if you are not sufficiently flexible, of turning you into a terrible C++ programmer.

I'm a bit of a hypocrite here - I learned FORTRAN and C long before I learned C++, and the C++ I learned first was a much less mature language than the current one, especially in terms of patterns - but I would like to point out a common fallacy that appears in nearly every single response that advocates C. Every one of them says something like "knowing C is a prerequisite for understanding C++" or "C++ is an extension of C". This is a clear indicator that they do not understand C++ as well as they believe they do. Here's the thing... to really understand C++, you have to understand the machine code it generates. You can best understand the machine code in terms of assembly, and C is closely mapped to assembly... but efficient machine code generated from well written C++ no longer in any way resembles well written C, and that's the point that the C advocates completely miss.

Modern C++ requires you to think in several paradigms at once. Once upon a time, long before the first standard, C++ encapsulated two paradigms - procedural programming (like C) and an object = data + methods + method overrides version of object oriented programming (like Java without annotations or reflection). Learning C taught a couple of bad habits, but it wasn't a huge jump from C to C++, and learning to write terse functions in C actually made you a better C++ programmer. Now, though, C++ has evolved to incorporate generic programming (in a manner far beyond anything Java could ever dream of), generative and algorithm driven programming (think of this as a static form of functional programming), and functional programming (though there are limits to lambdas in C++, mostly on account of the early evaluation of execution paths) - and, more to the point, it has evolved into a language that, in its best-use form, incorporates these paradigms seamlessly to express models of whatever problem is being solved. This is not something that comes easily to someone who has taken a deep dive into a single-paradigm language like C or Java. It comes more easily to someone who has started with a language like Python, as you have, though concurrency tends to be a difficult hurdle for people coming from Python.

Every so often I find myself trying to integrate an obvious C programmer who learned some superficial C++ concepts into a deep C++ codebase, and the effort is always painful. Do yourself a favor... if you do feel compelled to learn C first, don't go straight to C++. Fluency in Python does mitigate some of the pitfalls, but the temptation to view C++ as an extension of C is still a danger if you attempt that transition.
Kostadis Roussos
Kostadis Roussosprincipal engineer at vmware
14k Views
The difference between C and C++ is really about the level of abstraction the language designers think the programmer wants to program to. 

C is the ANSI standard assembler. C allows for very low level control of the system hardware resources, while making the use of higher level abstractions cumbersome.

C++ was an attempt to raise the level of abstraction of low level system programming without making any attempt to sacrifice the ability to get great performance. Unfortunately the desire to not sacrifice performance in general, and the desire to maintain backward compatibility with C at the source level, resulted in a programming language that was large, complex, and difficult to use or master.

I tend to describe C++ as the ANSI Standard Program Language builder. The reason being that no one programs in C++, what they program is a dialect that they create out of C++ either by restricting themselves to specific features or by creating abstractions that they require before you can usefully write code.

As a result of this programs written in C++ tend to be so divergent from C style and idioms that it makes a mockery of the attempts to retain C source compatability...

So which to learn first: if you're just trying to expand your toolbox, learn C. If you have a job to do and the job is in C++, just go and learn the specific dialect of C++ that the job requires, don't try and learn the entire beast of the language and bypass C. If you want to learn a very complex language system then I recommend learning C++ directly.
Magnus Lyckå
Magnus LyckåSoftware developer and consultant in Gothenburg, Sweden.
5.5k Views • Magnus has 60+ answers in Computer Programming
Since C is a small subset of C++, it's very difficult to learn C after C++. :-)
As you probably know, Python is written in C, and it's common that C is used to write third party libraries for use with Python. As a proficient Python programmer, C is a very good compliment, if you need to speed up parts of your Python applications, or e.g. interact with hardware which is only available through some C API. Cython is a convenient bridge between Python and C. The kind of additions that C++ brings to the table in addition to C's features are mainly things you can do much, much more conveniently in Python. C++ handles large programs better than C, but if you want to write largish applications, it might be a better idea to compose them from several smaller programs anyway... Particularly if you want to learn C++, you should make sure to learn to use the modern (C++11/14) features, since that's a much better language than last century C++.
Duc Nguyen
Duc Nguyen
7.1k Views • Upvoted by Nathan F YospeC++ standards expert, fluent in Python, Fortran, Matlab, C, Java, C# and Sergey ZubkovC++ programmer (using boost and C++14)
If you want to learn C, learn C. But do not learn C as a "preparation" for learning C++. Many people learn C, thinking it will be good since they will learn C++ faster/better. FAIL! This often lead to mixing C and C++ code and concepts, which will lead to ugly and buggy C++ which give C++ bad reputation.

I suggest therefore, directly start with C++. The concept of C will be "automatically" learned then. (The language C is really smaller and easier to learn than C++ though)

Some good source for learning C++: Standard C++
Serguei Filimonov
Serguei FilimonovSimplifier
11.4k Views
Well if you want to learn just for the sake of general education and not to maintain some particular codebase, then C. It's smaller, so you can understand it faster. C++ has like 1000+ features and quirks that are not that necessary to learn if you don't work with it all the time. Memory management education you get in both, and C lets you know what it's like to program without object-orientation. So, for education purposes, I think you get much more bang and less headache with C.

Bonus point, I you're looking to experience what C is/was all about, write something using UNIX sockets APIs or anything that would require you to read old but still used 'man' pages. Like a simple server/client combo.
Travis Hance
Travis Hance
12k Views • Upvoted by Jessica SuCS PhD student at Stanford and Vladimir Novakovski,Competed in IOI, ACM World Finals
I think you should start with C and move to C++ once you are comfortable with it.

C is simpler, and in many ways knowing C is a prerequisite to knowing C++. It is true that there are many things you do in C that you won't need to do in C++ (for example, in C++, you'll use many fewer pointers and array and a lot more shared_ptrs, references, and vectors). However, knowing these low-level concepts is essential to understanding what these higher-level C++ abstractions are doing and what problems they are solving.
Shashank Srivastav
Shashank Srivastava Web developer and a programmer - all in progression
5.5k Views
I believe you should start with C first and when you are thorough with the basics then switch over to C++.

There will be people who might recommend learning C++ first and then switch to C (if want to do lower level stuff).

*Explanation:*

C is a procedural programming language. Therefore, learning C first forms a good base as every task you do in C will be structured in the form of procedures (also known as methods, functions, sub-routines). It means that every executable code will be contained inside these procedures.
This helps in constructing a series of computational steps to be carried out and will help you in dealing directly with the problem.

http://en.m.wikipedia.org/wiki/P...

C++ introduces a different programming paradigm - object oriented programming. It forms an abstraction layer on top and treats every thing as an object which has methods/functions associated to it.
This offers a more real life scenario and helps structure the code better while dealing with problems.

http://en.m.wikipedia.org/wiki/O...

Comparison:
The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines, whereas in object-oriented programming it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using classes/interfaces.

Thus, IMHO I'd recommend C first (but no need to dive deep) and then switch to C++.
Jerry Coffin
Jerry CoffinGuy who writes some code.
3.4k Views • Upvoted by Nathan F YospeC++ standards expert, fluent in Python, Fortran, Matlab, C, Java, C# and Sergey ZubkovC++ programmer (using boost and C++14)
In the end, it depends heavily upon what you want to know.

If you learn C++ first, chances are pretty good that you'll find restricting yourself to C later so irksome that you'll never really learn C as a thing in itself--you'll just learn C++ and a memorized set of restrictions that will let a C compiler process your code (but it probably won't really ever be comfortable C code).

If you learn C first, you'll have to spend a lot of extra time unlearning habits from C that are really counterproductive in C++. It is possible to get past all these hurdles and used C++ well despite knowing C, but at least if you learn to use C very well at all, it really will cause you a lot of extra work and pain.

So, if you really want to know both C and C++ well, there's not much real choice but to bite the bullet and put up with the fact that learning both is a lot more work than the mere sum of learning each one individually.

If you don't really care a whole lot about knowing how to use both well, then I'd advise learning the one you really care about, and leaving it at that. If that one is C++, you'll be able to read C pretty easily afterwards, assuming you can get past gritting your teeth at all the repetition, clean-up code everywhere because you don't have destructors, etc., ad nauseam. If that one is C, you'll probably be able to read most C++ code reasonably easily afterwards, provided it doesn't get too heavily into template madness and such.
Eric Pepke
Eric Pepke
3.6k Views • Eric has 330+ answers in Computer Programming
It sort of doesn't matter.  If you learn C++, you'll automatically learn C and probably first.  Or you can learn C first.

I've used C for three decades and C++ for two, and my perspective is that C++ is

1) ANSI C without some of the really old stuff nobody uses
2) A fairly obvious class system that most C programmers think of, based on structs, but with a bunch of weird rules for overloading.
3) A game involving figuring out how many things you can do with the ampersand, const, a plastic chair, and an old guitar strap I got from Jeff Beck (c.f. Frank Zappa)
4) Some pretty powerful and magical templates
5) A pretty nice standard library, which you can't use on most projects due to cultural reasons
6) cin and cout, which hardly anybody uses outside of class and debugging and which serve mostly to illustrate the dangers of being able to overload operators to do something totally different from the C meaning
Twyla Naythias
Twyla NaythiasBeen building computers since the days that involved a soldering iron!
2.3k Views • Twyla has 30+ answers in Computer Programming
Definitely C first.

As much as many neo-programmers love to bash C, a lot of it is because so many flavor-of-the-month languages like Java and Python are so far removed from how a computer actually works that they're quickly bewildered.  C is closer to the metal than any programming language other than Assembler while still retaining high-level abstractions.  C is also much simpler than C++, as C is strongly procedural while C++ includes the capacity for every programming paradigm under the sun (and then some).

After so many years of living with your parents (Python), the next step is to live on your own for a while (C) and get a feel for that before trying to build your own house (C++).
Björn Wehlin
Björn WehlinApplied math major (with a somewhat pure track)
4.6k Views
I would suggest C++ because it teaches you about object oriented programming. However, if you're more into lower level stuff, C might be better, but I find that object oriented programming is more applicable to most things than what you'd learn from C.

Both are excellent choices though, in my opinion.
Max Lewin
Max LewinComputerologist
4.2k Views
Some interesting, thoughtful answers here.

I recently learned C, and then more recently learned C++ (really C++11 because I had the good fortune to learn from a standards committee member).

I think either path has its merits; you do need to know C, in a sense, to understand the details of any C++ implementation. But as far as learning to write C or C++ code, there are definitely some strongly contraindicated practices that will get you in trouble if you try to carry them from C to C++ (whereas you simply won't be able to use C++ features in C, so the transition would at least be enforced by the compiler).

I'd say reflect on the particular problem domain and/or workplace you'd like to enable yourself to work in, and go from there. Systems software and legacy C++ codebases seem to usually have large chunks of pure C they rely on, so learning both would most likely benefit you regardless of order; on the other hand if you want to write a cutting edge C++ application from the ground up (think computer games, fast big data server backends, similarly complex stuff), you'd probably be better suited by learning C++11 from the get go. C++11 is really great, and actually facilitates both faster writing and learning of C++ by deprecating some hacky practices that were necessitated by the feature richness of older specifications, especially regarding object construction. It's not entirely gone, and learning order of construction rules is still gnarly, but there are features available that let you circumvent the worst parts now.
Riyad Parvez
Riyad ParvezGrad Student
6.7k Views
Start with C, C++ is a complex multi-paradigm language with lot of warts whether C is a simple single paradigm language. Mastering full features of C++ takes years of practice.
C++ has basically five parts:
  1. Structured (Like C)
  2. OOP
  3. Generic Metaprogramming / template
  4. Functional - lambdas, value type.
  5. Other
Dan Jay
Dan Jay
2.2k Views
C++ is definitely the language I'd recommend for the first timers. 

It leads to anywhere you wish. It opens the pathway to Object Oriented Programming. So you can learn java/C#/python or any highlevel programing language.

If you like to learn low level programming, you can call assembly code or any C library from C++.
Carl Menezes
Carl MenezesSenior Embedded Software Engineer
1.1k Views
C++, only if you're willing to take the time to understand why something works the way it does the moment you find yourself asking the question.

The whys of C++ are very tightly coupled with the whys of C and therefore C knowledge is required to truly work with C++ on an intuitive level.

You don't need to learn C and in fact, there are quirks about C like the way programs link, that do not exist in C++ as we know it today. However, C++ is a massively complex beast and it is easy to be overwhelmed by the seemingly never ending list of keywords at first and know which one you should use when. This is why most people suggest learning C. This is when you need to go back to the C roots to see why things are the way they are.

In the end, you will end up learning both.
Nicolas Rossello
Nicolas RosselloSystem Engineer
1k Views
C isn't a OOP language.
You should go directly to C++.

Regards,
Nicolas
Pareto for Developers - How To be an Excellent Programmer
Vibhor Sharma
Vibhor SharmaMCP
1.9k Views
dear fellow learner,
its really nice that you know about python programming .
As a computer engineer i would personally suggest you to begin your pursuit with language "C" rather then c++
Advantages-
1. you will be able to learn about pointers structures which will help you visualize the data structures like linked lists easily and efficiently
2. you will be able to implement algorithms on a very base level through c though a lot of coding is to be done to accomplish a simple task
3. Linux and unix os were written in c

decision is yours all d best goodluck
Saifi Khan
Saifi Khan
2.3k Views
C++11 is what you start with !

Please download a decent compiler like Clang/LLVM 3.4.x or GCC 4.8.x or recent version of Visual Studio express. All of them have excellent support for C++11.

As Bjarne Stroustroup puts it, "Modern C++" should mean in the 2010s: a language for programming based on light-weight abstraction with a direct and efficient mapping to hardware, suitable
for infrastructure code.

The C++ Programming book in its 4th edition is an awesome book to read.
The C++ Programming Language (4th Edition)

When i started reading that book, i couldn't put it down and read it cover to cover as i typed the various examples to understand the concepts better.

There are plenty of Open Source C++ projects whose code you can study as you work through.

If it so happens that you have to work on a project that requires you to look at C++ code base written in the last 10+ years or so, i'd suggest taking a quick look at 'Large-Scale C++ software design by John Lakos' or the two volume set of POSA to get going.

All the best for learning C++11 :)
Jean Vincent
Jean Vincent
3k Views
You should definitely learn C first because it is very much a low-level subset of C++ and most low-level code from Linux and the GNU libraries are actually written entirely in C.

If you want to learn C/C++ this is probably out of performance issues be it speed, code size, or memory footprint, in which case you need to understand the low level aspects first, which also means C.

Learning C will allow you to get the low-level power of C and C++, in particular the use of pointers which is possibly the most intriguing feature coming from a higher-level language. C will also give you a strong understanding of memory allocation issues, performance, and strategies (static vs stack vs heap).

From there, if you need to do OO programming you could then learn C++, giving you additional memory allocation strategies and much more. Your prior understanding of C will allow you to better understand the costs of various types of classes and inheritance.
Rohit Nigam
Rohit NigamMore than two decades or coding, and still learning.
572 Views • Rohit has 60+ answers in Computer Programming
C, although a very similar language to C++, is a very different language. The whole thought process in C is different compared to C++.
And as you say you are coming from Python, it is going to be even worse. I find C++ and Python more aligned and C totally out of the league (no offense).
C is more structured and linear. C++ and Python are more object oriented/based.

For any student who doesn't know much about programming, I would recommend learning C first, as it would help him understand a lot about memory handling. C is also a lot simpler with much lesser to learn.
C++ is a much larger language and has a lot to learn. However if one is already well versed with OOP then he should go with C++ first and move towards C later, which is a little closer to middle level language.
Shirsh Zibbu
Shirsh Zibbu
2.1k Views
Learn C if you really care about the underlying logics of the working of a code and it's compiler. It's an old language, and hence, requires a lot of man-labour. But if you do get good at it, many things about the working of computers will become clear.

On the other hand, C++, being fairly new, coupled with the latest libraries and standards, does reduce the code size to some extent. So, if you wish to apply and work with logics of the code, and dont bother yourself with the magic behind it all, go for it!

However, I'd personally recommend going for C.
You can always reduce the code size, once yo know exactly what will happen when you do `this` or `that`.

Besides, if you wish to write even smaller codes, go for python or ruby
Mahesh Abnave
Mahesh Abnave
1.6k Views
Well I know this is not about whether C or C++ first. But just for a side-note if you decide to learn any, the best resources can be found at stackoverflow tag wiki.

 'c' tag wiki - Stack Overflow

 'c++' tag wiki - Stack Overflow
Jeremy Roberson
Jeremy Roberson
1.1k Views
If you have the right curriculum, I would highly recommend learning C++ first, but just the basics, and with heavy use of STL.     C++ has features that enable coding that is clearer and easire to grasp than C.   From there you can either pivot into hardcore C and all of it's confusing low-level syntax, or you can delve deeper into C++ and tackle generic programming, and advanced object oriented program design.   I'm an EE and a purist, so in my mind, if you take C but don't take a hardcore computer architecture class, then learning low-level C really isn't as worth it.  

I learned C first by the way. 

If C++ curriculum is taught in a manner where one is assumed to be familiar with C already, then C is a prereq.
Vikram Kamath
Vikram KamathIs getting there.
1.9k Views
Since you've already learn an 'object - oriented' language, I suggest you go ahead and learn C. It's a whole new paradigm.
Dhrumil Kabaria
Dhrumil Kabaria
471 Views
You should learn C language first. Because C is mother of all the languages and C language acts like foundation to all other languages.

It is not like you can never learn any other language without learning C. But if you have learnt C first then it will enhance your level of understanding.

So as per my point of view, learning any new language without knowing C and with knowing C is totally different.
You should learn C first.
Deepankar Prabhakar
Deepankar Prabhakar
1.5k Views
First take a brief overview of the concept involved in the "C" programming and then you can easily switch to C++ .also in order to clearly understand the object oriented programming paradigm ("C++") you need to have to understand the structural one ("C")
Emily Blanchard
Emily BlanchardSocial Anthropologist, Technocraver, Cognitive Wanderer, Talent Cultivation
1.7k Views
It really depends on what you are trying to do in terms of the project and your career track. When you look into a tool box you grab the tool that's best for the job. First ask your self "what am I trying to accomplish?". Then choose what's best for the job.
Michael Hayter
Michael Hayterprogram a lot
3.2k Views
I started with C++, but I would suggest going C to C++.  Largely C++, as the name suggests, is an improvement on C.  I suggest this ordering because it helps to know where you came from to know where you are going!
Debdut Karmakar
Debdut KarmakarC, Vala, Python, Bash, Csh, Js, Haskell
443 Views
I think you must learn C first and probably you won't need C++ ever. 

C++ teaches you OO style. A complex language like C++ just does not let you use your cleverness.
Pinesh Menat
Pinesh Menat
251 Views
It doesn't matter but c++ is more powerful and covers all the features that c supports, I would suggest to start with c++.Most of the IT industries now uses c++. I have hardly seen any industry that uses C unless they have already developed something in C and they are just maintaining that flow. At last for a developer concepts for any language gonna be same just syntaxes are different
Akash Chandrakar
Akash ChandrakarCode wins argument
1.4k Views
The order doesn't matter in which u learn the language I started with c++ and then studied c
Don't muggle up the syntax of language understand the semantics corresponding to the syntax
Kishore Kumar
Kishore Kumar
256 Views
Go with c first and move on to C++ it will help you to understand low level operations very well and you can analyse things better once you understood C as it is close to hardware.
If you don't have time then stick to C++. You can learn C++ with out knowing C.
Elham Afshar
Elham AfsharI am student of software engineering
43 Views
And then decide…..
good luck!
Sourav Datta
Sourav Datta
2.6k Views
I would suggest to go with C++11 and use a book that teaches the C parts as well. For example the latest edition of C++ primer is an excellent choice.

Comments

Popular posts from this blog

Top Comments on The Boondocks Theme Song Meaning

Banalities and Other Trivial Things

RSD Tyler's True Motivation For Mastering Social Skills