Adrian Esquivel
November 10, 2022
Articles

Experimental Carbon Language

Work smarter (and faster) not harder, is trending in the tech world. Not just with employing augmented teams to support growing businesses, which we talk about a lot, or the rise of popularity for cross-platform codebases and languages like React Native, but general readability and ease of use are ongoing themes.

What Gap Does Carbon Fill?

Other languages based of C++, like Rust (still in its early stage), are not fully compatible with C++ programs. Carbon’s feature set will mirror C++ features but place a focus on readability and interoperability between languages like Carbon and Swift that exceed the current C++ capabilities.We mentioned Go and Dart, other Google frameworks, and Dart, while an effective object-oriented language, did not win the hearts of C++ and JS programmers. Where dart failed, Go succeeded. This C based language became popular possibly because it initially feels like a compiled language but has the intuitive elements of an interpreted language like Python. And while Go still has its differentiators (such as how it compiles memory), it’s certainly earned its spot. Will Carbon follow the same path?

A look at Carbon

While as of August 2022 Carbon is not ready for use, this C++ successor was announced at CPP North, the Canadian C++ Conference, in July of 2022. So let’s jump in and get to know this upcoming framework.

Speed

The first goal is speed. Carbon needs to be fast, and able to work with C++. Performance matching C++ using LLVM, with low-level access to bits and addressesLLVM automates language creation between languages like C++, Rust, and now Carbon that use low-level language features. With using a tool like LLVM, memory optimizations can be challenging when compiling without compromising the automations between the languages. It will be interesting to see how this plays out with Carbons focus on interoperability.Other speed features include:

  • Interoperate with your existing C++ code, from inheritance to templates
  • Fast and scalable builds that work with your existing C++ build systems

Scalability

As a web-based language, scalability is a given in comparison to compiled languages. Open-source solutions and accessible versioning are all things we can look forward to - but also that we have come to expect - with language successors like Swift or Kotlin.

  • Solid language foundations that are easy to learn, especially if you have used C++
  • Easy, tool-based upgrades between Carbon versions
  • Safer fundamentals, and an incremental path towards a memory-safe subset

Open-Source

  • Clear goals and priorities with robust governance
  • Community that works to be welcoming, inclusive, and friendly
  • Batteries-included approach: compiler, libraries, docs, tools, package manager, and more

Evolution vs. Succession

Go, Kotlin, Rust, etc. are likely not going to be replaced by Carbon. So why is this new language even needed? With C++, migration has always been an issue when communicating with other languages - and so there were/are two choices. Evolve C++, or create its successor.Improving C++ is challenging, based on its established processes, and history of placing deliverability above ‘perfect code’. In other words, evolving CSS would be the equivalent of evolving the U.S. constitution. Years of technical debt and amendments have made evolution a time consuming challenge. The successor approach attempts to design a bridge of interoperation to C++ that can facilitate large scale adoption and migration for existing codebases. These are some of the successor requirements as outlined by the Carbon developers:

  • Performance matching C++, an essential property for our developers.
  • Seamless, bidirectional interoperability with C++, such that a library anywhere in an existing C++ stack can adopt Carbon without porting the rest.
  • A gentle learning curve with reasonable familiarity for C++ developers.
  • Comparable expressivity and support for existing software's design and architecture.
  • Scalable migration, with some level of source-to-source translation for idiomatic C++ code.

The end goal is to construct a language that sits on top of C++ which can relate better to a larger ecosystem.

Language

Carbon will support performance-critical software, language evolution, readability, testing, scalability, work with all modern operating systems, and fill the gap between communication, migration, and adoption with C++.“While many languages share subsets of these goals, what distinguishes Carbon is their combination.”Carbon’s library will feature a stable application binary interface (ABI) to define how data structures and routines are accessed, and take the place of a compiler for writing programs either of multiple languages, or where multiple compilers are used.

Project status

This language is experimental and there is currently no working compiler but you can check out Carbon’s demo interpreter on compiler-explorer.com. We’ll keep an eye on the development of Carbon, and how it compares to other C++ successor hopefuls like Rust.Staying on top of hiring and tech trends is challenging. Don’t miss out on a solution, either human or technical, that could help you. For the latest in technology solutions and tech talent, email us at info@teckpert.com or contact us here.