Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Debunking C++ Myths
  • Table Of Contents Toc
  • Feedback & Rating feedback
Debunking C++ Myths

Debunking C++ Myths

By : Alexandru Bolboacă, Ferenc-Lajos Deák
close
close
Debunking C++ Myths

Debunking C++ Myths

By: Alexandru Bolboacă, Ferenc-Lajos Deák

Overview of this book

Think you know C++? Think again. For decades, C++ has been clouded by myths and misunderstandings—from its early design decisions to misconceptions that still linger today. Claims like "C++ is too hard to learn" or "C++ is obsolete" are often rooted in some truth, but they are outdated and fail to capture the language’s ongoing evolution and modern capabilities. Written by industry veterans with over 40 years of combined experience, this book uncovers the myths, exploring their origins and relevance in the context of today’s C++ landscape. It equips you with a deeper understanding of advanced features and best practices to elevate your projects. Each chapter tackles a specific misconception, shedding light on C++'s modern features, such as smart pointers, lambdas, and concurrency. You’ll learn practical strategies to navigate common challenges like code portability and compiler compatibility, as well as how to incorporate modern best practices into your C++ codebase to optimize performance and future-proof your projects. By the end of this book, you’ll have a comprehensive understanding of C++'s evolution, equipping you to make informed decisions and harness its powerful features to enhance your skills, coding practices, and projects.
Table of Contents (15 chapters)
close
close

What this book covers

Chapter 1, C++ Is Very Difficult to Learn, looks at why this is the case: is it the language or is it the teaching method? Should we start with low-level features such as pointers and memory management first, or would it perhaps be better to start with working examples or with the OOP features? Also, does every C++ programmer need to know the same C++? The chapter discusses different approaches to learning a language, with a focus on C++, and decides whether C++ is still difficult to learn today ... with the right method. [Alex]

Chapter 2, Every C++ Program Is Standard-Compliant, covers the question that the title suggests. In an ideal world, maybe they would be! In reality, every C++ program should be compliant. However, as we discover in this chapter, when they stray a little to the left or right, using an obscure compiler extension, dabbling in undefined behavior, or relying on a particular platform’s quirks, you instantly might find yourself in a tangle of errors only decipherable by ancient mystics. So, sure, every C++ program is “compliant” ... until it’s not! [Ferenc]

Chapter 3, There’s a Single C++, and It Is Object-Oriented, examines different paradigms of organizing code, including functional programming, meta programming, and the lesser-known extreme polymorphism. [Alex]

Chapter 4, The Main() Function is the Entry Point to Your Application, covers the topic mentioned in the title. In practice, as we will present in the chapter, the main() function is like the front door of your application: it’s where everything begins, but if you peek behind it, you’ll often find an intricate web of dependencies, libraries, and OS-dependent system calls that make reaching it feel more like navigating a maze than walking a straightforward path. [Ferenc]

Chapter 5, In a C++ Class, Order Must There Be, explores the fact that, sure enough, there must be order in a C++ class, since problems arise without it! Methods, data members, constructors, a place each must find! Yes, flexibility is, but ignored structure cannot be. Respect not the ordered members’ order request and crumble the class will! Freedom too much, and behavior, undefined, comes, errors, bugs, crashes! Disorder, C++ does not tolerate. With sequence respect, harmony reigns! The most important rules, this chapter presents, where the specified order of C++ concepts matters. Or it might not be specified at all, but still matters. [Ferenc]

Chapter 6, C++ Is Not Memory-Safe, explores the challenges of memory management in C++, the promise of modern language constructs, and their failures, in the context of increased awareness of the general public on software reliability. [Alex]

Chapter 7, There’s No Simple Way to Do Parallelism and Concurrency in C++, looks at the need for parallelism and concurrency, how modern C++ proposes to deal with them, and how the actor model can help design parallelism in your products. [Alex]

Chapter 8, The Fastest C++ Code Is Inline Assembly, covers a fact we were taught three decades ago. While assembly does indeed offer low-level control, modern compilers are highly optimized and often generate more efficient code than hand-written assembly, as we will demonstrate in the chapter. Indeed, inline assembly can improve performance in some cases, but it sacrifices readability and portability, so use it sparingly and only when absolutely necessary. [Ferenc]

Chapter 9, C++ Is Beautiful, asserts that C++ is indeed beautiful because where else can you find a language so gracefully tangled in angle brackets, semicolons, curly braces, and periods? It’s a poetic dance of keywords, templates, ancient macros, and overloaded operators, all elegantly arranged to make even the most seasoned programmers question their life choices. Truly, as the chapter will showcase, C++ syntax is the epitome of beauty, if beauty means a riddle wrapped in an enigma, with just a hint of confusion after preprocessing again the unpreprocessable. [Ferenc]

Chapter 10, There Are No Libraries For Modern Programming in C++, evaluates the need and availability of libraries for C++, the challenges of package management, the difficulties in finding libraries for your target version and architecture, and the increasing problem of supply chain attacks. [Alex]

Chapter 11, C++ Is Backward Compatible ... Even With C, explores backward compatibility because, as we will present in the chapter, C++ inherits the family heirloom: a messy pile of global variables, pointy pointers, and undefined behavior. C++ dutifully keeps these relics alive, allowing the two languages to coexist in an awkward, yet somehow functional, embrace. Compatibility, indeed, because who doesn’t want the thrill of mixing decades-old C code with modern C++? Or with not-so-modern C++? We mean, hey, tradition is important, and we must clamber for a living! [Ferenc]

Chapter 12, Rust Will Replace C++, looks at why we have so many programming languages, how Rust fits into the ecosystem and what it does well, C++’s answer, and the conditions under which Rust might replace C++. [Alex]

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY