Carbon (programming language)

Last updated

Carbon
Carbon logo.png
Logo on Carbon's GitHub organization
Family C
Designed by Google
Typing discipline Static, nominative, partly inferred
Implementation language C++
License Apache-2.0-with-LLVM-Exception
Filename extensions .carbon
Website github.com/carbon-language
Influenced by
C++, Rust, Swift [ citation needed ]

Carbon is an experimental programming language designed for interoperability with C++. [1] The project is 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. [2] [3] [4] The language is expected to have an experimental MVP version 0.1 in 2025 and a production-ready version 1.0 after 2027. [5]

Contents

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 like Rust, that, while 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]

Carbon's documents, design, implementation, and related tools are hosted on GitHub under the Apache-2.0 license with LLVM Exceptions. [11]

Example

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

CarbonC++
packageGeometryapi;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;}
#include<numbers>#include<print>#include<span>#include<stdfloat>#include<vector>// or: import std;structCircle{std::float32_tr;};voidPrintTotalArea(std::span<Circle>circles){std::float32_tarea=0;for(constCircle&c:circles){area+=std::numbers::pi*c.r*c.r;}std::print("Total area: {}\n",area);}intmain(){std::vector<Circle>circles{{.r=1.0},{.r=2.0}};// Implicitly converts `vector` to `span`.PrintTotalArea(circles);return0;}

See also

Related Research Articles

<span class="mw-page-title-main">KornShell</span> Bourne shell backward compatible Unix shell created by David Korn

KornShell (ksh) is a Unix shell which was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983. The initial development was based on Bourne shell source code. Other early contributors were Bell Labs developers Mike Veach and Pat Sullivan, who wrote the Emacs and vi-style line editing modes' code, respectively. KornShell is backward-compatible with the Bourne shell and includes many features of the C shell, inspired by the requests of Bell Labs users.

<span class="mw-page-title-main">Ruby (programming language)</span> General-purpose programming language

Ruby is an interpreted, high-level, general-purpose programming language. It was designed with an emphasis on programming productivity and simplicity. In Ruby, everything is an object, including primitive data types. It was developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.

<span class="mw-page-title-main">LLVM</span> Compiler backend for multiple programming languages

LLVM is a set of compiler and toolchain technologies that can be used to develop a frontend for any programming language and a backend for any instruction set architecture. LLVM is designed around a language-independent intermediate representation (IR) that serves as a portable, high-level assembly language that can be optimized with a variety of transformations over multiple passes. The name LLVM originally stood for Low Level Virtual Machine, though the project has expanded and the name is no longer officially an initialism.

QuickCheck is a software library, specifically a combinator library, originally written in the programming language Haskell, designed to assist in software testing by generating test cases for test suites – an approach known as property testing.

<span class="mw-page-title-main">Clojure</span> Dialect of the Lisp programming language on the Java platform

Clojure is a dynamic and functional dialect of the Lisp programming language on the Java platform.

Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs that communicate with each other over a network or for storing data. The method involves an interface description language that describes the structure of some data and a program that generates source code from that description for generating or parsing a stream of bytes that represents the structured data.

<span class="mw-page-title-main">Node.js</span> JavaScript runtime environment

Node.js is a cross-platform, open-source JavaScript runtime environment that can run on Windows, Linux, Unix, macOS, and more. Node.js runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser.

<span class="mw-page-title-main">Rust (programming language)</span> General-purpose programming language

Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety—meaning that all references point to valid memory—without a garbage collector. To simultaneously enforce memory safety and prevent data races, its "borrow checker" tracks the object lifetime of all references in a program during compilation. Rust was influenced by ideas from functional programming, including immutability, higher-order functions, and algebraic data types. It is popular for systems programming.

Elixir is a functional, concurrent, high-level general-purpose programming language that runs on the BEAM virtual machine, which is also used to implement the Erlang programming language. Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides tooling and an extensible design. The latter is supported by compile-time metaprogramming with macros and polymorphism via protocols.

<span class="mw-page-title-main">Julia (programming language)</span> Dynamic programming language

Julia is a high-level, general-purpose dynamic programming language, most commonly used for numerical analysis and computational science. Distinctive aspects of Julia's design include a type system with parametric polymorphism and the use of multiple dispatch as a core programming paradigm, efficient garbage collection, and a just-in-time (JIT) compiler.

<span class="mw-page-title-main">Atom (text editor)</span> Free and open-source text and source code editor

Atom is a free and open-source text and source-code editor for macOS, Linux, and Windows with support for plug-ins written in JavaScript, and embedded Git control. Developed by GitHub, Atom was released on June 25, 2015.

<span class="mw-page-title-main">Nim (programming language)</span> Programming language

Nim is a general-purpose, multi-paradigm, statically typed, compiled high-level systems programming language, designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages as intermediate representations.

<span class="mw-page-title-main">WebAssembly</span> Cross-platform assembly language and bytecode designed for execution in web browsers

WebAssembly defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment.

<span class="mw-page-title-main">Redox (operating system)</span> Operating system written in Rust

Redox is a Unix-like microkernel operating system written in the programming language Rust, which has a focus on safety, stability, and performance. Redox aims to be secure, usable, and free. Redox is inspired by prior kernels and operating systems, such as SeL4, MINIX, Plan 9, and BSD. It is free and open-source software distributed under an MIT License.

<span class="mw-page-title-main">SYCL</span> Higher-level programming standard for heterogeneous computing

SYCL is a higher-level programming model to improve programming productivity on various hardware accelerators. It is a single-source embedded domain-specific language (eDSL) based on pure C++17. It is a standard developed by Khronos Group, announced in March 2014.

<span class="mw-page-title-main">TOML</span> Configuration file format

Tom's Obvious, Minimal Language (TOML) is a file format for configuration files. It is intended to be easy to read and write due to obvious semantics which aim to be "minimal", and it is designed to map unambiguously to a dictionary. Originally created by Tom Preston-Werner, its specification is open source. TOML is used in a number of software projects and is implemented in many programming languages.

Microsoft, a technology company historically known for its opposition to the open source software paradigm, turned to embrace the approach in the 2010s. From the 1970s through 2000s under CEOs Bill Gates and Steve Ballmer, Microsoft viewed the community creation and sharing of communal code, later to be known as free and open source software, as a threat to its business, and both executives spoke negatively against it. In the 2010s, as the industry turned towards cloud, embedded, and mobile computing—technologies powered by open source advances—CEO Satya Nadella led Microsoft towards open source adoption although Microsoft's traditional Windows business continued to grow throughout this period generating revenues of 26.8 billion in the third quarter of 2018, while Microsoft's Azure cloud revenues nearly doubled.

<span class="mw-page-title-main">Zig (programming language)</span> A general-purpose programming language, toolchain to build Zig/C/C++ code

Zig is an imperative, general-purpose, statically typed, compiled system programming language designed by Andrew Kelley. It is intended to be a successor to the C programming language, with the goals of being even smaller and simpler to program in while also offering modern features, new optimizations and a variety of safety mechanisms while not as demanding of runtime safety as seen in other languages. It is distinct from languages like Go, Rust and Carbon, which have similar goals but also target the C++ space.

Project Verona is an experimental research programming language developed by Microsoft.

References

  1. "README" . Retrieved 6 September 2023. It is designed around interoperability with C++ as well as large-scale adoption and migration for existing C++ codebases and developers.
  2. "Scheduled events for Tuesday, July 19, 09:00 - 10:30". CppNorth, The Canadian C++ Conference, July 17–20, 2022. CppNorth. Retrieved 21 July 2022 via Sched.com.
  3. "Carbon Language: An experimental successor to C++ - Chandler Carruth - CppNorth 2022". CppNorth. 22 July 2022 via YouTube.
  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, retrieved 18 January 2024
  6. "Difficulties improving C++". carbon-language/carbon-lang repo. Google. 21 July 2022 via GitHub.
  7. Carruth, Chandler; Ross-Perkins, Jon; Riley, Matthew; Hummert, Sidney (23 July 2022). "Evolution and governance". carbon-language/carbon-lang repo. Google via GitHub.
  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. Retrieved 24 July 2022.
  12. "carbon-lang/docs/images/snippets.md at trunk · carbon-language/carbon-lang". GitHub. Retrieved 16 December 2023.