This is the seventh of a series of articles examining a 2009 interview with Bjarne Stroustrup. The first part is here with links to the other parts:
C++ 2.0
Question: “Will we ever see C++ 2.0?”
Since this publication, C++ luminary, Herb Sutter, has been working on a syntactic front end to clean up C++ syntax. Sutter worked on C++ standards for over a decade. Those who have worked on the definition of C++ also find the syntax of C++ ugly and want something better.
Stroustrup himself has said: “Within C++, there is a much smaller and cleaner language struggling to get out.”
A cleaner language would be better, less ugly syntax, especially the need for cryptic double characters such as ‘::’ and ‘==‘ and ‘&&’. New programmers feel some kind of admittance or right-of-passage into the arcane world of coding when they learn these. But these are forms that should not be a burden for learning at all. Language designers should choose clean and direct syntax. ‘=‘ MEANS EQUALS, not something else that forces ‘==‘ to mean equals. But then many new programmers don’t realise there is a distinction between equality testing and assignment — after all programming assignment now looks like a mathematical equation. But it is not — a + b = c + d can’t be written like that for assignment. When that is pointed out, the penny begins to drop with new programmers.
These arcane and obscure reinterpretations of natural syntax, both from natural language and mathematics should be avoided. Yet C and C++ are full of them. When C was invented there was a culture of computing being different just because it could be. That is both good and bad. Different thinking can challenge ways things are traditionally done with better ways of doing things. But too often computing changed perfectly good ways of doing things for the worse. Robert Recorde invented the ‘=‘ symbol:
“To avoide the tediouse repetition of these woordes: is equalle to: I will sette as I doe often in woorke use, a paire of paralleles, or gemowe (twin) lines of one lengthe: =======, bicause noe .2. thyngs,, can be moare equalle.”
Robert Recorde, The Whetstone of Witte, 1557
https://www.ajmonline.org/wp-content/uploads/2018/12/73-322-1-ED.pdf
Thus ‘=‘ visually suggests two parallel lines of equal length. That is great typography! Shame that has been dishonoured by so many programming languages, just for a small convenience of not typing ‘:’ in ‘:=‘ (although ‘:=‘ is also an ugly double character).
By default, computers should be made to work the way that people work, following tried and true conventions. People are not subservient to computers. Computers are the servants of people. Computers can help us find better ways to do things, but that should be the exception.
Herb Sutter has produced a front end, cppfront, to transform his proposed syntax to standard C++20. However, this is not a real project, only testing ideas. We now have a preprocessor on a language that started as a preprocessor (with all the limitations over a real compiler with syntax analysis) and C++ still feels that way.
There are two observations here. First, that C++ forms a reasonable backend intermediate syntax, rather ugly, but it has everything. However, that could also be C. Other languages can be built with C or C++ as a backend. In fact, other languages have taken this approach. Whereas cppfront might still be close to C++ syntax, other languages do not suffer from that dependency at all. In fact, even though they might use C or C++ as a universal intermediate assembler, they are in no way dependent on or related to C or C++.
The second observation is why do we need a separate utility to transcribe a source syntax to an intermediate form? We don’t. We can integrate that functionality into the presentation and editing software itself which can transform between the intermediate representation and the presentation which the programmer can choose for themselves. Let’s do away with the tyranny of text and syntax, where language designers decide they can impose their deranged preferences on everyone else.