I watched a video by Flagship introducing the Carbon language. The video began with the following words:
"The programming languages people like to hear are disappearing quickly. Microsoft killed Javascript with Typescript, Apple killed objective C with Swift. JetBrains killed Java with Kotlin. And now Google is stepping up to the plate for the biggest challenge of all: C++."
You may have heard by now, that Google recently announced a new experimental language called Carbon which is designed to match the performance of C++ with LLVM while being able to interrupt with existing C++ codebase. That's a big deal because C++ is by far the most prolific language when it comes to building high-performance low-level systems.
Some developers out there are already thinking of learning how to code in Carbon. A reason might be the benefits of investing in a programming language before it takes off. For others, just to learn new things.
However, I spent more than 48 hours exploring the Carbon language. And with my experience with C++ here are 7 practical reasons why I think you shouldn't waste your 2022 learning how to code in Carbon. The worst is that reason #7 may happen.
1. Confusing Syntax
fn Main() -> i32 {
var a: i32 = 5;
let b: i32 = 5;
return a + b; // result: 15
}
The program above returns the sum of a
and b
. If you are seeing this code for the first time, you may not be able to tell the difference between a
and b
. But a
is variable and b
is a constant. Weird thing to a Javascript.
This is the first confusing thing I found with Carbon syntax. To create a variable in Carbon, you use the word var
and for constant, you write let
.
For millions of Javascript developers who no longer use var to declare variables and also frequently use let to declare variables within a particular scope; this is a conflict already.
I have to get used to it, even now it's still confusing. And as you will learn later, it wasn't intended for JavaScript or modern web developers.
var fruits: [String; 3] = ("mango", "orange", "apple");
You may often forget to type a semicolon before setting the array length. A comma would have been easier and the brackets used here should have been interchanged.
Every language has its own way of doing things. But typing common things like arrays and structs shouldn't be uncomfortable. It going to take a significant amount of time to get your fingers right on them.
2. Difficult to write or even read
Like Rust, Carbon abbreviated most reserved words and did common things in C++ differently. For instance, to declare a function, you start by typing fn:
fn Add(a: i32, b: i32) -> i32 {
return a + b;
}
For a C++ dev, it's more typing and completely different. Adding ->
makes things horrible, one of the things that make me dislike PHP. And for a new dev reading your code, he or she has to know what fn means. In JS or PHP, you start by typing function in full:
function add(a, b) {}
It is obvious. Everyone knows it's a function when reading your code for the first time. Not comparing Carbon with Typescript, but one of the best things with Typescript is that it doesn't distort the way you write Javascript; just add types.
The return type i32
also makes it difficult to read. You have to think a little or you need to be familiar with system languages to quickly know its 32-bit integer. int32
would have been easier to read.
I find Carbon syntax difficult to write compared to C++, you will be holding shift key a lot. The syntax is also hard to read. Too much novelty usually affects readability; Golang's success is more on readability than speed.
3. Require practical knowledge of C++
You may start seeing videos with the title "Learn Carbon in 60 minutes". A quote from the book How To Design Program, reads "Bad programming is easy. Idiots can learn it in 21 days, even if they are dummies."
But it takes take 10 years to learn C++. And maybe another 10 years to fully understand everything. You can ask any C++ expert.
Carbon is designed for easy adoption by existing c++ codebases and developers. It has bi-directional interoperability with C++ which means you can use existing C++ libraries and Carbon seamlessly or vice versa. This clearly suggests early practical use cases are going to be mostly rewriting or migrating existing C++ codebase to Carbon codes.
Like Java is to Kotlin, or JavaScript to Typescript. Arguably, you will need to understand C++ to really work with Carbon. And once you do, you may not like Carbon.
Well, as Carbon progress, we are going to be seeing job openings with practical knowledge of C++ as a requirement or a plus. You shouldn't be surprised to see 10 years of Carbon experience needed. Usually, those experiences will be pointing to C++.
4. Longer to master
If you are new to programming so you can get a job in the next 6 to 12 months. Then this is not for you.
This reason is similar to the previous one. You won't master C++ in 5 years. And I don't think most devs reading this will master Carbon in 5 years. As stated clearly on it Github repo, Carbon foundations are easy to learn for C++ dev. But not for a developer who has spent all of her coding time writing PHP.
Carbon is a low-level system language. Languages in this category are usually hard to master. Developers coming from other languages like Python or Javascript are going to struggle. Terms like pointers, references, generics, and garbage collections are going to be things you have to understand and master. 75% of you reading this may have never used generics in your codebase.
You also have to understand its Type System. To run a Carbon program, you have to compile. And it currently can take up to 1 minute depending on your codebase and system processor. Believe it or not, you won't become a Senior Carbon developer anytime soon.
5. Pretty much Google
Seriously, I don't think you need Carbon. Especially if you can effectively use Go, Rust, or Kotlin. It doesn't have a clear value for most of us. Google is simply scratching its own itche.
Google has been a dominant user of C++. Much of its systems are written in C++. Codes are now hard to read or understand for collaboration; development isn't fast enough; safety issues. And to them, the designs of languages like Rust present significant barriers to adoption and migration from C++. So they have to create a new language to solve their problem.
I haven't written or worked on a million lines of C++ codes. You may haven't. The key reason a developer will want to migrate to Carbon is that they are stuck with C++ and they want a change. And most of these developers are working in Google or a big org that uses a lot of C++. Not your size project.
It's a google thing.
6. Governance: Three person-group
You may not care, but the language will be governed by a three person-group. So instead of a benevolent dictator for life like we have with most popular languages, they have decided to go for three people. Even the three people said no, we want a benevolent dictator. They choose Chandler Carruth to do it and he said no, so they just settled with three people.
Is that a bad sign? Why did Chandler decide not a be the benevolent dictator? ๐
Three people ruling and that's it and they are making all sorts of decisions. It's more of committee stuff. Has any language become popular with that kind of governance? I don't know.
Popular languages usually have a small team or at least one person to have the design plan to say what the proper goal is because then you can have a proper design goal. It's not just a ragbag of people arguing or counter-suggesting which features should be included.
7. Worst of all, it may fail to succeed C++
As stated clearly on its Github page, Carbon is an experiment. Things are thing very very early. No efficient compiler or toolchain. No logo and I couldn't find an official website. I'm very sure things will get better. But the problem is:
The Carbon team only hope they can build a language that successfully succeeds C++. And to be frank, this depends on whether they are able to generate a critical mass of interest within the larger C++ industry and community.
Google is no stranger to creating programming languages. They gave us Go and Dart which are both very well-liked in the industry. But the goal of Carbon succeeding C++ is not a small undertaking. Rust is yet to replace C++. And I don't think it will.
Also, we may have seen many wonderful supersets over the years. C to Objective C, Javascript to Typescript, Java to Kotlin. However, Carbon isn't really a superset of C++. They are lot of C++ code that can't run on Carbon.
Google is a for-profit company with some non-profit endeavours, yet at any point in time, Google may decide to stop working on it if it fails to meet their expectation.
Final Thought
Here is a recap:
- Confusing Syntax
- Difficult to write or read
- Require practical knowledge of C++
- Longer time to master
- Pretty much Google
- Governance - no benevolent dictator
- It may fail to succeed C++
You may say all my reasons don't really matter, and this is the language for me. But I don't think it is; especially if you don't have experience with C++. You may argue after all Google got some power to decide our tools and Go and Dart are quite successful.
However, things may change, Carbon is still new.
So the only way you will know actually if it is really for you is to pick it up and start coding, and probably go work for Google; the language is pretty much-solving google problems not yours in the first place.
If you are a new developer and want to get a job as soon as possible, don't even think of starting with this. You don't really have a big chunk of C++ codes to rewrite or interface with. Your chance of working in a big org is too slim and most startups won't use Carbon to build an MVP. The language is still new and so experimental, still not fully usable, it may fail ๐.
Further learning
If you like to go further on Carbon, you can check the following links and some interesting arguments :
- Carbon Language Documentation(github)
- An experimental successor to C++ by Chandler Carruth(youtube)
- Carbon Language: Who is it for?(youtube)
- Carbon Language Tutorial With Syntax, examples to get started with(hashnode)
- Carbon Lang First Look & Crash course(youtube)
PS: All reasons and conclusions stated here are purely subjective and should be considered thoughtfully. Hashnode is an open community and I would love to read and reply to your comments.