Cpp Notes

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 ...

  1. Defect Reports, Deprecations, and Clarifications:

    • Omitted because they refine but do not add new functionality.
  2. Minor Adjustments and Tweaks:

    • Exclusions include minor additions like noexcept, constexpr, new constructors, and constraints.
  3. 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.
  4. Unicode and Text Encoding Features:

    • Omitted due to their specialized nature and ongoing issues that are still being addressed.
  5. Simplifications and Syntax Improvements:

    • Examples include enhancements to CTAD and lambda syntax which streamline existing features rather than introduce new capabilities.
  6. Improvements to Existing Library Features:

    • These are enhancements that build on existing functionalities, which don't represent new feature introductions.
  7. Pre-supported Compiler Features:

    • Features like #warning and #elifdef already supported by major compilers are excluded as they don’t offer new capabilities to most developers.
  8. Compatibility Features:

    • Omitted as they are aimed at ensuring backward compatibility rather than introducing new tools or functionalities.
  9. Cleanup from Previous Standards:

    • Features that are primarily improvements or resolutions of issues from C++20.
  10. Specialized Numeric and Type Features:

    • Such as std::float16_t and std::float32_t, which, while important, are niche and better suited for a dedicated numeric-focused discussion.
  11. Expert-Only Features:

    • Features like [[assume]] and std::unreachable which can introduce risks like undefined behavior and are not widely applicable for all developers.
  12. Highly Specialized Features:

    • These are akin to "pentalobe screwdrivers" of the C++ world, useful for specific problems but not widely impactful.
  13. 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.

The final 4 that we are talking today