Carbon (programming language): Difference between revisions

Content deleted Content added
moved clear template for better layout and less wasted whitespace, still avoids the example and the infobox getting in each other's way
m rv IP 1 April 2024
 
(13 intermediate revisions by 8 users not shown)
Line 10:
| designer = [[Google]]
| typing = [[Static type|Static]], [[Nominal type system|nominative]], [[Type inference|partly inferred]]
| influenced by = [[C++]], [[Rust (programming language)|Rust]], [[SwiftZig (programming language)|SwiftZig]], [[Haskell {{citation(programming neededlanguage)|dateHaskell]], [[Kotlin (programming language)|Kotlin]], [[Swift (programming language)|Swift]]<ref name=August"cppnorthkeynote-video" 2023}}/>
| programming language = [[C++]]
| license = [[Apache-2.0-with-LLVM-Exception]]
Line 17:
}}
 
'''Carbon''' is an experimental [[programming language]] designed for connectivenessinteroperability with [[C++]].<ref name="readme">{{cite web|title=README|url=https://github.com/carbon-language/carbon-lang/blob/trunk/README.md|quote="It is designed around interoperability with C++ as well as large-scale adoption and migration for existing C++ codebases and developers."|accessdate=2023-09-06}}</ref> The project is [[Open-source software|open-source]] and was started at [[Google]]. Google engineer Chandler Carruth first introduced Carbon at the CppNorth conference in [[Toronto]] in July 2022. He stated that Carbon was created to be a C++ successor.<ref name="cppnorthkeynote-sched" /><ref name="cppnorthkeynote-video" /><ref name="cppnorthkeynote-9to5google" /> The language is expected to have an experimental [[Minimum viable product|MVP]] version 0.1 in 2025late 2026 at the earliest and a production-ready version 1.0 after 20272028.<ref>{{Citation |title=Carbon Language: Roadmap |date=2024-01-11 |url=https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/roadmap.md |publisher=carbon-language |access-date=2024-01-18}}</ref>
 
The language intends to fix several perceived shortcomings of C++<ref name="difficulties improving cpp" /> but otherwise provides a similar feature set.
Line 62:
</syntaxhighlight>
| <syntaxhighlight lang="c++" line="1">
#include <numbers>
#include <print>
#include <span>
#include <stdfloat>
#include <vector>
//using or: importnamespace std;
 
struct Circle {
std::float32_t r;
};
 
void PrintTotalArea(std::span<Circle> circles)
{
std::float32_t area = 0;
for (const Circle& c : circles) {
area += std::numbers::pi * c.r * c.r;
}
std::print("Total area: {}\n", area);
}
 
int main() {
std::vector<Circle> circles{{.r = 1.0}, {.r = 2.0}};
// Implicitly converts `vector` to `span`.
 
PrintTotalArea(circles);
return 0;
Line 98 ⟶ 96:
* [[Go (programming language)|Go]]
* [[Rust (programming language)|Rust]]
* [[Ring (programming language)|Ring]]
* [[Mojo (programming language)|Mojo]]
* [[V (programming language)|V]]
 
== References ==
Line 179 ⟶ 175:
== External links ==
* {{GitHub|carbon-language}}
* [https://docs.carbon-lang.dev/ Carbon language documentation]
* [https://carbon.godbolt.org/ Carbon at the Compiler Explorer (godbolt)]
 
Line 191 ⟶ 188:
[[Category:Programming languages created in 2022]]
[[Category:Google software]]
 
 
{{Google-stub}}