Revolutionary ‘Safe C++’ Extension Proposal: Questioning Rust, Understanding Rust, Becoming Rust?

↑ Click the blue text above to follow ‘OSC Open Source Community’Revolutionary 'Safe C++' Extension Proposal: Questioning Rust, Understanding Rust, Becoming Rust?

The C++ community has announced a “revolutionary” proposal for the ‘Safe C++’ extension, aimed at adding memory safety features to C++.

Revolutionary 'Safe C++' Extension Proposal: Questioning Rust, Understanding Rust, Becoming Rust?

This proposal will be developed in collaboration with an organization called the “C++ Alliance” and engineer Sean Baxter. The C++ Alliance plans to submit the ‘Safe C++’ extension proposal to ISO for inclusion in the C++ standard.

The C++ Alliance is a non-profit organization aimed at making the C++ programming language accessible and useful, with a mission to enable everyone who wishes to learn and apply the C++ programming language to master and use it..

Revolutionary 'Safe C++' Extension Proposal: Questioning Rust, Understanding Rust, Becoming Rust?

Example code written using the ‘Safe C++’ extension:

#feature on safety
#include <std2.h>

int main() safe {
  std2::vector<int> vec { 11, 15, 20 };

  for(int x : vec) {
    // Ill-formed. mutate of vec invalidates iterator in ranged-for.
    if(x % 2)
      mut vec.push_back(x);

    std2::println(x);
  }
}
$ circle iterator.cxx -I ../libsafecxx/single-header/
safety: during safety checking of int main() safe
  borrow checking: iterator.cxx:10:11
        mut vec.push_back(x);
            ^
  mutable borrow of vec between its shared borrow and its use
  loan created at iterator.cxx:7:15
    for(int x : vec) {
                ^

https://github.com/cppalliance/safe-cpp/blob/master/proposal/iterator.cxx

C++ Alliance Chairman and Executive Director Vinnie Falco wrote on his blog:

This collaboration marks an important milestone in the C++ ecosystem, as the need for ensuring code safety has never been more urgent.

With the increasing importance of software safety and reliability, developers face immense pressure to adopt safer programming practices. The ‘Safe C++’ extension aims to address this critical need by introducing new features that prevent common memory-related errors.

The ‘Safe C++’ extension represents a significant step towards a safer and more efficient C++, while maintaining the language’s performance and flexibility.

The ‘Safe Standard Library’ will be a key component of the ‘Safe C++’ extension proposal. It will provide developers with robust and memory-safe implementations of fundamental data structures and algorithms.

By integrating these components into the C++ standard library, we can ensure that safety is considered from the outset when writing new code.

In recent years, tech giants including Google and Microsoft have been highlighting the issues posed by memory safety vulnerabilities and promoting the use of languages that do not require manual memory management, other than C and C++.

This message has also caught the attention of the U.S. government public sector, which has a large amount of legacy code, prompting the White House and the U.S. Cybersecurity and Infrastructure Security Agency (CISA) to encourage the use of memory-safe programming languages—Rust.

Despite C/C++ developers arguing that similar results can be achieved by strictly adhering to ISO standards and diligently applying testing tools.

Even Bjarne Stroustrup, the father of C++, stated, “We can now achieve perfect type and memory safety in ISO C++.”

Last year, Josh Aas, co-founder and executive director of the Internet Security Research Group (ISRG), pointed out in an interview that while it is theoretically possible to write memory-safe C++ code, there are no such cases in practical scenarios, because C++ was not designed for memory safety from the beginning.

To accelerate the transition to memory-safe programming languages, the U.S. Department of Defense’s Advanced Research Projects Agency (DARPA) has also launched the TRACTOR project. TRACTOR stands for TRanslating All C TO Rust, aiming to develop a code translation platform based on AI technology to automatically convert old C code to Rust code.

The background of the ‘Safe C++’ extension proposal is precisely to address various criticisms and respond to the needs for memory safety from agencies such as the National Security Agency (NSA), CISA, the White House, and DARPA.

Related Sources

https://www.theregister.com/2024/09/16/safe_c_plusplus/

https://safecpp.org/P3390R0.html

https://cppalliance.org/vinnie/2024/09/12/Safe-Cpp-Partnership.html

Further Reading

The U.S. Department of Defense suggests converting C code to Rust—using AI

Switching from C++ to Rust, development efficiency increases by more than double

The father of C++ rebuts the White House, stating that the Biden administration overlooks the advantages of modern C++ programming languages

Suggestions to abandon C/C++ to eliminate memory safety vulnerabilities

C++ used in Linux kernel development, once strongly opposed by Linus, is now the right time to mature?

Apple claims Swift is the best choice to replace C++

END

Popular Articles

Google SRE engineer works for 9 years: annual salary over $600,000, earned enough money, no longer so passionate about technology

Qualcomm plans to acquire Intel—Is the Arm vs. x86 battle coming to an end?

Zen Browser—Claimed to be the “open-source version of Arc”, light as a feather, fast as lightning

Former employees of “heavenly foreign enterprises” and “IT retirement homes” recall the past: once a utopia, salaries so high they could only buy houses

Revolutionary 'Safe C++' Extension Proposal: Questioning Rust, Understanding Rust, Becoming Rust?

Leave a Comment