Offered at CppCon 2022, cppfront by Herb Sutter is an experiment on making a 10x enchancment to the C++ programming language by implementing a brand new, safer, extra trendy “classes realized” syntax. Makes an attempt to enhance C++ are nothing new, as we noticed with Google’s not too long ago introduced Carbon programming language. This method is barely distinction, as it’s simply a brand new C++ syntax, backward suitable with present C++, very comparable in method to the TypeScript programming language. It is usually vital to comprehend cppfront is simply an experiment or proof of idea and most will possible by no means exist as a manufacturing degree product.
Design objectives of cppfront syntax embrace:
- repair defaults (e.g., make
[[nodiscard]]
the default); - double down on trendy C++ (e.g., make C++20 modules and C++23
import std;
the default); - take away unsafe elements which can be already outdated (e.g., take away
union
and pointer arithmetic); - have kind and reminiscence security by default (e.g., make the C++ Core Pointers security profiles the default and required);
- eradicate 90% of the steerage now we have to show about at the moment’s advanced language;
- make it simple to put in writing a parser (e.g., have a context-free grammar); and
- make it simple to put in writing refactoring and different instruments (e.g., have order-independent semantics).
cppfront code is hosted on GitHub and might requires a C++20 suitable compiler to construct. As soon as constructed, cppfront can be utilized to compile cpp2 recordsdata to cpp format, which may then be constructed utilizing a standard C++ toolchain.
Key Hyperlinks
Herb Sutter’s Technical Weblog
You possibly can be taught extra about cppfront and see it in motion within the video beneath.