Presented at CppCon 2022, cppfront by Herb Sutter is an experiment on making a 10x improvement to the C++ programming language by implementing a new, safer, more modern “lessons learned” syntax. Attempts to improve C++ are nothing new, as we saw with Google’s recently announced Carbon programming language. This approach is slightly difference, as it is just a new C++ syntax, backward compatible with existing C++, very similar in approach to the TypeScript programming language. It is also important to realize cppfront is just an experiment or proof of concept and most will likely never exist as a production level product.
Design goals of cppfront syntax include:
- fix defaults (e.g., make
- double down on modern C++ (e.g., make C++20 modules and C++23
import std;the default);
- remove unsafe parts that are already superseded (e.g., remove
unionand pointer arithmetic);
- have type and memory safety by default (e.g., make the C++ Core Guidelines safety profiles the default and required);
- eliminate 90% of the guidance we have to teach about today’s complex language;
- make it easy to write a parser (e.g., have a context-free grammar); and
- make it easy to write refactoring and other tools (e.g., have order-independent semantics).
cppfront code is hosted on GitHub and can requires a C++20 compatible compiler to build. Once built, cppfront can be used to compile cpp2 files to cpp format, which can then be built using a traditional C++ toolchain.
You can learn more about cppfront and see it in action in the video below.