Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Carbon (programming language)

From Wikipedia, the free encyclopedia
Programming language designed for interoperability with C++

Carbon
A dark-gray circle with a white sans-serif letter "C" in the middle
Logo on Carbon's GitHub organization
FamilyC
Designed byGoogle
Typing disciplineStatic,nominative,partly inferred
Implementation languageC++
LicenseApache-2.0-with-LLVM-Exception
Filename extensions.carbon
Websitegithub.com/carbon-language
Influenced by
C++,Rust,Zig,Haskell,Kotlin,Swift[1]

Carbon is an experimentalprogramming language designed for interoperability withC++.[2] The project isopen-source and was started atGoogle. Google's engineer Chandler Carruth first introduced Carbon at the CppNorth conference inToronto in July 2022. He stated that Carbon was created to be a C++ successor.[3][1][4] The language is expected to have an experimentalMVP version 0.1 in late 2026 at the earliest and a production-ready version 1.0 after 2028.[5]

The language intends to fix several perceived shortcomings of C++[6] but otherwise provides a similar feature set.The main goals of the language are readability and "bi-directional interoperability" (which allows the user to include C++ code in the Carbon file), as opposed to using a new language likeRust, that, whilst being influenced by C++, is not two-way compatible with C++ programs. Changes to the language will be decided by the Carbon leads.[7][8][9][10] It aims to build on top of the C++ ecosystem the way in an analogous role toTypeScript toJavaScript, orKotlin toJava.[2]

Carbon's documents, design, implementation, and related tools are hosted onGitHub under theApache-2.0 license withLLVM Exceptions.[11]

Example

[edit]

The following shows how a program might be written in Carbon and C++:[12]

CarbonC++
packageGeometry;importMath;classCircle{varr:f32;}fnPrintTotalArea(circles:Slice(Circle)){vararea:f32=0;for(c:Circleincircles){area+=Math.Pi*c.r*c.r;}Print("Total area: {0}",area);}fnMain()->i32{// A dynamically sized array, like `std::vector`.varcircles:Array(Circle)=({.r=1.0},{.r=2.0});// Implicitly converts `Array` to `Slice`.PrintTotalArea(circles);return0;}
importstd;usingstd::span;usingstd::vector;structCircle{floatr;};voidPrintTotalArea(span<Circle>circles){floatarea=0.0f;for(constCircle&c:circles){area+=std::numbers::pi*c.r*c.r;}std::println("Total area: {}",area);}intmain(){vector<Circle>circles{{.r=1.0f},{.r=2.0f}};// Implicitly converts `vector` to `span`.PrintTotalArea(circles);return0;}

See also

[edit]

References

[edit]
  1. ^ab"Carbon Language: An experimental successor to C++ - Chandler Carruth - CppNorth 2022". CppNorth. 22 July 2022 – viaYouTube.
  2. ^ab"README". Retrieved6 September 2023.It is designed around interoperability with C++ as well as large-scale adoption and migration for existing C++ codebases and developers.
  3. ^"Scheduled events for Tuesday, July 19, 09:00 - 10:30".CppNorth, The Canadian C++ Conference, July 17–20, 2022. CppNorth. Retrieved21 July 2022 – via Sched.com.
  4. ^Bradshaw, Kyle (19 July 2022)."Carbon, a new programming language from Google, aims to be C++ successor".9to5Google.
  5. ^Carbon Language: Roadmap, carbon-language, 11 January 2024, retrieved18 January 2024
  6. ^"Difficulties improving C++".carbon-language/carbon-lang repo.Google. 21 July 2022 – viaGitHub.
  7. ^Carruth, Chandler; Ross-Perkins, Jon; Riley, Matthew; Hummert, Sidney (23 July 2022)."Evolution and governance".carbon-language/carbon-lang repo.Google – viaGitHub.
  8. ^Illidge, Myles (21 July 2022)."Google's Carbon programming language aims to replace C++".MyBroadband.
  9. ^Jackson, Joab (20 July 2022)."Google Launches Carbon, an Experimental Replacement for C++".The New Stack.
  10. ^Mustafa, Onsa (20 July 2022)."Carbon, A New Programming Language from Google As A C++ Successor".PhoneWorld.
  11. ^"carbon-lang/LICENSE".GitHub. 16 June 2020. Retrieved24 July 2022.
  12. ^"carbon-lang/docs/images/snippets.md at trunk · carbon-language/carbon-lang".GitHub. Retrieved16 December 2023.

External links

[edit]
Google free and open-source software
Software
Applications
Programming languages
Frameworks and
development tools
Operating systems
Related
a subsidiary ofAlphabet
Company
Divisions
Subsidiaries
Active
Defunct
Programs
Events
Infrastructure
People
Current
Former
Criticism
General
Incidents
Other
Software
A–C
D–N
O–Z
Operating systems
Machine learning models
Neural networks
Computer programs
Formats and codecs
Programming languages
Search algorithms
Domain names
Typefaces
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Y
Hardware
Pixel
Smartphones
Smartwatches
Tablets
Laptops
Other
Nexus
Smartphones
Tablets
Other
Other
Advertising
Antitrust
Intellectual
property
Privacy
Other
Related
Concepts
Products
Android
Street View coverage
YouTube
Other
Documentaries
Books
Popular culture
Other
Retrieved from "https://en.wikipedia.org/w/index.php?title=Carbon_(programming_language)&oldid=1317514568"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp