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 connectiveness 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, 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]

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++
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;}
#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">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.

CppCMS is an open-source web application framework for the C++ programming language developed by Artyom Beilis. The primary goal of CppCMS is building performance-demanding web applications. It may also be used for embedded web applications for consumer devices. The library is available under MIT license. It currently targets POSIX-compatible platforms as well as Microsoft Windows.

<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.

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">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">Visual Studio Code</span> Source code editor developed by Microsoft

Visual Studio Code, also commonly referred to as VS Code, is a source-code editor developed by Microsoft for Windows, Linux, macOS and web browsers. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded version control with Git. Users can change the theme, keyboard shortcuts, preferences, and install extensions that add functionality.

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

WebAssembly (Wasm) 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">RocksDB</span> Embedded key-value database

RocksDB is a high performance embedded database for key-value data. It is a fork of Google's LevelDB optimized to exploit multi-core processors (CPUs), and make efficient use of fast storage, such as solid-state drives (SSD), for input/output (I/O) bound workloads. It is based on a log-structured merge-tree data structure. It is written in C++ and provides official language bindings for C++, C, and Java. Many third-party language bindings exist. RocksDB is free and open-source software, released originally under a BSD 3-clause license. However, in July 2017 the project was migrated to a dual license of both Apache 2.0 and GPLv2 license. This change helped its adoption in Apache Software Foundation's projects after blacklist of the previous BSD+Patents license clause.

<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.

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 as a successor to the language C, with the intent of being even smaller and simpler to program in, while offering more function. It is free and open-source software, released under an MIT License.

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

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

V, also known as vlang, is a statically typed, compiled programming language created by Alexander Medvednikov in early 2019. It was inspired by the language Go, and other influences including Oberon, Swift, and Rust. It is free and open-source software released under the MIT License, and currently in beta.

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.