Movatterモバイル変換


[0]ホーム

URL:


Packt
Search iconClose icon
Search icon CANCEL
Subscription
0
Cart icon
Your Cart(0 item)
Close icon
You have no products in your basket yet
Save more on your purchases!discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Profile icon
Account
Close icon

Change country

Modal Close icon
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timerSALE ENDS IN
0Days
:
00Hours
:
00Minutes
:
00Seconds
Home> Programming> Programming Language> Debunking C++ Myths
Debunking C++ Myths
Debunking C++ Myths

Debunking C++ Myths: Embark on an insightful journey to uncover the truths behind popular C++ myths and misconceptions

Arrow left icon
Profile Icon Alexandru BolboacăProfile Icon Ferenc-Lajos Deák
Arrow right icon
€20.99€23.99
Full star iconFull star iconFull star iconFull star iconFull star icon5(1 Ratings)
eBookDec 2024226 pages1st Edition
eBook
€20.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Alexandru BolboacăProfile Icon Ferenc-Lajos Deák
Arrow right icon
€20.99€23.99
Full star iconFull star iconFull star iconFull star iconFull star icon5(1 Ratings)
eBookDec 2024226 pages1st Edition
eBook
€20.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€20.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning
OR

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Table of content iconView table of contentsPreview book icon Preview Book

Debunking C++ Myths

Every C++ Program Is Standard-Compliant

Except when they are not

In the world of C++ programming, the concept of standard compliance is often held in high regard, with the latest iteration of the C++ standard perceived as the definitive guide for writing correct and efficient code. The C++ standard, meticulously crafted and periodicallyupdated by the C++ committee and theInternational Organization for Standardization (ISO), serves as the ultimate guide for developers, providing a comprehensive set of rules and best practices to ensure code quality and interoperability. However, the reality of software development is more nuanced and complex than thisideal suggests.

In this chapter, we will delve into the myriad challenges faced by developers who, due to various constraints, cannot always adhere to these standards and carefully balance on the sharp, thin edge between ideal standards and the practical demands of their work. These constraints can include limitations in their...

Technical requirements

We have to admit that reading this chapter will not be a straightforward process, but we will try to make it as easy as possible. Our minds will wander between platforms, compilers, and different dialects of the C++ language. However, at some point, we must draw the line and conclude that we should be able to transform all this theoretical transfer of information into the practicalities of life and produce some C++ code out of it. So, we kindly ask that at this stage of the book, you have access to the almighty internet, and the go-to place for experimental C++: MattGodbolt’s site:

https://gcc.godbolt.org/

That place should keep you covered since almost all the compilers we will discuss in this chapter are to befound there.

There is nothing else required for now. That’s because at this stage, we have not produced enough valuable code to be able to put anything meaningful into the GitHub repository of the book, and the code that we have...

Somewhere in Ghana, far, far away

When Richard Appiah Akoto posted a few images of himself drawing the user interface of Microsoft Wordon a blackboard at his school in Ghana, he instantly became a social media phenomenon overnight1. His school was poor and they had no working computers, just a standard blackboard from the turn of the century, but this did not stop him from performing his duties as a teacher. In a very creative manner, he did his best to convey life-altering knowledge to his pupils, hoping that one day, it would be useful for them in their quest for a better life. The rest is history, but the real question is: was this the standard way of teachingMicrosoft Word?

Let’s not diverge too much from our initial objective. We want to find out about the standard compliance of C++ programs. For...

Microsoft’s tiny, squishy C++

That’s enoughstaring backward for now. Let’s look, for a moment, in a different direction and consider a compiler that once was the king of C++, but with time, its shine faded. OpenWatcom is an open source integrated development environment and suite of compilers for C and C++ (and Fortran too, but that language is not in focus in this book), originally developed by Watcom International Corporation and released as open source by Sybasein 2003.

It supports multiple operating systems, including DOS, Windows, OS/2, and also Linux, and is the de-facto compiler for programmers who have an interest in creating fun, free-time projects forretro platforms.

Not necessarily for the money, but instead for that joyful feeling of sweet nostalgia shivering through one’s spine when they are in front of an 80x25 screen. Maybe that’s the reason most senior programmers today use a grid of VI editors running in a terminal tiled...

The realm of free compilers

Two of the threemajor compilers today are developed and maintained in an open-source manner. This means that, in theory, anyone can contribute and provide useful new features to their compiler of choice. However, in practice, it means that there is a tiny core of professional programmers who have the necessary knowledge and dedication, and also the backing of a large corporation benefiting from the development of the aforementioned compiler workingon it.

In no particular order, GCC and Clang (and MSVC, which we discussed in the previous section) are the most standard-compliant compilers as of 2024. This standard compliance, however, does not mean that these compilers don’t come with their own perks that a developer once thought would be a great ideato incorporate.

Let’s take, for example, thecomputed goto feature of GCC (and Clang too, of course; those two tend to go hand in hand). We all have learned in school thatgoto is just plain...

When the header is not even C++

The long list of standard-non-compliant-but-still-working-and-useful features does not end with the preceding examples. However, if we had only focused our attention on those, we could still have filled several books with them. Sadly, for the moment, we have only dedicated one chapter to this topic, so let’s move our attention to somewhat moreexotic features.

Qt has been the de-facto cross-platform programming framework for GUI applications (but not only) for quite some time. Throughout its fateful history, while exchanging owners several times since its inception in 1994, the Qt framework has evolved significantly, with each release giving a new set of features to the C++ (but not only) programming community. However, one feature has remained more or less the same: the signal/slotimplementation and theMeta Object Compiler (MOC). The pillar of the framework, the MOC makes it possible to connect events from components (i.e., signals) to receivers...

The curious case of C++ locked in a box

Up until now, we have observed cases where the standard compliance was at the developers’ own discretion. They had the option to choose their platform, use the extensions provided by their favorite compiler, or go for pure standard C++. However, out there inthe wild wide world, there are certain circumstances wherein we cannot fully comply with the standard due to some restrictions imposed upon us by the environment that disallows the usage of certain features found in theC++ standard.

Not considering obscene scenarios, when we must maintain decades-old legacy code written in the golden age of C++ (i.e., before the standardization committee took over and ruined all the fun by demanding standard compliance, in order to avert the uncontrollable spread of C++ dialects as happened withBASIC), there are situations outside of our control that make the usage of the full C++ standard features impossible. For example, there might be certain...

Past days of future C++

The last scenario that we will explore concerning the standard compliance of the code you writerelates to the most fundamental item in the C++ ecosystem: thecompiler itself.

You see, compilers are also programs, consisting of millions and millions of lines of code. There are several contributors spread out on the globe working on them, adding new features, fixing bugs, making them more standard compliant, releasing the latest versions, and generally making sure that your compilerjust works.

These compilers also have a development timeline. The implementation of features does not happen overnight, and there simply might be situations wherein, at a certain point in time, some compiler does not support some feature of the standard because there was not enough manpower toimplement it.

There is a very handy document available at the source of all C++ knowledge8, which details the support of various C++ standard features and which compilers have support...

Summary

As this chapter has demonstrated, writing standard C++ ensures code portability, compatibility, and maintainability across different platforms and compilers. We learned that by adhering to the ISO/IEC C++ standard, we can create code that behaves predictably and is less prone to bugs and platform-specific issues. Standard-compliant C++ code also benefits from generic compiler optimizations and future language enhancements, while ensuring long-term relevance and performance, as we learned inthis chapter.

On the other hand, using C++ compiler-specific extensions can provide performance optimizations specific to a platform and compiler, access to advanced features that are not yet standardized, and integration with vendor-specific tools. However, the extension may introduce portability issues, dependencies on specific compiler versions, as well as divergence from standard C++ practices, which can impact code maintenance and interoperability across different platforms and compilers...

Left arrow icon

Page1 of 9

Right arrow icon
Download code iconDownload Code

Key benefits

  • Trace the origins of C++ misconceptions and understand why they persist
  • Learn to avoid pitfalls caused by misunderstood C++ standards
  • Leverage the lesser-known features of the C++ programming language
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

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.

Who is this book for?

This book is for intermediate-to-advanced C++ developers looking to deepen their understanding of the language’s complexities. It is perfect for coders eager to avoid common mistakes, hackers, scholars with a sense of humor, or anyone with an interest in C++. Programmers who want to expand their knowledge, refine existing skills, explore new paradigms, or dive into the nuances of C++, will find valuable insights. Technical leads and software engineering managers adopting new technologies or navigating the C++ ecosystem will also benefit from this book.

What you will learn

  • Comprehend the history of C++ and the design decisions that shape modern challenges
  • Master program flow and its underlying principles to resolve issues effectively
  • Tackle incompatibility across compilers and platforms with ease
  • Identify issues and avoid writing code that may lead to undefined behavior
  • Explore advanced C++ features not typically covered in academia
  • Address concerns about compiler code generation and optimizations
  • Understand why undefined behavior remains intentionally undefined

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date :Dec 30, 2024
Length:226 pages
Edition :1st
Language :English
ISBN-13 :9781835884799
Category :

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
Product feature iconAI Assistant (beta) to help accelerate your learning
OR

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Product Details

Publication date :Dec 30, 2024
Length:226 pages
Edition :1st
Language :English
ISBN-13 :9781835884799
Category :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99billed monthly
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconSimple pricing, no contract
€189.99billed annually
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick iconExclusive print discounts
€264.99billed in 18 months
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick iconExclusive print discounts

Table of Contents

14 Chapters
Chapter 1: C++ Is Very Difficult to LearnChevron down iconChevron up icon
Chapter 1: C++ Is Very Difficult to Learn
Technical requirements
Why is C++ perceived as difficult to learn?
The hard parts of C++ and how to grasp them
The Stroustrup method for learning C++
The Kate Gregory method – don’t teach C
The test-driven method for learning C++
With great power…
Summary
Chapter 2: Every C++ Program Is Standard-CompliantChevron down iconChevron up icon
Chapter 2: Every C++ Program Is Standard-Compliant
Technical requirements
Somewhere in Ghana, far, far away
Microsoft’s tiny, squishy C++
The realm of free compilers
When the header is not even C++
The curious case of C++ locked in a box
Past days of future C++
Summary
Chapter 3: There’s a Single C++, and It Is Object-OrientedChevron down iconChevron up icon
Chapter 3: There’s a Single C++, and It Is Object-Oriented
Technical requirements
The multiple facets of C++
Functional programming in C++
Metaprogramming
Strong types to the limit
What about ignoring types?
Summary
Chapter 4: The Main() Function is the Entry Point to Your ApplicationChevron down iconChevron up icon
Chapter 4: The Main() Function is the Entry Point to Your Application
The main() function
The penguin farm
Let’s open the Windows (unless you’re on ISS)
Summary
Chapter 5: In a C++ Class, Order Must There BeChevron down iconChevron up icon
Chapter 5: In a C++ Class, Order Must There Be
Size does matter
The order that must be respected
Deep thoughts about order
The dark orders of C++
When order does not matter
Summary
Chapter 6: C++ Is Not Memory-SafeChevron down iconChevron up icon
Chapter 6: C++ Is Not Memory-Safe
Technical requirements
Memory safety is important
The memory safety problems of older C++
Modern C++ to the rescue
The limits of modern C++
There’s still more to do
Summary
Chapter 7: There’s No Simple Way to Do Parallelism and Concurrency in C++Chevron down iconChevron up icon
Chapter 7: There’s No Simple Way to Do Parallelism and Concurrency in C++
Technical requirements
Defining parallelism and concurrency
Common issues with parallelism and concurrency
Functional programming to the rescue!
The Actor Model
What we can’t do yet
Summary
Chapter 8: The Fastest C++ Code is Inline AssemblyChevron down iconChevron up icon
Chapter 8: The Fastest C++ Code is Inline Assembly
Light me a pixel
The sum of all numbers
One instruction to rule them all
Summary
Chapter 9: C++ Is BeautifulChevron down iconChevron up icon
Chapter 9: C++ Is Beautiful
In search of beauty
The definition of zero
A parenthesis concerning parentheses
C++uties
Summary
Chapter 10: There Are No Libraries For Modern Programming in C++Chevron down iconChevron up icon
Chapter 10: There Are No Libraries For Modern Programming in C++
How can we tell?
A modern developer’s experience
Common needs
Compatibility
Supply chain security
Summary
Chapter 11: C++ Is Backward Compatible ...Even with CChevron down iconChevron up icon
Chapter 11: C++ Is Backward Compatible ...Even with C
Is C really forward-compatible with C++?
Whitespace matters – until it doesn’t
The auto surprise
Summary
Chapter 12: Rust Will Replace C++Chevron down iconChevron up icon
Chapter 12: Rust Will Replace C++
Technical requirements
Why the competition?
Core features of Rust
Rust’s advantages
Where C++ is better
What C++ still needs
Summary
IndexChevron down iconChevron up icon
Index
Why subscribe?
Other Books You May EnjoyChevron down iconChevron up icon
Other Books You May Enjoy
Packt is searching for authors like you
Share Your Thoughts
Download a free PDF copy of this book

Recommendations for you

Left arrow icon
Debunking C++ Myths
Debunking C++ Myths
Read more
Dec 2024226 pages
Full star icon5 (1)
eBook
eBook
€20.99€23.99
€29.99
Go Recipes for Developers
Go Recipes for Developers
Read more
Dec 2024350 pages
eBook
eBook
€20.99€23.99
€29.99
50 Algorithms Every Programmer Should Know
50 Algorithms Every Programmer Should Know
Read more
Sep 2023538 pages
Full star icon4.5 (68)
eBook
eBook
€26.98€29.99
€37.99
€37.99
Asynchronous Programming with C++
Asynchronous Programming with C++
Read more
Nov 2024424 pages
Full star icon5 (1)
eBook
eBook
€22.99€25.99
€31.99
Modern CMake for C++
Modern CMake for C++
Read more
May 2024504 pages
Full star icon4.7 (12)
eBook
eBook
€26.98€29.99
€37.99
Learn Python Programming
Learn Python Programming
Read more
Nov 2024616 pages
Full star icon5 (1)
eBook
eBook
€20.99€23.99
€29.99
Learn to Code with Rust
Learn to Code with Rust
Read more
Nov 202457hrs 40mins
Video
Video
€56.99
Modern Python Cookbook
Modern Python Cookbook
Read more
Jul 2024818 pages
Full star icon4.9 (21)
eBook
eBook
€28.99€32.99
€41.99
Right arrow icon

Customer reviews

Rating distribution
Full star iconFull star iconFull star iconFull star iconFull star icon5
(1 Ratings)
5 star100%
4 star0%
3 star0%
2 star0%
1 star0%
PhilippJun 25, 2025
Full star iconFull star iconFull star iconFull star iconFull star icon5
excellent book that covers topics you wont find in any other C++ Book. Fun to read, full of both useful and just nice to know knowledge. Absolute recommendation
Subscriber reviewPackt

About the authors

Left arrow icon
Profile icon Alexandru Bolboacă
Alexandru Bolboacă
LinkedIn iconGithub icon
Alexandru Bolboacă is a CTO, passionate polyglot programmer, senior trainer, and advisor at Mozaic Works. With over 20 years in software development, he has worked in various industries and across European countries, as well as the UK and the USA. He has been involved in large projects in sectors such as banking and financial services, energy, telecommunications, pharma, and eHealth. Drawing from practical experience, he advises and teaches architecture and usable software design, evolutionary design, crafting code, clean code, secure coding, and refactoring legacy code. Alex enjoys helping teams and organizations understand and build strategies for successful and robust products, built-in quality, and motivation.
Read more
See other products by Alexandru Bolboacă
Profile icon Ferenc-Lajos Deák
Ferenc-Lajos Deák
LinkedIn iconGithub icon
Ferenc-Lajos Deák is a seasoned software developer with a strong foundation in mathematics and theoretical computer science, currently based in Trondheim, Norway. His career spans roles across diverse domains, including autonomous vehicles, real-time traffic systems, multimedia, and telecommunications. An avid open-source enthusiast, he maintains several live projects and has authored more than a dozen articles for various technical publications, focusing on one of his passions: programming.
Read more
See other products by Ferenc-Lajos Deák
Right arrow icon
Getfree access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook?Chevron down iconChevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website?Chevron down iconChevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook?Chevron down iconChevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support?Chevron down iconChevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks?Chevron down iconChevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook?Chevron down iconChevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.


[8]ページ先頭

©2009-2025 Movatter.jp