Aside from the syntax of C and the OOP nature of C++, How much is there to learn of C if you have a solid base of C++. Is there much incentive to learn C at all if you're learning C++?
Aside from the syntax of C and the OOP nature of C++, How much is there to learn of C if you have a solid base of C++. Is there much incentive to learn C at all if you're learning C++?
Depends on what you want to do. If you think C would be useful to you in your career (or even if you just want to learn it for personal interest) then by all means learn it. It has been suggested by a few experienced programmers that it is useful to continue learning new programming languages. For example, if you wanted to do some kernel hacking, or even just some system programming, for one of the UNIX variants, you would want to have a really good grasp on C. So in that sense, there is some incentive to learn the language.
C is not a large language, as far as syntax. You already know how the operators and the keywords work. You do lose a lot of the nice stuff from C++, e.g., with C its a little more work to resize a vector, and work with strings etc. Having learned C++ first, you may have a deficiency in understanding the underlying work done by the string functions. Of course this lack of knowledge is by no means a problem, provided that you recognise it is helpful to learn some of what is going on with the functions you are using. Now some might argue that it's unnecessary to know what is underlying the functions you are using (after all that is one reason why we encapsulate code into a function, in order to not have to worry about what goes on inside) but I still think it is useful in order to avoid some of the 'gotchas' of the C language.
Allocating memory is another thing that is not so easy in C as in C++. Again, this is not a problem, but you do have to take the time to learn it.
Why would it be smart to go for C?
Well I understand data structures so a lot of that was already covered and I have references if I need more.
And I haven't learned much of memory allocation (aside from some simple C++ Allocator library functions to mimic a vector using raw memory).
If you feel comfortable with your current level of C++ knowledge, there are several ways you can go to continue learning. Which one is best depends on your own interests and goals.
You might consider delving deeper into C++. There are advanced topics that can be interesting and challenging and make you a better programmer.
You can also try using your current C++ abilities to expand your software design knowledge. For example, you can learn how to identify and implement design patterns.
Another option is to learn C. You already know almost all C syntax, so you can focus on C idioms and practices, and learning how to write good C code. You will also learn many lower-level details glossed over by C++ constructs.
Those are just a few options. IMO any would be excellent choices.
If you just want to write programs for the PC, then C++ (plus the WinAPI library) is fine. There are plenty of good C++ compilers for the PC, and if you ever really need to include C code in your C++ program, you (generally) can.Why would it be smart to go for C?
At my work, all of our embedded systems and drivers are programmed in C. The compilers we have happen to be C, and I think it's easier to control the relationship between the hardware/memory and the software... less abstraction... But, I'm not sure if that's really true... I'm the hardware guy.
If you are planning to be a professional programmer, you need to understand more than one programming paradigm, and you need to know more than one language. (You need to know how to program without using OOP.) If you already know one procedural language and C++, yoiu could pick-up very C easily.
The vast majority of C students I know of have gone on to learn C++. Not many of them have stuck with C as a main language to use. These few people went on to design lunix systems and deeper OS programming structure. C has many uses, and as a whole is a well leveraged study along side C++.
EDIT These people I "know" are past college buddies. Meh, they think I was the odd one out as I went on to favor C++ over C. But my main goal is to program game software, so I had no choice.
Double Helix STL
I've been told that, "You don't know C++ in you don't know C." I'm not sure I endorse that view, but I have been told that.
You probably don't know all of C++ if you don't know C, but you probably don't know all of C++ even if you do know C, so that statement is pretty irrelevent. I'm guessing the point is that the person who told you believes that knowledge of the C parts of C++ are essential to a good understanding of the C++ language. I'm not sure I'd agree with that, though.
I agree with it: the C parts of C++, as in functions, if-statements, and in fact pretty much all the low-level syntax are quite essential to C++
Beyond that, no.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Until now POSIX threads are not compatible with C++. So if you want to write cross platform multithreaded software, you better stick to C, at least for now.
Excuse me!?
Even if it that was case, there wouldn't be no problem in taking a C library into your C++ code, or better yet, wrap it in C++ classes.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
As has been done with Boost.Threads.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law