explaingit

hsutter/cppfront

5,949C++Audience · developerComplexity · 4/5Setup · hard

TLDR

Cppfront is an experimental compiler by Herb Sutter that translates a cleaner experimental C++ syntax called Cpp2 into standard C++20, prototyping safety and simplicity ideas for future C++ standards.

Mindmap

mindmap
  root((cppfront))
    What it does
      Cpp2 to C++20
      Experimental syntax
      Standards prototyping
    Key ideas
      Lifetime safety
      Simpler declarations
      Metaclasses
    Compatibility
      Mix old and new
      Standard compilers
      Existing libraries
    Origins
      Herb Sutter
      CppCon talks
      ISO C++ proposals
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Experiment with a cleaner C++ syntax that compiles to standard C++20 your existing toolchain can already build

USE CASE 2

Prototype code using proposed C++ safety features like lifetime analysis before they reach the official standard

USE CASE 3

Study how future C++ language proposals might look in practice by running working examples

USE CASE 4

Mix old and new C++ syntax in the same file to incrementally adopt new patterns in existing codebases

Tech stack

C++C++20

Getting it running

Difficulty · hard Time to first run · 1h+

Requires familiarity with C++ and manual build from source, not a production tool, explicitly described as a personal experiment.

In plain English

Cppfront is a personal experiment by Herb Sutter, a well-known figure in the C++ standards community. It is a compiler that takes C++ written in a new experimental syntax he calls "Cpp2" and translates it into ordinary C++ code that any standard C++ compiler can then build. The project is not a replacement for C++ or a competing language. Instead, it is a way to prototype ideas about how C++ could be made simpler and safer in the future, with the goal of eventually proposing those ideas to the official C++ standards committee. The premise is that C++ has accumulated a lot of complexity over decades, and many common coding mistakes stem from that complexity. The new syntax tries to address this by providing a cleaner way to express the same things, while remaining fully compatible with existing C++ code, libraries, and compilers. You can mix the old and new syntax in the same file. The output of cppfront is standard C++20 code, so it works with tools and compilers that already exist without requiring any changes to them. The README includes a long list of C++ proposals and conference talks that grew out of this work, covering ideas like lifetime safety analysis, a comparison operator that was ultimately adopted into C++20, reflection and code generation features called metaclasses, and others. Some of those concepts are already implemented in cppfront, others are listed as future work. This is explicitly described as a personal experimental project rather than a production tool. The documentation, full design details, and a getting-started guide are available on the project's website linked from the README. There are also several recorded talks at C++ conferences (CppCon, ACCU) where Sutter explains the ideas behind this work. This repository is aimed at experienced C++ developers interested in language design and the future direction of C++. It is not an application end users would interact with directly, and it requires familiarity with C++ to use or evaluate.

Copy-paste prompts

Prompt 1
Show me a simple Cpp2 function definition and explain step by step how cppfront translates it to standard C++20
Prompt 2
How do I install cppfront and integrate it with CMake so I can mix Cpp2 and regular C++ files in the same project?
Prompt 3
What are the main syntax differences between Cpp2 and regular C++ for declaring variables, functions, and parameters?
Prompt 4
Explain how cppfront's lifetime safety analysis detects dangling pointers and show an example that would trigger a warning
Prompt 5
What C++ standard proposals grew out of the cppfront experiment, which ones were adopted and which are still future work?
Open on GitHub → Explain another repo

← hsutter on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.