学习C/C++的一些书籍和工具

From the time I began learning C language to now, it has been five or six years, during which I have read quite a few good and bad books, tried many tools (the holy war of compilers/editors), and here I will summarize everything in detail. After messing around for a long time, I have come to a kind of thought, which is different from the “take-it-for-granted” mindset; it is an experience of “doing it yourself.”

Books

This section mainly writes about the books I have read, mainly related to C/C++.
I started programming with C language and slowly transitioned to C++. Looking back at C language now, the feeling of using this procedural form indeed feels very rudimentary; however, it can showcase the strongest performance while ensuring programmers have good data structure and algorithm skills. In simple terms, C++ adds OO features (very important) on top of C and encapsulates a large number of libraries, with many excellent algorithms written by experts that can be directly used without worrying about performance. C++ can be said to be a superset of C, but C++ does not support VLA (Variable Length Arrays).

The following books are recommended to read in order:

C Language

C Primer Plus
Prerequisite Skills: None

I started learning C language with this book, which is very detailed, though some parts might feel a bit verbose. In fact, the first book I read was Tan Haoqiang’s “C Programming Design,” which is far inferior compared to C Primer Plus.

C and Pointers
Prerequisite Skills: C Language

Although it is also claimed to be an introductory book, it is better to have some experience with C language before reading it, as it provides a deep exploration of pointers and data structures.

After finishing the above two books, one can be considered a beginner in C language, but writing code requires long-term practice.

C++

If you have experience in C language, learning C++ will be much easier. This is because C++ has keywords, data types, etc., inherited from C.

C++ Primer
Prerequisite Skills: C Language

The book I used to learn C++ is C++ Primer 4th edition. Recently, I also got a 5th edition to supplement my knowledge of C++11. In fact, do not be misled by the name Primer; if one does not have a foundation in C, this book is not suitable for direct reading, as the chapter arrangement is not friendly to beginners; often, a concept introduced at the beginning may not be explained in detail until much later chapters. Therefore, it is recommended to first have a general understanding of C language or C++ before reading this book.

Based on a comparison of the 4th and 5th editions, I strongly recommend starting with the 5th edition since C++11 is a significant revision with many new features that can be directly used.

In fact, the detail level of C++ Primer is almost like a manual, covering everything thoroughly.

This book must be read seriously!

Data Structures and Algorithm Analysis - C Language Description
Prerequisite Skills: C/C++

I have read Yan Weimin’s Data Structures, but in general, domestic textbooks are not as interesting as foreign books.

For learning data structures and algorithms, I recommend this book.

Although Introduction to Algorithms is a classic, it can be quite difficult for beginners without good mathematical skills, so it is better to start with this Data Structures and Algorithm Analysis!

Learning C/C++ from Traps and Defects
Prerequisite Skills: C/C++

This is a thin book, only 166 pages, produced by the Taobao team.

This book does not cover any C/C++ syntax knowledge. It only provides case analyses of various misuse examples, which are completely practical, with a perfect usability score.

Advanced

Prerequisite Skills: C++

There are many advanced books on C++.

Deep Exploration of the C++ Object Model
Prerequisite Skills: Familiar with the Object-Oriented Part of C++

After reading C++ Primer, you may have some understanding of class construction and virtual function usages; this book delves into the features of C++ objects, focusing mainly on the compiler implementations of class construction, destruction, and copying, as well as class inheritance, polymorphism, and in-depth knowledge about function semantics and the compiler level. Additionally, it covers the important RAII mechanism in C++ OO and a deep exploration of the virtual function table.

This book will help you understand the C++ object model more deeply; as the book title suggests, it explores in depth—strongly recommended!!

Effective C++: 55 Specific Ways to Improve Programs and Designs
Prerequisite Skills: C++

This book, like the above Learning C/C++ from Defects, does not involve any C++ syntax knowledge; it addresses misconceptions about C++ features or aspects that were not considered during C++ design.

It’s completely practical content; this book is truly timeless. If possible, I highly recommend memorizing these 55 summaries!!

STL Source Code Analysis
Prerequisite Skills: C++, STL

STL is the standard template library for C++, which includes five components: algorithms, containers, iterators, functions, and adapters.

STL source code analysis provides a detailed examination of the algorithms and data structures implemented in STL; it is an excellent book (translated by Mr. Hou Jie must be a masterpiece). I am currently reading it and planning to write my own STL.

Language-Independent

The last few books are focused on C++ in the server backend direction, while the earlier books can be viewed regardless of the direction you are taking with C/C++; the later ones are primarily based on personal choices for direction.

Modern Operating Systems
Prerequisite Skills: C Language

Starting with the development of operating systems, it gradually expands into process threads/storage management/file systems/input/output/deadlocks, etc. You can gain detailed knowledge about operating systems.

TCP/IP Illustrated, Volume 1: The Protocols

One of W. Richard Stevens’ masterpieces, an indispensable book for anyone wanting to learn the TCP/IP protocol!

Unix/Linux Programming Practice Tutorial

You can read this book before looking at APUE (Advanced Programming in the Unix Environment), but it seems this book is already out of print; you can check it out at a library or buy a photocopy.

This book guides you step by step to learn Unix/Linux knowledge by analyzing, designing, and writing a tool under Linux. However, this book is somewhat outdated, and some of the code needs improvement.

Unix Network Programming, Volume 1: Socket Networking API

One of W. Richard Stevens’ masterpieces. The legendary UNP (UNIX Network Programming). The third edition was penned by top networking programming experts Bill Fenner and Andrew M. Rudoff, revising the classic work of the late great W. Richard Stevens, adding content on IPv6, SCTP protocol, and key management sockets, in-depth discussing the latest key standards, implementations, and technologies.

This is an indispensable resource for us learning UNIX network programming.

Advanced Programming in the Unix Environment

This is the legendary APUE (Advanced Programming in the UNIX Environment). Its depth and breadth surpass the earlier discussed Unix/Linux Programming Practice Tutorial.

This is also an essential book for us to learn/advance UNIX environment programming.

About Unix/Linux platforms, you cannot run things under Windows, so it is best to install Linux or set up a virtual machine when reading these last three books.

Tools

In fact, learning C++ does not require any special tools; the main issue now is the overwhelming number of tools available, making it dazzling. I initially used VC6.0 (something from over a decade ago, but many schools still use it now), and after being criticized by a group of people in the community (for not supporting new features), I chose Dev-cpp, which supports updated standards. I am currently using Sublime Text + GCC/Clang or Visual Studio (the most powerful IDE). Regardless of how you configure it yourself, you ultimately just end up with a subset of VS. However, using an editor + compiler can make it easier to understand the compilation/linking process, which is a skill in itself.

Without further ado, for beginners, I recommend using Dev-cpp, which can be downloaded here (includes MinGW).

Of course, if you want an IDE, you can use VS: Visual Studio 2015 Professional Update2.

If you want to set up your environment, you can use the online installer or use my packaged offline version; just add it to your system PATH.

For analyzing code, you can use gprof, which is provided by GCC.

To analyze memory leaks on Windows, you can use cppcheck, and on Linux, you can use valgrind.

Sublime Text + gprof + Clang + cppcheck is also a great combination. You can find the details in my blog post: Configure Sublime Text as a Lightweight C/C++ IDE.

Documentation Manuals

Online Documentation

Offline Documentation

What I often use now are offline Wikipedia (very convenient for checking IEEE) + offline cppReference and the chm of cppReference (for easy querying).

The article is finished. If you have any questions, please comment and communicate.

Scan the QR code on WeChat and follow me.

Title:学习C/C++的一些书籍和工具
Author:LIPENGZHA
Publish Date:2016/06/12 12:08
World Count:7.9k Words
Link:https://en.imzlp.com/posts/64054/
License: CC BY-NC-SA 4.0
Reprinting of the full article is prohibited.
Your donation will encourage me to keep creating!