Navigation
Recherche
|
C++ on Steroids: Bjarne Stroustrup Presents Guideline-Enforcing 'Profiles' For Resource and Type Safety
dimanche 9 février 2025, 13:04 , par Slashdot
![]() 'At the end, I present ways to ensure that code is contemporary, rather than relying on outdated, unsafe, and hard-to-maintain techniques: guidelines and profiles.' To help developers focus on effective use of contemporary C++ and avoid outdated 'dark corners' of the language, sets of guidelines have been developed. Here I focus on the C++ Core guidelines that I consider the most ambitious... My principal aim is a type-safe and resource-safe use of ISO standard C++. That is: - Every object is exclusively used according to its definition - No resource is leaked This encompasses what people refer to as memory safety and much more. It is not a new goal for C++. Obviously, it cannot be achieved for every use of C++, but by now we have years of experience showing that it can be done for modern code, though so far enforcement has been incomplete... When thinking about C++, it is important to remember that C++ is not just a language but part of an ecosystem consisting of implementations, libraries, tools, teaching, and more. WG21 (and others) are working on 'profiles' to enforce guidelines (though they're 'not yet available, except for experimental and partial versions'). But Stroustrup writes that the C++ Core Guidelines 'use a strategy known as subset-of-superset.' First: extend the language with a few library abstractions: use parts of the standard library and add a tiny library to make use of the guidelines convenient and efficient (the Guidelines Support Library, GSL). Next: subset: ban the use of low-level, inefficient, and error-prone features. What we get is 'C++ on steroids': Something simple, safe, flexible, and fast; rather than an impoverished subset or something relying on massive run-time checking. Nor do we create a language with novel and/or incompatible features. The result is 100% ISO standard C++. Messy, dangerous, low-level features can still be enabled and used when needed. Stroustrup writes that the C++ Core Guidelines focus on rules 'we hope that everyone eventually could benefit from.' No uninitialized variables No range or nullptr violations No resource leaks No dangling pointers No type violations No invalidation Bjarne Stroustrup answered questions from Slashdot readers in 2014... Read more of this story at Slashdot.
https://developers.slashdot.org/story/25/02/09/0636247/c-on-steroids-bjarne-stroustrup-presents-guid...
Voir aussi |
56 sources (32 en français)
Date Actuelle
mar. 11 févr. - 01:51 CET
|