Can Google’s Carbon Language Replace C++? | Built In (2024)

It’s really happening. Google developers have released a brand-new, experimental, open-sourced language named Carbon.

Carbon could serve as a successor language to C++, and it’s one that provides a simple starting point for developers to a newer language that addresses contemporary development concepts like memory safety and generics.

This would be similar to how Microsoft built Typescript to update JavaScript and Kotlin to strengthen weaknesses in Java.

Google developer Chandler Carruth unveiled the language in July 2022 at the CPP North conference in Toronto by Google developer Chandler Carruth.

I’ll summarize a few points from the conference and add some flavor from other resources, comments, tweets and documentation, etc.

What’s Wrong With C++?

In the words of Carruth in his Carbon documentation on Github:

“C++ is the dominant programming language for the performance critical software our goals prioritize. The most direct way to deliver a modern and excellent developer experience for those use cases and developers would be to improve C++.

Improving C++ to deliver the kind of experience developers expect from a programming language today is difficult.”

More on Software Development: Google Foobar Challenge: Level 1 Tutorial

Why Is It Difficult To Improve C++?

Carruth mentioned a few points that can be summarized in two areas: language and bureaucracy

Language

  • Technical debt: Necessary choices that made C++ great are becoming a burden. C++ accumulated decades of technical debt.
  • Prioritization of backward compatibility: More and more features have been added rather than removed or replaced. While backward compatibility is important, it comes at a cost. It adds and prevents fixing the technical debt.

Governance

  • Processes: The process to improve C++ goes through a bureaucratic committee approach that prioritizes standardization above design.
  • Limited access: Access to the committee and standard is restricted and expensive.
  • Interests of the few: While some nations and companies are represented, many other stakeholders are not.
  • Lengthy decision process: Decisions can take years, or not reach any definitive conclusion.

All told, it’s difficult to improve C++.

Having said that, other garbage-collected languages were considered but didn’t meet the performance required by specific users and organizations.

What Is Carbon?

As stated in the goals, “Carbon is an experiment to explore a possible, distant future for the C++ programming language designed around a specific set of goals, priorities and use cases.”

Syntax

Among the presented features, it is worth mentioning:

  • Introducer keywords: fn for function, var for variable declarations.
  • Function input parameters are read-only values.
  • Pointers provide indirect access and mutation.
  • Expressions to name type.
  • The namespace at the root is always local.
  • Public members by default. The reasoning seems to be that since you will mostly read the public functions in your API, it makes sense to expose them.
  • Type checking generics.

This list is by no means complete, but it gives an overview of some characteristics of the language.

Below you can see a snippet from the example code on GitHub, with some simple comments from my side.

// Carbon:package Geometry api; // local namespaceimport Math; // library importclass 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);}

Is Carbon a Successor Language for C++?

The team behind Carbon spent some time considering how other languages could tackle these issues.

Rust might seem a great solution, and the recommendation is clear. If Rust works for you today, you should use it, but moving a C++ ecosystem to Rust is hard.

Carbon aims to replace large C++ codebases that are difficult to convert into Rust.

Furthermore, Carruth observed how each of them was designed for a purpose and introduced the concept of successor languages.

According to Carruth, successor languages are:

  • Built on an existing ecosystem without bootstrapping a new one.
  • Provide bi-directional interoperability.
  • Optimize the learning curve and adoption path.
  • Ideally have tool-assisted migration support.

Given the context, it seems reasonable to think of a new purpose-driven language that builds on the six goals for C++ and adds one more:

  1. Performance-critical software.
  2. Software and language evolution.
  3. Code that is easy to read, understand and write.
  4. Practical safety and testing mechanisms.
  5. Fast and scalable development.
  6. Modern OS platforms, hardware architectures and environments.
  7. Interoperability with and migration from existing C++ code.

What Are the Advantages of Carbon?

Starting from the difficulties experienced in the language and in the governance, Carbon adopts a different approach for both areas.

Language

Carbon wants to start from scratch including:

  • Modern generics system.
  • Modular code organization.
  • Simple syntax.

Carbon wants to be “a successor language […], rather than an attempt to incrementally evolve C++,” according to Carruth’s post on carbon-lang.

For this reason, it gave up on transparent backward compatibility while remaining interoperable with and migratable from C++.

Governance

Carbon wants to be more inclusive by:

  • Building on open-source principles, processes and tools. This makes contributing easier and more transparent.
  • Having a clear governance structure that can make decisions rapidly when needed.
  • Expanding the ecosystem with tools that provide a rich developer experience (compiler, standard library and IDE tools) and tool-based upgrades.
  • Bridging a gap in the C++ ecosystem with a built-in package manager.

How Will Carbon Be Governed?

Carruth expanded on Carbon’s governance while talking about culture and community. This includes:

  • An inclusive and welcoming community, with a comprehensive code of conduct.
  • A friendly and approachable community.
  • Open process for governance and changes.
  • Decisions with clear rationale, especially when a difficult trade off.

Though Google first founded Carbon, the aim is to reduce the contributions from any single company to less than 50 percent by the year’s end.

Eventually, they hope to transfer ownership of the project to a nonprofit software foundation, where it will be developed by volunteers.

How Has Carbon Been Received?

As Carbon has rolled out, developers have shared their feelings via posts, tweets and comments:

  • Developers seem to be mostly optimistic about Carbon
  • Most love the interoperability with C++.
  • There is some skepticism around Carbon replacing C++. Some argue that Carbon will excel in a niche but won’t become widely adopted.
  • Immutable declarations are preponed by let, which might be confusing for developers coming from JavaScript. However, this will be smooth for devs coming from Swift.
  • Public members by default seems to be a controversial decision. The reasoning seems to be that since you will mostly read the public functions in your API, it makes sense to expose them.
  • Rust supporters have been addressed: “If Rust works for you today, you should use it. But moving a C++ ecosystem to Rust is hard.”

It’s still too early to evaluate Carbon, but it’s exciting to see a new project starting from scratch and making its first steps.

If you are interested, you could contribute and be part of something that might become very big in a few years.

More on Software Development: 10 Ways to Convert Lists to Dictionaries in Python

Explore Carbon Programming Language

Fancy trying it out?

Carbon Explorer is “A prototype interpreter demo that can both run isolated examples and gives a detailed analysis of the specific semantic model and abstract machine of Carbon,” according to its documentation.

References:

Can Google’s Carbon Language Replace C++? | Built In (2024)
Top Articles
How to Make Money on Instagram: What You Need to Know - SMC
Delete or restore files from your OneDrive recycle bin in Android, iOS, or Windows mobile
Kmart near me - Perth, WA
Television Archive News Search Service
Ets Lake Fork Fishing Report
Missed Connections Inland Empire
Apex Rank Leaderboard
Craigslist Dog Sitter
2021 Tesla Model 3 Standard Range Pl electric for sale - Portland, OR - craigslist
Ukraine-Russia war: Latest updates
Sport Clip Hours
Athens Bucket List: 20 Best Things to Do in Athens, Greece
Charmeck Arrest Inquiry
Echat Fr Review Pc Retailer In Qatar Prestige Pc Providers – Alpha Marine Group
Aldi Süd Prospekt ᐅ Aktuelle Angebote online blättern
All Obituaries | Buie's Funeral Home | Raeford NC funeral home and cremation
Lcwc 911 Live Incident List Live Status
Parentvue Clarkston
Swgoh Blind Characters
Metro Pcs.near Me
Www.publicsurplus.com Motor Pool
MLB power rankings: Red-hot Chicago Cubs power into September, NL wild-card race
Busted Newspaper Fauquier County Va
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Diakimeko Leaks
Unionjobsclearinghouse
If you have a Keurig, then try these hot cocoa options
Weve Got You Surrounded Meme
Meridian Owners Forum
Busted Mugshots Paducah Ky
Craigslist Fort Smith Ar Personals
Sandals Travel Agent Login
Gopher Hockey Forum
Best Laundry Mat Near Me
Ancestors The Humankind Odyssey Wikia
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Gideon Nicole Riddley Read Online Free
Craigslist Hamilton Al
Kips Sunshine Kwik Lube
11 Pm Pst
Crystal Mcbooty
Craigs List Stockton
Radical Red Doc
Atlanta Musicians Craigslist
Fetus Munchers 1 & 2
Reese Witherspoon Wiki
Torrid Rn Number Lookup
Vérificateur De Billet Loto-Québec
Interminable Rooms
The Complete Uber Eats Delivery Driver Guide:
Congruent Triangles Coloring Activity Dinosaur Answer Key
The Significance Of The Haitian Revolution Was That It Weegy
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated:

Views: 5691

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.