Carbon overview

Elucian MoiseElucian Moise
5 min read

Carbon is an experimental, open-source programming language developed by Google. It is designed to be a successor to C++, and aims to address some of the shortcomings of C++ while still providing a similar feature set. Carbon is still in its early stages of development, but it has the potential to be a powerful and versatile language for a wide range of applications.

The Carbon project was announced on May 11, 2022, by Google CEO Sundar Pichai. The project is led by Ilya Sukhanov, who is the Vice President of Engineering at Google.

Carbon is a new programming language that is designed to be more efficient and safer than C++. It is still under development, but it has the potential to be a major player in the programming language landscape.

Features

  • Memory safety: Carbon is a memory-safe language, which means that it prevents developers from accidentally accessing or modifying memory that they are not supposed to. This can help to prevent crashes and security vulnerabilities.

  • Type safety: Carbon is a statically typed language, which means that the types of variables and expressions are checked at compile time. This can help to catch errors early on, and can make it easier to reason about the behavior of code.

  • Generics: Carbon supports generics, which allow developers to write code that can be used with different types of data. This can make code more reusable and easier to maintain.

  • Functional programming features: Carbon supports some functional programming features, such as lambda expressions and closures. This can make it easier to write code that is concise and elegant.

The status of Carbon project is currently under development. The language is still in its early stages, but it has the potential to be a powerful and versatile language for a wide range of applications. Google has released several tools and resources for developers who want to learn more about Carbon and contribute to the project.

Example

For now, none of AI Bots: Rix, ChatGPT nor Bart can generate Carbon code. So I have copied this example from the Carbon documentation. This is what the syntax looks like. It looks more like Rust but also has different keywords Rust does not have.

// Carbon:
package Geometry api;
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 constructs `Slice` from `Array`.
  PrintTotalArea(circles);
  return 0;
}

References

Carbon has a repository on GitHub and readme.md file contains links to documentation, examples of code and the invitation to Discord community. Compiler enthusiasts and system programmers can investigate and contribute.

https://github.com/carbon-language/carbon-lang


Bard evaluation:

Carbon is a new programming language developed by Google that is still under development. It is designed to be a high-performance, memory-efficient, and expressive language that is suitable for a wide range of applications.

Carbon has several advantages over Rust and Go, two other programming languages developed by Google. First, Carbon is designed to be more expressive than Rust and Go. This means that it is easier to write concise and readable code in Carbon. Second, Carbon is designed to be more memory-efficient than Rust and Go. This means that Carbon programs can use less memory than Rust and Go programs, which can be important for applications that are running on resource-constrained devices. Third, Carbon is designed to be more high-performance than Rust and Go. This means that Carbon programs can run faster than Rust and Go programs, which can be important for applications that require high performance.

Overall, Carbon is a promising new programming language that has the potential to replace Rust and Go as the language of choice for a wide range of applications. Here are some of the advantages of Carbon over Rust and Go:

  • Expressiveness: Carbon is designed to be more expressive than Rust and Go, which means that it is easier to write concise and readable code in Carbon.

  • Memory efficiency: Carbon is designed to be more memory-efficient than Rust and Go, which means that Carbon programs can use less memory than Rust and Go programs.

  • Performance: Carbon is designed to be more high-performance than Rust and Go, which means that Carbon programs can run faster than Rust and Go programs.

In addition to these advantages, Carbon also has a number of other features that make it a compelling choice for developers. For example, Carbon is designed to be easy to learn and use, and it has a large and active community of developers who are working to improve the language.

Overall, Carbon is a promising new programming language that has the potential to become a major player in the programming language landscape. It is still under development, but it has the potential to replace Rust and Go as the language of choice for a wide range of applications.


Conclusion

I can't predict the future of the Carbon Language. Google has shut down projects before and there is a lot of competition from Dart and Go languages that are already established. I think the objective of Carbon is ambitious but the syntax of the new language looks suspiciously like Rust. Be mindful bout this language, which is a strong competitor for other system languages. I'm excited to see it growing.


Disclaim. This paper was created with Google Bard. Also contains my conclusion. You can derive your own conclusion. I'm curious about other opinions.

0
Subscribe to my newsletter

Read articles from Elucian Moise directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Elucian Moise
Elucian Moise

Software engineer instructor, software developer and community leader. Computer enthusiast and experienced programmer. Born in Romania, living in US.