how_cpp_23_changes_the_way_we_write_code
How C++23 Changes the Way We Write Code - Timur Doumler
C++ is like a giant toolbox
- Specialized Tools: Some features in C++ are like pentalobe screwdrivers—specialized for specific tasks that not everyone will encounter. These features solve particular problems effectively but are not universally applicable.
- Transformative Tools: Other features are more like cordless electric screwdrivers that revolutionize the basic tasks of coding, such as the introduction of features like coroutines, concepts, ranges, and modules in C++20. These fundamentally alter how developers write and structure code, making tasks more efficient and broadly applicable.
Reflection on C++20 and the Transition to C++23
-
Impactful Features of C++20:
- Coroutines, concepts, ranges, and modules as the "big four" that changed the foundational aspects of C++, affecting the mental model of functions, templates, algorithms, and code distribution.
- These features were transformative, akin to tools that change the entire workflow for developers, applicable across various coding tasks and enhancing overall efficiency and capability.
-
Anticipation for C++23:
- Smaller Scale: C++23 is viewed as a smaller release primarily aimed at completing and refining the developments started with C++20, rather than introducing groundbreaking new features.
- Still Influential: Despite its smaller scope, C++23 will introduce features that, while perhaps not as revolutionary on a broad scale as those in C++20, will still be highly influential and beneficial for developers.
Narrow down the impactful features
Started with a comprehensive list of all the new features included in the C++23 draft, as detailed on cppreference.com. We are skipping features that are ...
-
Defect Reports, Deprecations, and Clarifications:
- Omitted because they refine but do not add new functionality.
-
Minor Adjustments and Tweaks:
- Exclusions include minor additions like
noexcept,constexpr, new constructors, and constraints.
- Exclusions include minor additions like
-
Ranges-Related Enhancements:
- Significant work has been done, but these are part of a continuous development from C++20 and will be covered in dedicated discussions.
-
Unicode and Text Encoding Features:
- Omitted due to their specialized nature and ongoing issues that are still being addressed.
-
Simplifications and Syntax Improvements:
- Examples include enhancements to CTAD and lambda syntax which streamline existing features rather than introduce new capabilities.
-
Improvements to Existing Library Features:
- These are enhancements that build on existing functionalities, which don't represent new feature introductions.
-
Pre-supported Compiler Features:
- Features like
#warningand#elifdefalready supported by major compilers are excluded as they don’t offer new capabilities to most developers.
- Features like
-
Compatibility Features:
- Omitted as they are aimed at ensuring backward compatibility rather than introducing new tools or functionalities.
-
Cleanup from Previous Standards:
- Features that are primarily improvements or resolutions of issues from C++20.
-
Specialized Numeric and Type Features:
- Such as
std::float16_tandstd::float32_t, which, while important, are niche and better suited for a dedicated numeric-focused discussion.
- Such as
-
Expert-Only Features:
- Features like
[[assume]]andstd::unreachablewhich can introduce risks like undefined behavior and are not widely applicable for all developers.
- Features like
-
Highly Specialized Features:
- These are akin to "pentalobe screwdrivers" of the C++ world, useful for specific problems but not widely impactful.
-
Previously Discussed or Imminent Features:
- Topics like standard library modules and generator forcoroutine support, which are continuations of discussions from C++20 or are already being extensively covered elsewhere.