C++’s origins date back to 1979, when Bjarne Stroustrup, the programming language’s creator, first began work on the language that was then known as “C with Classes”. The language was initially designed as an improvement on the C programming language that added features based on object-oriented programming.
“C++’s success was obviously a surprise,” Stroustrup tells TechRepublic. “I see C++’s success as a function of its original design aims – efficient use of hardware, plus powerful abstraction mechanisms – and its careful evolution based on feedback from real-world use.” Now the language is the one of the most popular with developers and underpins systems and services around the world.
“I wanted to build a multi-computer system with a communication system that could be either shared-memory or a network,” Stroustrup explains.
“My focus was on the software. I needed to write low-level, close-to-hardware code, such as memory managers, process schedulers, and device drivers to separate software components, so that they could be running on separate computers communicating in well-defined ways.”
No language of the time was up to the task, so Stroustrup committed himself to building something that was. “C with Classes combined C’s ability to work close to the hardware with an efficient variant of Simula’s classes for abstraction and code organization,” he says.
From fairly early on, Stroustrup realized he didn’t have dictatorial control of the language. Whereas early work on C++ involved just him and a handful of colleagues at Bell Labs, this ballooned to several dozen when efforts to standardize the language began.
Today, there are around 400 members in C++’s standards committee, in addition to a wider community of users who follow and try to influence the language’s direction.
So how does one keep a programming language coherent given so much enthusiasm? “That’s an opportunity and a huge problem,” says Stroustrup.
“The hardest part is to decide what’s important and maintain a coherency. Once you know what you want, eventually, you find a good technical way of doing it.”
Remember the Vasa
1998 marked the year C++ was formally standardized and became a solid workhorse. By this point, C++ was one of the most commonly used programming languages in the world, a position it retains to this day.
Yet it was the arrival of C++11 thirteen years later that laid the foundations for the language’s future evolution, says Stroustrup. “C++11 made C++ feel like a new language,” he says.
“The type-safe support for concurrency was essential. C++11 supplied a dense web of mutually supporting features such as [constant expression] functions for compile-time computation, lambdas, automatic type deduction, and variadic templates.”
While C++11 introduced several new features and capabilities that made the language simpler, faster and more expressive, the language maintains its reputation for being difficult to master – a fact its creator readily attests to.
“C++ is indeed complex, and it takes effort to learn to use it well,” says Stroustrup. “Unfortunately, people don’t just want simplicity, they what something impossible: a simpler language, with more features, and no breakage of their existing code.”
Stroustrup’s answer to this “trilemma,” as he calls it, is adding features that “make simple things simple to do” – for example, though generalization or direct support for common use cases – while also maintaining both compatibility and stability.
That’s easier said than done with a beast as large as C++, or any major programming language for that matter. One of the biggest challenges is reaching a consensus on deciding which new features to adopt and omit, Stroustrup explains, which in itself takes a great deal of hard work, discussion, time and patience.
SEE: Top 5 programming languages for systems admins to learn (free PDF) (TechRepublic)
Even then, not all the good features can be taken onboard. “You must try to add only what really helps people and then only a few such things – because if we accepted every feature that would help someone, the language would sink under its own weight,” he explains.
Stroustrup refers to the Vasa, a grand 17th century Swedish battleship that sank in Stockholm harbor on its maiden voyage because of its poor design.
“At the insistence of the King – the highest management – and against the better judgement of the technical people, it had been piled high with beautiful statues and great guns. Top heavy, it was overturned by a gust of wind.
“I repeatedly talked and wrote about the Vasa as a caution to people enthusiastically wanting to improve C++ by adding features: remember the Vasa! So far, C++ hasn’t tumbled over.”
His secret to keeping C++ afloat after all these years? “You start small, articulate fundamental principles, articulate long-term ideals, and develop based on feedback from real-world use.”
Indeed, C++ is still going strong more than 35 years after it first appeared on the scene. Today’s C++ is far more powerful and expressive than the early C++. However, the original design remains visible, even to this day.
“There are simple programs from the early years – 40 years ago – that would still run today,” Stroustrup says.
“Stability is an important feature for a language used for systems that have to work for decades. In fact, many of the early ideas became available only in C++20. I knew from the start that I couldn’t build the ideal language, so I had to aim for gradual development – evolution. In fact, I did not believe in the idea of a perfect language – perfect for what? For whom?”
He adds: “Evolution is necessary to meet the challenges of a changing world and to incorporate new ideas.”
C++ in practice
As of September 2020, C++ is the fourth most popular programming language globally behind C, Java and Python, and – according to the latest TIOBE index – is also the fastest growing. C++ is a general-purpose programming language favored by developers for its power and flexibility, which makes it ideal for operating systems, web browsers, search engines (including Google’s), games, businesses applications and more.
Stroustrup summarizes: “If you have a problem that requires efficient use of hardware and also to handle significant complexity, C++ is an obvious candidate. If you don’t have both needs, either a low-level efficient language or a high-level wasteful language will do.”
Yet even with its widespread popularity, Stroustrup notes that it is difficult to pinpoint exactly where C++ is used, and for what.
“A first estimate for both questions is ‘everywhere’,” he says.
“In any large system, you typically find C++ in the lower-level and performance-critical parts. Such parts of a system are often not seen by end-users or even by developers of other parts of the system, so I sometimes refer to C++ as an invisible foundation of everything.”
He also highlights the relative unreliability of developer surveys in estimating the popularity of a given programming language: “Counting programmers is hard and simple. Web surveys typically just measure ‘noise’; that is, what is being talked about as opposed to what is being used.”
The future of C++
Today, Stroustrup is a Technical Fellow at Morgan Stanley. His work with the International Organization for Standardization (ISO) for the C++ standard and on the C++ Core Guidelines are considered part of his role with the finance giant, and he remains very much involved in the development of C++.
Most notably, Stroustrup forms part of the direction group, which presents and discusses recommendation about the future of the programming language. He also follows the evolution group, and takes part in discussions about new language features.
When it comes to the day-to-day running of C++, however, Stroustrup is happy to take more of a backseat role. “I follow administrative activities but try to do as little as possible there. I am not a great administrator,” he admits.
Before the pandemic, Stroustrup would travel a lot to teach, and to explain C++ to the world at large through his books, articles, and interviews – though much like the rest of the world, 2020 has put a temporary end to this.
SEE: Linux commands for user management (TechRepublic Premium)
“For my work, I depend critically on talking with people to learn about their problems and hear how my ideas might help them,” Stroustrup says.
“In this time of the pandemic, I am deprived of much-needed feedback. Virtual talks and interviews are not the same, and the dynamic of Zoom meetings are inferior to real face-to-face meetings when it comes to discussing design and ideas.”
The COVID-19 pandemic has also hindered progress with the next two iterations of the language, C++20 and C++23, though Stroustrup affirms that “almost all” of C++20 will ship in 2020.
“Beyond that, there is work on Unicode, numerics, game development and low latency, tooling, AI, and much more,” he says.
“We ship a feature (language and library) when it is ready, and we issue a revised standard every three years. C++14, C++17, and C++20 shipped on time. It is worth noting that the standards effort and the major implementors are very much in sync.
“It is crucial that C++ remains coherent and is a stable platform for development.”
Subscribe to the Developer Insider Newsletter
From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays