Member-only story
C++ Syntax Sucks and Carbon Fixes It
Isn’t C++ syntax perfectly fine? Why did the Carbon guys need to change it?

Judging by the many twitter comments I have read about Carbon, there is a significant number of C++ developers who are very displeased with the syntax of the Carbon programming language. A question I have seen repeatedly asked is:
If they are making a new language for C++ developers, then why did they make it look completely different? C++ syntax is perfectly fine and well known.
Actually, no, C++ syntax is not fine at all, but it is easy to internalize that fact and become blind to it once you spend enough years in the C++ trenches. When Chandler Carruth presented Carbon, he may not have done a good enough job of really explaining why C++ syntax is so problematic. I cannot promise that I will succeed either, but I will make an attempt at digging into the details of why C++ syntax is problematic and why we would want an upgrade. Let us start with a simple comparison:

What you will notice with Carbon is that most statements in Carbon have an introducer keyword such as fn
, var
, let
and class
. These keywords allow you to determine what kind of statement you are dealing with by just looking at one keyword. That is a deliberate design by Carbon. Let me quote from the first presentation of Carbon:
I don’t know if anyone has worked on a C++ parser, which doesn’t get to be a full compiler. It is incredibly difficult. We can make that better.
— Chandler Carruth
As a developer who has often made various tools to aid my C++ development, I can absolutely sign off on this observation. Writing code to parse C++ is very hard. Since I began writing C++ code back in 1998 that is something I have seen first hand. While the Java and C# communities got spoiled by amazing IDEs and tools, us C++ developers have for many years had very poorly working tools. Command completion would very regularly break, especially on larger projects…