Introduction
Carbon is an experimental programming language created by Google as a potential successor to C++. It aims to provide a modern development experience while maintaining full interoperability with existing C++ codebases, allowing teams to migrate incrementally.
What Carbon Does
- Provides a modern syntax with type inference, pattern matching, and generics
- Offers seamless bidirectional interoperability with C++ code
- Delivers performance comparable to C++ without garbage collection
- Introduces memory safety features beyond what C++ provides
- Supports incremental migration from existing C++ projects
Architecture Overview
Carbon compiles through a custom toolchain built on LLVM. The language uses a layered design: a core language with minimal built-in types, a standard library providing common abstractions, and an interop layer that maps between Carbon and C++ types. The build system integrates with Bazel for the reference implementation.
Self-Hosting & Configuration
- Requires Bazel and LLVM toolchain for building from source
- Supports Linux and macOS development environments
- Uses Clang as the underlying C++ compiler for interop
- Configuration via BUILD files and Carbon package manifests
- Explorer tool available for experimenting with language features
Key Features
- Bidirectional C++ interop without FFI overhead
- Modern generics system with checked definitions
- Pattern matching and sum types for safe data handling
- Fast compilation model designed for large codebases
- Open governance with community RFC process
Comparison with Similar Tools
- C++ — Carbon aims to succeed C++ with better ergonomics while maintaining interop
- Rust — Rust requires rewriting; Carbon allows incremental migration from C++
- Zig — Zig targets C interop; Carbon specifically targets C++ codebases
- Circle — Circle extends C++; Carbon is a distinct language with C++ bridging
- Val (Hylo) — Val explores mutable value semantics; Carbon focuses on C++ migration
FAQ
Q: Is Carbon ready for production use? A: No. Carbon is still experimental and under active design. The team recommends not using it for production code yet.
Q: Can I call C++ libraries from Carbon directly? A: Yes. Bidirectional interop is a core design goal, allowing Carbon code to call C++ and vice versa without manual bindings.
Q: Will Carbon replace C++ at Google? A: Carbon is an experiment exploring what a C++ successor could look like. There is no official commitment to replace C++ company-wide.
Q: How does Carbon compare to Rust for safety? A: Carbon aims for a safety model that allows incremental adoption from C++ codebases. Rust provides stronger guarantees but requires full rewrites.