This is a question from several readers in the past week, and I took two pictures.



To be honest, I’ve seen this problem a lot before, but I forgot to take a screenshot.

Every time I encounter this kind of problem, it seems very simple, but typing for a while is really hard to say, think about today’s weekend, write an article to talk about it, if partners have different views, also welcome criticism and correction, see the comments section.


This article is in the open source project: github.com/hansonwang9… Has been included, which contains different directions of self-study programming routes, interview questions set/interviews, and a series of technical articles, etc., resources continue to update…


CLanguage andC++What is the relationship?

First of all, C++ and C language are two different programming languages, but C++ is indeed an extension and extension of C language, and provides backward compatibility capabilities for C language. It’s a bit awkward for some people to say that C++ is all about C.

When C++ was first invented by Bjarne Stroustrup, it was called “C with Classes,” or “C with Classes. Obviously it is on the basis of C language extension class and other object-oriented features and mechanisms. But it went through a series of revisions and many evolutions (see figure below) to create what is now a large programming language that supports a number of significant features.


As stated at the beginning of the classic book Effective C++, when we speak of C++ today, we should think of it as a vast “language federation” that contains, at the very least, the following important components:

  • Process-oriented programming
  • Object-oriented programming
  • Generic programming
  • metaprogramming
  • Functional programming
  • STL standard library

The first part of this, “Procedural programming,” is the backward compatible C language provided by C++, so you can see that most books on C++ programming on the market have the first few chapters devoted to “procedural programming,” including but not limited to: Data types, variables, operators, expressions, statements, judgments, loops, functions, Pointers, and so on.


Don’t learnCLanguages can be learned directlyC++?

Again, the first important part of the C++ programming language is “procedural programming,” and this is where C’s big brother comes in. Even if you haven’t learned C before, those who have learned C++ directly from the beginning should not escape the “process Oriented” section. Because most of the C++ programming books on the market begin with a chapter on procedural programming.

Theoretically speaking, it is not necessary to learn C language before learning C++, but it is often more advantageous to learn C++ with C language foundation, at least “procedural programming” this part of the content can be easily mastered.

Unfortunately, even the authoritative C++ Primer, which is over 700 pages long, starts with only a small portion of “procedural programming,” so process-oriented programming is certainly not as detailed and comprehensive as a C-specific book. Otherwise there would not have been books like C and Pointers, which focus on Pointers.

Therefore, my personal advice is that before learning C++, the foundation of C language should be consolidated as far as possible, which is certainly helpful.


CStudy well, studyC++Is it more advantageous?

Yes.

At least when learning C++, the “process-oriented” part of the content can be said to be familiar.


C++Can replaceCLanguage?

Why learn C when C++ is so powerful, with so many modules and paradigms, and almost all of the process-oriented part of C? Is it not sweet to learn C++ directly?

Yes, C++ is powerful, but those powerful paradigms and mechanisms themselves come with a lot of baggage, and do create a lot of burdens for learners, and even discourage many of them.

On the other hand, C language itself is a programming language that balances ability, performance, efficiency and learning cost to the extreme, so much so that C language is basically included in the required programming courses in college.

In addition, THE application of C language is extremely extensive, from the native interface at the bottom of the operating system to the development of the common application layer, C language has no small contribution. So that for many years, in the Tiobe programming language ranking, C language is not high.


In 2020, C returned to the top of the list as the “Programming Language of the Year 2019”. This is a seemingly boring ranking, but it tells you something.


So no matter in the past, now, or even in the future, the nearly 50-year-old C language old general will never be a slave.



onlyC++Is this object-oriented language suitable for large projects?

The emergence of C++ is indeed to facilitate the development of large applications, after all, many important ideas and mechanisms in object-oriented programming for large projects and complex systems required project engineering, code reuse/extensibility/maintainability and so on to provide a powerful support.

But the fact is that even C can build extremely complex systems and software. From Linux, the great operating system kernel, to Redis, Nginx and other open source software or frameworks heavily relied on by various companies, they are all representative works of C language.

So sometimes we have to admit that what people call abstraction depends more on the person writing the program than on the programming language itself.


The small knot

Okay, that’s a little too much, but to sum it up:

  • CLanguage andC++Are two different programming languages, but there is some overlap in content;
  • CThe language is a very powerful programming language, I think there is a chance to learn it;
  • Generally speaking, yesCThe foundation of language, get startedC++It’s faster;
  • C++andCEach has its own selection consideration and application scenarios, and there is no one better to say, to learn or not to learn depends on their own interests and their own technical development considerations

Books recommended

Finally, let’s talk about books on learning C and C++.

Personally, if you want to learn the two languages systematically, you’d better read classic books.

The most authoritative book on C learning is, of course, The C Programming Language by Dennis M. Ritchie, The Language’s creator (which is also available in Chinese), and C Primer Plus is also very systematic and comprehensive.

The most authoritative learning book on C++ is The C++ Programming Language written by Bjarne Stroustrup, The inventor of C++, but clearly this book is not suitable for beginners. A more appropriate C++ Primer is also very comprehensive. For further reading, you can read books such as Effective C++, STL source code anatomy, and exploring the C++ object model in depth.

When these books are read, the road to becoming god begins.

This article is in the open source project: github.com/hansonwang9… Has been included, which contains different directions of self-study programming routes, interview questions set/interviews, and a series of technical articles, etc., resources continue to update…


Make a little progress every day

Slower is faster