Introduction
Carbon is an experimental programming language initiated at Google as an evolution path for C++ codebases. It aims to provide modern language features — generics, pattern matching, and improved memory safety — while maintaining bidirectional interoperability with existing C++ code. Carbon is still in early development and not yet ready for production use.
What Carbon Does
- Provides a modern syntax with type inference, pattern matching, and named parameters
- Offers bidirectional C++ interoperability for incremental migration
- Implements checked generics with type constraints instead of templates
- Targets memory safety improvements through a planned safe subset
- Compiles via an LLVM-based toolchain for native performance
Architecture Overview
Carbon's toolchain is built on LLVM and uses Clang for C++ interop. The compiler pipeline processes Carbon source through lexing, parsing, and semantic analysis, lowering to LLVM IR for code generation. The design separates a safe Carbon subset from an unsafe interop layer, allowing gradual migration from C++ while maintaining compatibility at the ABI level.
Self-Hosting & Configuration
- Clone the repository and build with Bazel (requires Clang 18+ and LLVM)
- Use the Carbon Explorer for quick experimentation with the language
- Follow the language design documents in the repository for specification details
- Contribute via the RFC process for language evolution proposals
- Track milestone progress on the GitHub project board
Key Features
- Bidirectional interop with C++ at the function and type level
- Checked generics replacing C++ templates with better error messages
- Sum types and pattern matching for expressive control flow
- Modern syntax free of C++ legacy baggage like header files
- Designed for incremental adoption alongside existing C++ codebases
Comparison with Similar Tools
- C++ — Carbon's direct predecessor; Carbon aims to fix ergonomics while maintaining interop
- Rust — stronger safety guarantees today but no direct C++ interop; Carbon prioritizes migration path
- Zig — targets C interop rather than C++; Carbon focuses specifically on the C++ ecosystem
- cppfront (Cpp2) — Herb Sutter's C++ syntax evolution; Carbon is a separate language with its own semantics
FAQ
Q: Is Carbon ready for production use? A: No. Carbon is explicitly experimental. The team targets a working 1.0 specification but has not set a release date.
Q: Can I mix Carbon and C++ in the same project? A: That is the core design goal. Carbon is designed for bidirectional interop so you can call C++ from Carbon and vice versa.
Q: Does Carbon replace Rust? A: Carbon and Rust serve different niches. Rust is for new projects prioritizing safety. Carbon is for teams with large C++ codebases that need an incremental migration path.
Q: Who is developing Carbon? A: Carbon was initiated by Google engineers but is developed as an open community project with contributions from multiple organizations.