Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Carbon Language's main repository: documents, design, implementation, and related tools. (NOTE: Carbon Language is experimental; see README)

License

NotificationsYou must be signed in to change notification settings

carbon-language/carbon-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Why? |Goals |Status |Getting started |Join us

See ourannouncement video fromCppNorth. Note that Carbon isnot ready for use.

Quicksort code in Carbon. Follow the link to read more.

Fast and works with C++

  • Performance matching C++ using LLVM, with low-level access to bits andaddresses
  • Interoperate with your existing C++ code, from inheritance to templates
  • Fast and scalable builds that work with your existing C++ build systems

Modern and evolving

  • Solid language foundations that are easy to learn, especially if you haveused C++
  • Easy, tool-based upgrades between Carbon versions
  • Safer fundamentals, and an incremental path towards a memory-safe subset

Welcoming open-source community

  • Clear goals and priorities with robust governance
  • Community that works to be welcoming, inclusive, and friendly
  • Batteries-included approach: compiler, libraries, docs, tools, packagemanager, and more

Why build Carbon?

C++ remains the dominant programming language for performance-critical software,with massive and growing codebases and investments. However, it is struggling toimprove and meet developers' needs, as outlined above, in no small part due toaccumulating decades of technical debt. Incrementally improving C++ isextremely difficult, both due tothe technical debt itself and challenges with its evolution process. The bestway to address these problems is to avoid inheriting the legacy of C or C++directly, and instead start with solid language foundations likemodern generics system, modular code organization, and consistent,simple syntax.

Existing modern languages already provide an excellent developer experience: Go,Swift, Kotlin, Rust, and many more.Developers thatcan use one of theseexisting languagesshould. Unfortunately, the designs of these languagespresent significant barriers to adoption and migration from C++. These barriersrange from changes in the idiomatic design of software to performance overhead.

Carbon is fundamentallya successor language approach, rather than anattempt to incrementally evolve C++. It is designed around interoperability withC++ as well as large-scale adoption and migration for existing C++ codebases anddevelopers. A successor language for C++ requires:

  • Performance matching C++, an essential property for our developers.
  • Seamless, bidirectional interoperability with C++, such that a libraryanywhere in an existing C++ stack can adopt Carbon without porting the rest.
  • A gentle learning curve with reasonable familiarity for C++ developers.
  • Comparable expressivity and support for existing software's design andarchitecture.
  • Scalable migration, with some level of source-to-source translation foridiomatic C++ code.

With this approach, we can build on top of C++'s existing ecosystem, and bringalong existing investments, codebases, and developer populations. There are afew languages that have followed this model for other ecosystems, and Carbonaims to fill an analogous role for C++:

  • JavaScript → TypeScript
  • Java → Kotlin
  • C++ →Carbon

Language Goals

We are designing Carbon to support:

  • Performance-critical software
  • Software and language evolution
  • Code that is easy to read, understand, and write
  • Practical safety and testing mechanisms
  • Fast and scalable development
  • Modern OS platforms, hardware architectures, and environments
  • Interoperability with and migration from existing C++ code

While many languages share subsets of these goals, what distinguishes Carbon istheir combination.

We also have explicitnon-goals for Carbon, notably including:

Our detailedgoals document fleshes out these ideasand provides a deeper view into our goals for the Carbon project and language.

Project status

Carbon Language is currently an experimental project. We are hard at work on atoolchain implementation with compiler and linker. You can try out the currentstate atcompiler-explorer.com.

We want to better understand whether we can build a language that meets oursuccessor language criteria, and whether the resulting language can gather acritical mass of interest within the larger C++ industry and community.

Currently, we have fleshed out several core aspects of both Carbon the projectand the language:

  • The strategy of the Carbon Language and project.
  • An open-source project structure, governance model, and evolution process.
  • Critical and foundational aspects of the language design informed by ourexperience with C++ and the most difficult challenges we anticipate. Thisincludes designs for:
    • Generics
    • Class types
    • Inheritance
    • Operator overloading
    • Lexical and syntactic structure
    • Code organization and modular structure
  • An under-developmentcompiler and toolchain that will compileCarbon (and eventually C++ code as well) into standard executable code. Thisis where most of our current implementation efforts are directed.
    • Historically, there was also a prototypeexplorer interpreter thatimplemented an older version of the Carbon language design, but is nolonger under development and has been archived.

If you're interested in contributing, we're currently focused on developing theCarbon toolchain until it cansupport Carbon ↔ C++ interop.Beyond that, we plan to continue developing the design and toolchain until wecan ship the0.1 languageand support evaluating Carbon in more detail.

You can see ourfull roadmap for more details.

Carbon and C++

If you're already a C++ developer, Carbon should have a gentle learning curve.It is built out of a consistent set of language constructs that should feelfamiliar and be easy to read and understand.

C++ code like this:

A snippet of C++ code. Follow the link to read it.

corresponds to this Carbon code:

A snippet of converted Carbon code. Follow the link to read it.

You can call Carbon from C++ without overhead and the other way around. Thismeans you migrate a single C++ library to Carbon within an application, or writenew Carbon on top of your existing C++ investment. For example:

A snippet of mixed Carbon and C++ code. Follow the link to read it.

Read more aboutC++ interop in Carbon.

Beyond interoperability between Carbon and C++, we're also planning to supportmigration tools that will mechanically translate idiomatic C++ code into Carboncode to help you switch an existing C++ codebase to Carbon.

Generics

Carbon provides amodern generics systemwith checked definitions, while stillsupporting opt-intemplates for seamless C++ interop. Checkedgenerics provide several advantages compared to C++ templates:

  • Generic definitions are fully type-checked, removing the need toinstantiate to check for errors and giving greater confidence in code.
    • Avoids the compile-time cost of re-checking the definition for everyinstantiation.
    • When using a definition-checked generic, usage error messages areclearer, directly showing which requirements are not met.
  • Enables automatic, opt-in type erasure and dynamic dispatch without aseparate implementation. This can reduce the binary size and enablesconstructs like heterogeneous containers.
  • Strong, checked interfaces mean fewer accidental dependencies onimplementation details and a clearer contract for consumers.

Without sacrificing these advantages,Carbon generics supportspecialization, ensuring it can fully address performance-critical use casesof C++ templates. For more details about Carbon's generics, see theirdesign.

In addition to easy and powerful interop with C++, Carbon templates can beconstrained and incrementally migrated to checked generics at a fine granularityand with a smooth evolutionary path.

Memory safety

Safety, and especiallymemory safety, remains a keychallenge for C++ and something a successor language needs to address. Ourinitial priority and focus is on immediately addressing important, low-hangingfruit in the safety space:

  • Tracking uninitialized states better, increased enforcement ofinitialization, and systematically providing hardening againstinitialization bugs when desired.
  • Designing fundamental APIs and idioms to support dynamic bounds checks indebug and hardened builds.
  • Having a default debug build mode that is both cheaper and morecomprehensive than existing C++ build modes even when combined withAddress Sanitizer.

Once we can migrate code into Carbon, we will have a simplified language withroom in the design space to add any necessary annotations or features, andinfrastructure likegenerics to support safer design patterns.Longer term, we will build on this to introducea safe Carbon subset. Thiswill 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 safesemantics onto C++ such as Rust-inspiredlifetime annotations.

Getting started

To try out Carbon immediately in your browser, you can use the toolchain at:carbon.compiler-explorer.com.

We are developing a traditional toolchain for Carbon that can compile and linkprograms. However, Carbon is still an early, experimental project, and so weonly have very experimental nightly releases of the Carbon toolchain availableto download, and only on limited platforms. If you are using a recent UbuntuLinux or similar (Debian, WSL, etc.), you can try these out by going to ourreleases page anddownload the latest nightly toolchain tar file:carbon_toolchain-0.0.0-0.nightly.YYYY.MM.DD.tar.gz. Then you can try it out:

# A variable with the nightly version from yesterday:VERSION="$(date -d yesterday +0.0.0-0.nightly.%Y.%m.%d)"# Get the releasewget 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"import Core library\"io\"; 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 workyet or may not work on all systems. We expect to have releases that are muchmore robust and reliable that you can try out when we reach our0.1 milestone.

If you want to build Carbon's toolchain yourself or are thinking aboutcontributing fixes or improvements to Carbon, you'll need to install ourbuild dependencies (Clang,LLD, libc++) and check out the Carbon repository. For example, on Debian orUbuntu:

# 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 forCarbon:

# 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 variousdifferent platforms, see ourcontribution tools documentation.

Learn more about the Carbon project:

Conference talks

Carbon focused talks from the community:

2024

  • Generic implementation strategies in Carbon and Clang, LLVM Developers'Meeting (video,slides)
  • The Carbon Language: Road to 0.1, NDC {TechTown}(video,slides)
  • How designing Carbon with C++ interop taught me about C++ variadics andoverloads, CppNorth (video,slides)
  • Generic Arity: Definition-Checked Variadics in Carbon, C++Now(video,slides)
  • Carbon: An experiment in different tradeoffs, panel session, EuroLLVM(video,slides)
  • Carbon's high-level semantic IR lightning talk, EuroLLVM(video)

2023

  • Carbon’s Successor Strategy: From C++ interop to memory safety, C++Now(video,slides)
  • Definition-Checked Generics, C++Now
  • Modernizing Compiler Design for Carbon’s Toolchain, C++Now(video,slides)

2022

  • Carbon Language: Syntax and trade-offs, Core C++(video,slides)
  • Carbon Language: An experimental successor to C++, CppNorth(video,slides)

Other videos

We additionally havetoolchain videos.

Join us

We'd love to have folks join us and contribute to the project. Carbon iscommitted to a welcoming and inclusive environment where everyone cancontribute.

Contributing

You can also directly:

You cancheck out some"good first issues",or join the#contributing-help channel onDiscord. See our fullCONTRIBUTING documentation for more details.

About

Carbon Language's main repository: documents, design, implementation, and related tools. (NOTE: Carbon Language is experimental; see README)

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp