Should I learn C before C++? Isn't C better because it has less overhea

by -  Blake Madden

 

Should I learn C before C++? Isn't C better because it has less overhead? These are very valid questions and ones that I believe should be answered prior to delving into the world of C/C++. I feel that the answers are "no, you should learn C++ first, then you should come to understand the fundamental differences C++ and its predecessor" and "no, C++ still retains the efficiency of C with improved and new features." Many people are apt to view C and C++ as two entirely different languages, whereas I prefer to see C++ as an improved version of C that can still utilize many of the features that are thought of as "C-style." Some C programmers will argue that C++ is too large with too much overhead. The fact is that there is indeed more overhead with classes as opposed to (C-style, data-only) structures. However, you should bear in mind that just because you are using C++ you don't need to make everything object-oriented. This is to say, if you feel the situation calls for a simple structure or enumeration, then by all means use them. There's nothing wrong with utilizing the less complex and more efficient C-style data types when data encapsulation isn't a major concern, but memory is. The point is, C++ is a better C with improved (completely overhauled , actually) data structures, memory allocation, and I/O features. You are much better off learning and using this improved methods first, and then go back and familiarize yourself with the way C handles these methods. C++ is a big, complex language, but I honestly don't feel that coming to learn C first will necessarily aid you. Learning C's (error-prone) I/O system and memory allocation instead of C++'s will only cause bad practice and style further down the road. However, you should at least understand C's methods in case you ever work with legacy code. You also can familiarize yourself with the data structure efficiency in C, so that you can incorporate that along with object-oriented data structures. I have to agree with some C++ critics that it can have a bit of overhead in some cases, but C++'s advanced features--like overloaded operators and multiple inheritance--are options, not requirements. This is the whole reason why C was chosen to be the base language, because of its efficiency, and C++ still has all of that efficiency with improved and more features.

Add your tutorials to this site Mail Me

 

Click Here!

1