LoginSignup
20
7

More than 1 year has passed since last update.

C++の後継言語、Carbon Languageについて

Posted at

Carbon Language

先日、Googleの技術者Chandler Carruth氏らが「Carbon Language」をGithubにて公開しました。

現在は実験段階で、実験がうまくいったとしても今後数年は実用が難しいとは言及されています。

How soon can we use Carbon?
Carbon is still years away — even if the experiment succeeds, it's unlikely that it will be ready for serious > or production use in the next few years. Everything here is part of a long-term investigation.

(FAQより)

あまり話題になっていないため、現段階での情報をまとめたいと思います。

要件

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

LLVMを利用したC++に匹敵するパフォーマンスとbit、アドレスの低レベルまでのアクセスを可能に。
既存のC++コードとの相互運用
既存のC++ビルドシステムで動作する高速でスケーラブルなビルド

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

C++習得者であれば容易に習得可能な言語基盤
Carbonバージョン感の簡単なアップグレード
メモリの安全性

(READMEより)

背景

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

C++はパフォーマンスが重要なソフトウェアにとって主要な言語ですが、開発者のニーズである上記要件を満たすためには段階的に改善するのは非常に困難です。
この課題解決のアプローチとして、C++を段階的にではなく、言語基盤から始めることです。

JavaScript → TypeScript
Java → Kotlin
C++ → Carbon

上記のような位置付けを目指すとのこと。
既存のエコシステム上に構築し後継言語として同様の役割を果たす。

目的

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

(C++と一致する)高速なパフォーマンス
ソフトウェアと言語の進化
読みやすく、理解しやすく、描きやすいコード
実用的な安全性とテストメカニズム
高速でスケーラブルな開発
最新のOSプラットフォーム、ハードウェアアーキテクチャ、環境
既存のC++コードとの相互運用性と移行

他言語との比較

Rustを使用できるなら、CarbonではなくRustを使用した方がよいとのこと。

If you can use Rust, ignore Carbon
If you want to use Rust, and it is technically and economically viable for your project, you should use Rust. > In fact, if you can use Rust or any other established programming language, you should. Carbon is for organizations and projects that heavily depend on C++; for example, projects that have a lot of C++ code or use many third-party C++ libraries.

(FAQより)

Rustの他にもGoやSwiftが使用可能であればそちらを使用するべきとのこと。
ただし、C++と比べてこれらの言語ではパフォーマンスのオーバーヘッド等に障壁があるため、C++のモダンな言語Carbonを開発する経緯に至ると続く。

Existing modern languages already provide an excellent developer experience: Go, Swift, Kotlin, Rust, and many more. Developers that can use one of these existing languages should. Unfortunately, the designs of these languages present significant barriers to adoption and migration from C++. These barriers range from changes in the idiomatic design of software to performance overhead.

(READMEより)

使用が想定される場面

Carbonの目的、要件から考えて今までC++で動作していたもののリプレイスという側面が強い(というかメイン)。
従って、プロジェクトとしてCarbonを使用する目的としては以下のような課題に対して使われることになるのではないだろうか。

  • これまでC++で書かれていた大規模なシステムの移行、リプレイス案件
    パフォーマンスを落とすことなく移行が可能
    C++コードに対してソース間変更がCarbonであれば容易であること
    C++開発者にとって取り組みやすい言語であることから

  • C++でのゼロベースからの開発
    技術選定からC++での開発がベストであると結論が出た際に、モダンな言語としての採用が可能

逆に言えば、現段階ではC++以外の言語への強みが薄いように感じる。後継言語の方針としては何も間違ってはいないが、今後の動向に期待している。

参考記事

日本語記事 (READMEの内容が分かりやすく和訳されてまとめられています)
https://www.publickey1.jp/blog/22/ccarbon_languagegooglec.html

20
7
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
7