English
Why? | Goals | Status | Getting started | Join us
See our announcement video from CppNorth. Note that Carbon is not ready for use.
corresponds to this Carbon code:
You can call Carbon from C++ without overhead and the other way around. This means you migrate a single C++ library to Carbon within an application, or write new Carbon on top of your existing C++ investment. For example:
Read more about C++ interop in Carbon.
Beyond interoperability between Carbon and C++, we're also planning to support migration tools that will mechanically translate idiomatic C++ code into Carbon code to help you switch an existing C++ codebase to Carbon.
Carbon provides a modern generics system with checked definitions, while still supporting opt-in templates for seamless C++ interop. Checked generics provide several advantages compared to C++ templates:
Without sacrificing these advantages, Carbon generics support specialization, ensuring it can fully address performance-critical use cases of C++ templates. For more details about Carbon's generics, see their design.
In addition to easy and powerful interop with C++, Carbon templates can be constrained and incrementally migrated to checked generics at a fine granularity and with a smooth evolutionary path.
Safety, and especially memory safety, remains a key challenge for C++ and something a successor language needs to address. Our initial priority and focus is on immediately addressing important, low-hanging fruit in the safety space:
Once we can migrate code into Carbon, we will have a simplified language with room in the design space to add any necessary annotations or features, and infrastructure like generics to support safer design patterns. Longer term, we will build on this to introduce a safe Carbon subset. This will be a large and complex undertaking, and won't be in the 0.1 design. Meanwhile, we are closely watching and learning from efforts to add memory safe semantics onto C++ such as Rust-inspired lifetime annotations.
To try out Carbon immediately in your browser, you can use the demo interpreter for Carbon on: carbon.compiler-explorer.com.
We are developing a traditional toolchain for Carbon that can compile and link programs. However, Carbon is still an early, experimental project, and so we only have very experimental nightly releases of the Carbon toolchain available to download, and only on limited platforms. If you are using a recent Ubuntu Linux or similar (Debian, WSL, etc.), you can try these out by going to our releases page and download the latest nightly toolchain tar file: carbon_toolchain-0.0.0-0.nightly.YYYY.MM.DD.tar.gz. Then you can try it out:
carbon_toolchain-0.0.0-0.nightly.YYYY.MM.DD.tar.gz
# A variable with the nightly version from yesterday: VERSION="$(date -d yesterday +0.0.0-0.nightly.%Y.%m.%d)" # Get the release wget https://github.com/carbon-language/carbon-lang/releases/download/v${VERSION}/carbon_toolchain-${VERSION}.tar.gz # Unpack the toolchain: tar -xvf carbon_toolchain-${VERSION}.tar.gz # Create a simple Carbon source file: echo "fn Run() { Core.Print(42); }" > forty_two.carbon # Compile to an object file: ./carbon_toolchain-${VERSION}/bin/carbon compile --output=forty_two.o forty_two.carbon # Install minimal system libraries used for linking. Note that installing `gcc` # or `g++` for compiling C/C++ code with GCC will also be sufficient, these are # just the specific system libraries Carbon linking still uses. sudo apt install libgcc-11-dev # Link to an executable: ./carbon_toolchain-${VERSION}/bin/carbon link --output=forty_two forty_two.o # Run it: ./forty_two
As a reminder, the toolchain is still very early and many things don't yet work. Please hold off on filing lots of bugs: we know many parts of this don't work yet or may not work on all systems. We expect to have releases that are much more robust and reliable that you can try out when we reach our 0.1 milestone.
If you want to build Carbon's toolchain yourself or are thinking about contributing fixes or improvements to Carbon, you'll need to install our build dependencies (Clang, LLD, libc++) and check out the Carbon repository. For example, on Debian or Ubuntu:
# Update apt. sudo apt update # Install tools. sudo apt install clang libc++-dev libc++abi-dev lld # Download Carbon's code. $ git clone https://github.com/carbon-language/carbon-lang $ cd carbon-lang
Then you can try out our toolchain which has a very early-stage compiler for Carbon:
# Build and run the toolchain's help to get documentation on the command line. $ ./scripts/run_bazelisk.py run //toolchain -- help
For complete instructions, including installing dependencies on various different platforms, see our contribution tools documentation.
Learn more about the Carbon project:
Carbon focused talks from the community:
We'd love to have folks join us and contribute to the project. Carbon is committed to a welcoming and inclusive environment where everyone can contribute.
You can also directly:
You can check out some "good first issues", or join the #contributing-help channel on Discord. See our full CONTRIBUTING documentation for more details.
#contributing-help
CONTRIBUTING