The Circle Compile is a modern C++ compiler that extends C++17 with advanced metaprogramming capabilities through a built-in, bit-accurate C++ interpreter. It provides same-language reflection and introspection, enabling powerful compile-time code generation in an imperative style. Circle compiler Git

Similarities and differences with C++

Similarities

Differences

Metaprogramming with the embedded C++ interpreter

The interpreter is the foundation for Circle’s metaprogramming, using the special @meta keyword to run code at compile time. 

  1. Integrated interpreter: The compiler contains a “second backend” for executing code, not just compiling it. The interpreter is “bit-accurate” with the host environment, allowing it to evaluate C++ expressions and functions during translation.
  2. Meta scopes: The @meta keyword specifies that the following statement or block should be executed at compile time. This allows developers to use standard C++ constructs like if and for loops to control code generation.
  3. Same-language reflection: Rather than relying on a complex API for generating Abstract Syntax Tree (AST) nodes, Circle uses “same-language reflection.” Statements inside a meta scope, like a @meta for loop, are programmatically deposited into the final AST for the compiled program.
  4. Introspection keywords: Circle provides built-in keywords for querying type information at compile time, such as counting data members, getting their names, or iterating over enum values. These queries, combined with meta control flow, are used to generate code based on a type’s structure.

SafeC++ using Circle

SafeC++ is an extension of Circle that aims to bring Rust’s rigorous memory safety guarantees to C++ while maintaining backward compatibility. It is not a new language but an opt-in extension. SafeC++ Proposal - D3390

Key features of SafeC++: