{"id":1215131,"date":"2025-02-09T07:04:00","date_gmt":"2025-02-09T12:04:00","guid":{"rendered":"https:\/\/www.prime-wow.com\/?p=1215131"},"modified":"2025-02-09T07:04:00","modified_gmt":"2025-02-09T12:04:00","slug":"c-on-steroids-bjarne-stroustrup-presents-guideline-enforcing-profiles-for-resource-and-type-safety","status":"publish","type":"post","link":"https:\/\/www.prime-wow.com\/?p=1215131","title":{"rendered":"<div>C++ on Steroids: Bjarne Stroustrup Presents Guideline-Enforcing &#8216;Profiles&#8217; For Resource and Type Safety<\/div>"},"content":{"rendered":"<div>&#8220;It is now 45+ years since C++ was first conceived,&#8221; writes 74-year-old C++ creator Bjarne Stroustrup in an article this week for Communications of the ACM. But he complains that many developers &#8220;use C++ as if it was still the previous millennium,&#8221; in an article titled 21st Century C++ that promises &#8220;the key concepts on which performant, type safe, and flexible C++ software can be built: resource management, life-time management, error-handling, modularity, and generic programming&#8230; <\/p>\n<p>&#8220;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.&#8221;<\/p>\n<p>To help developers focus on effective use of contemporary C++ and avoid outdated &#8220;dark corners&#8221; of the language, sets of guidelines have been developed. Here I focus on the C++ Core guidelines that I consider the most ambitious&#8230; My principal aim is a type-safe and resource-safe use of ISO standard C++. That is: <\/p>\n<p>&#8211; Every object is exclusively used according to its definition<br \/>\n&#8211; No resource is leaked<br \/>\nThis 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&#8230; 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.<br \/>\nWG21 (and others) are working on &#8220;profiles&#8221; to enforce guidelines (though they&#8217;re &#8220;not yet available, except for experimental and partial versions&#8221;). But Stroustrup writes that the C++ Core Guidelines &#8220;use a strategy known as subset-of-superset.&#8221;<\/p>\n<p> 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).<br \/>\n Next: subset: ban the use of low-level, inefficient, and error-prone features.<br \/>\nWhat we get is &#8220;C++ on steroids&#8221;: 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.<br \/>\nStroustrup writes that the C++ Core Guidelines focus on rules &#8220;we hope that everyone eventually could benefit from.&#8221;<\/p>\n<p>No uninitialized variables<br \/>\nNo range or nullptr violations<br \/>\nNo resource leaks<br \/>\nNo dangling pointers<br \/>\nNo type violations<br \/>\nNo invalidation<\/p>\n<p>Bjarne Stroustrup answered questions from Slashdot readers in 2014&#8230;<\/p>\n<div class=\"share_submission\" style=\"position:relative;\">\n<a class=\"slashpop\" href=\"http:\/\/twitter.com\/home?status=C%2B%2B+on+Steroids%3A+Bjarne+Stroustrup+Presents+Guideline-Enforcing+'Profiles'+For+Resource+and+Type+Safety%3A+https%3A%2F%2Fdevelopers.slashdot.org%2Fstory%2F25%2F02%2F09%2F0636247%2F%3Futm_source%3Dtwitter%26utm_medium%3Dtwitter\"><img decoding=\"async\" src=\"https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/twitter_icon_large.png\"><\/a><br \/>\n<a class=\"slashpop\" href=\"http:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fdevelopers.slashdot.org%2Fstory%2F25%2F02%2F09%2F0636247%2Fc-on-steroids-bjarne-stroustrup-presents-guideline-enforcing-profiles-for-resource-and-type-safety%3Futm_source%3Dslashdot%26utm_medium%3Dfacebook\"><img decoding=\"async\" src=\"https:\/\/www.prime-wow.com\/wp-content\/uploads\/2025\/02\/facebook_icon_large.png\"><\/a><\/p>\n<\/div>\n<p><a href=\"https:\/\/developers.slashdot.org\/story\/25\/02\/09\/0636247\/c-on-steroids-bjarne-stroustrup-presents-guideline-enforcing-profiles-for-resource-and-type-safety?utm_source=rss1.0moreanon&amp;utm_medium=feed\">Read more of this story<\/a> at Slashdot.<\/p>\n<p><iframe src=\"https:\/\/slashdot.org\/slashdot-it.pl?op=discuss&amp;id=23604661&amp;smallembed=1\" style=\"height: 300px; width: 100%; border: none;\"><\/iframe><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;It is now 45+ years since C++ was first conceived,&#8221; writes 74-year-old C++ creator Bjarne Stroustrup in an article this week for Communications of the ACM. But he complains that many developers &#8220;use C++ as if it was still the &hellip; <a href=\"https:\/\/www.prime-wow.com\/?p=1215131\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,44],"tags":[],"class_list":["post-1215131","post","type-post","status-publish","format-standard","hentry","category-slashdot","category-technology"],"_links":{"self":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts\/1215131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1215131"}],"version-history":[{"count":0,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=\/wp\/v2\/posts\/1215131\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1215131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1215131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.prime-wow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1215131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}