To start with C or C++

This is a discussion on To start with C or C++ within the C Programming forums, part of the General Programming Boards category; I know another one of these topics but just hear me out. I am new to programming and I am ...

To start with C or C++

I know another one of these topics but just hear me out. I am new to programming and I am going to learn both of these languages eventually (and others) but which one should I begin with. I was of course going to just start with C like any person would think but after reading around the forums it appears if you start and get more fluent with programming in C due to restrictions it has when you make the switch to C++ you have bad habbits from prgramming in C. I have been looking through threads all day and I just keep coming up with no answers and more questions. Also have read that is easier to learn C if you know C++ then if you know C first and then switching to C++. Maybe I am just rambling I don't know but any input about which would be a better to learn first would be greatly appreciated. So which should I learn first C++ or C, or does it even matter. I just dont want to break into bad programming habbits.

(No flames please, I know these threads get annoying but believe me I went through many threads and all the different posts just gave me more questions than answers)

>when you make the switch to C++ you have bad habbits from prgramming in C
And vice versa. C and C++ idioms are different enough that you'll have issues no matter which you start with. Just pick the language that you feel more comfortable with. Everyone's different, so you can't reasonably expect someone else to make this decision for you.

I wouldn't start with either. I would personally start with something like Lisp or any other kind of language that is meant to be "taught in school". I don't know about C++, but C tends to blur a lot of computer science concepts. I think is sort of due to that fact it was designed to be a general purpose programming language. Added to the headache is the fact C requires the user to do the memory management. BTW, both UC-Berkeley and MIT teach Lisp (before C or Java) as a first programming language in the introductory engineering classes

I won't go as far as to recommend that you learn Lisp, Pascal, Fortran, Basic, Logo, or any other language that is taught by some schools in their introductory programming classes. Learning to program is different than learning a specific programming language. Once you know how to program, which involves thinking about problem solving in ways that lend themselves to expression as computer programs that correctly solve the problem at hand, you can quickly learn almost any programming language. I will admit that Lisp and Perl (and Scheme, Snobol, APL, and some others) use a programming syntax and model that is quite different, and may give you a deeper understanding of what's really going on when you switch to a procedural language like C or C++, but it it doesn't change my assertion that what you need to do is to learn to program. Pick a language, any language.

C and C++ differ in some subtle, and some not-so-subtle ways, and while it's true that learning one before the other may limit your initial forays into the other, this awkwardness should pass very quickly as you gain experience in the new language.

C and C++ can be used to solve the same problems. C++ cannot be used in some environments where C can, but that's because the environments lack the support required, not because the problems themselves cannot be solved in C++. In some environments, C is hard to use and C++ is the best choice because the APIs are all C++ oriented. It is possible (and not difficult) do write code in C that implements an object oriented design. It was being done for years before C++ came on to the scene, and continues to be done. Non-object oriented designs can be easily implemented in C++. It is a wash.

Object oriented and non-object oriented design are different ways of thinking. It is easier to express an object oriented design in C++ than in C because you don't have to know (or care) about how stuff is working under the hood. I personally believe that it's better to know what's going on under the hood, but that's me.

If you want to learn the Object Oriented way of thinking, C++ may be the better choice as a first language. If you want to be able to do Linux kernel hacking, C is the way to go. Even if you choose C++, you'll have to learn a lot of C to understand why some things work the way they do in C++ (pointers, arrays, pointer arithmetic), and to deal with operating system calls and such.

I did learn C long before I learned C++, but I learned Fortran, Lisp, Basic (several dialects), TPL, PDP-11, 8080 and 6502 assembler, Bliss, Algol, Algol68, BCPL, APL, and PL/1 (along with a few others on the side) before I learned C. C++ came along many years later.