I N T R O D U C T I O N
The demand for system programming
is enormous. With the ubiquity of web
browsers, mobile devices, and the Internet
of Things, there has
perhaps never been a bet-
ter time to be a system programmer. Efficient, main-
tainable, and correct code is desired in all cases, and
it’s my firm belief that C++ is the right language for
the job
in general.
In the hands of a knowledgeable programmer, C++ can produce
smaller, more efficient, and more readable
code than any other system
programming language on the planet. It’s a language committed to the
ideal of zero-overhead abstraction mechanisms—so your programs are fast
and quick to program—as well as simple, direct mapping to hardware—
so you have low-level control when you need it. When you program in C++,
you stand on the shoulders of giants who have spent decades crafting an
incredibly powerful and flexible language.
Grab the ol’ brush and paint along with us.
—Bob Ross
xxxii
Introduction
A huge benefit of learning C++ is that you gain access to the C++
Standard Library, the
stdlib, free of charge. The stdlib is composed of three
interlocking parts: containers, iterators, and algorithms. If you’ve ever written
your own quicksort algorithm by hand or if you’ve programmed system code
and been
bitten by buffer overflows, dangling pointers, use-after frees, and
double frees, you’ll enjoy getting acquainted with the stdlib. It provides you
with an unrivaled combination of type safety, correctness, and efficiency. In
addition, you’ll like how compact and expressive your code can be.
At the core of the C++ programming model is the
object life cycle, which
gives you strong guarantees that resources your program uses, such as files,
memory, and network sockets, release correctly, even when error conditions
occur.
When used effectively, exceptions can clean out large amounts of error-
condition-checking clutter from your code. Also, move/copy semantics pro-
vide safety,
efficiency, and flexibility to manage resource ownership in a way
that earlier system programming languages, like C, simply don’t provide.
C++ is a living, breathing language; after more than 30 years, the
International Organization for Standardization (ISO) committee for C++
regularly makes improvements in the language.
Several updates to the stan-
dard have been released in the past decade: C++11, C++14, and C++17, which
were released in 2011, 2014, and 2017, respectively. You can expect a new
C++20 in 2020.
When I use the term
modern C++, I mean the latest C++ version that
embraces the features and paradigms presented in these additions. These
updates have made serious refinements to the language that improve its
expressiveness, efficiency, safety, and overall usability. By some measures,
the language has never been more popular, and it’s not going away any
time soon. If you decide to invest in learning C++, it will pay dividends
for years to come.
Dostları ilə paylaş: