Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Example  





2 See also  





3 References  





4 External links  














Carbon (programming language)






 / Bân-lâm-gú
Deutsch
فارسی
Français

Bahasa Indonesia
Italiano
עברית

Русский
Suomi
Türkçe


 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


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

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[edit]

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

Carbon C++
package Geometry;
import Math;

class Circle {
  var r: f32;
}

fn PrintTotalArea(circles: Slice(Circle)) {
  var area: f32 = 0;
  for (c: Circle in circles) {
    area += Math.Pi * c.r * c.r;
  }
  Print("Total area: {0}", area);
}

fn Main() -> i32 {
  // A dynamically sized array, like `std::vector`.
  var circles: Array(Circle) = ({.r = 1.0}, {.r = 2.0});
  // Implicitly converts `Array` to `Slice`.
  PrintTotalArea(circles);
  return 0;
}
#include <numbers>
#include <print>
#include <span>
#include <stdfloat>
#include <vector>
// or: import 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;
}

See also[edit]

References[edit]

  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.
  • ^ "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.
  • ^ "Carbon Language: An experimental successor to C++ - Chandler Carruth - CppNorth 2022". CppNorth. 22 July 2022 – via YouTube.
  • ^ Bradshaw, Kyle (19 July 2022). "Carbon, a new programming language from Google, aims to be C++ successor". 9to5Google.
  • ^ Carbon Language: Roadmap, carbon-language, 11 January 2024, retrieved 18 January 2024
  • ^ "Difficulties improving C++". carbon-language/carbon-lang repo. Google. 21 July 2022 – via GitHub.
  • ^ Carruth, Chandler; Ross-Perkins, Jon; Riley, Matthew; Hummert, Sidney (23 July 2022). "Evolution and governance". carbon-language/carbon-lang repo. Google – via GitHub.
  • ^ Illidge, Myles (21 July 2022). "Google's Carbon programming language aims to replace C++". MyBroadband.
  • ^ Jackson, Joab (20 July 2022). "Google Launches Carbon, an Experimental Replacement for C++". The New Stack.
  • ^ Mustafa, Onsa (20 July 2022). "Carbon, A New Programming Language from Google As A C++ Successor". PhoneWorld.
  • ^ "carbon-lang/LICENSE". GitHub. 16 June 2020. Retrieved 24 July 2022.
  • ^ "carbon-lang/docs/images/snippets.md at trunk · carbon-language/carbon-lang". GitHub. Retrieved 16 December 2023.
  • External links[edit]


  • t
  • e

  • Retrieved from "https://en.wikipedia.org/w/index.php?title=Carbon_(programming_language)&oldid=1225725299"

    Categories: 
    Google
    Programming languages
    Statically typed programming languages
    Cross-platform software
    Object-oriented programming languages
    Programming languages created in 2022
    Google software
    Google stubs
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
    Use dmy dates from July 2022
    All articles with unsourced statements
    Articles with unsourced statements from August 2023
    All stub articles
     



    This page was last edited on 26 May 2024, at 09:19 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki