Vehicles have come a long way in recent decades, with advancements in technology making the driving experience more safe, comfortable, and efficient than ever before.
The average modern car relies on more code than almost any other piece of tech, and eclipses even commercial airplanes and fighter jets in the sheer length and complexity of the code involved.
Behind all of these advancements are enormous codebases — and they’re getting bigger all the time. Which means devs are facing longer build times and need more computing power and processing resources..
C++ is the dominant programming language used in automotive development. At first glance, this may seem counterintuitive. As codebases are getting longer, reliance on C++ means build times will be extended even more than they would be if we used certain other languages.
So why is C++ still the standard in such a modern industry? Why is it still used when developers now so often focus on dev acceleration?
In this article, we look at why C++ is the preferred language of automotive developers, the benefits of C++ for vehicle software, and why it is the future of the industry.
The history of C++ in automotive development
The history of C++ in automotive development can be traced back several decades, making it ancient in programming terms. Initially, C, the predecessor of C++, was the standard for most vehicle software, and this naturally led to the adoption of C++ when it was created. C++ has now been the standard for around 40 years.
The coding guidelines of the Motor Industry Software Reliability Association (MISRA) and AUTomotive Open System ARchitecture (AUTOSAR) reflect the dominance of C and C++ in the industry. While MISRA C++ is the oldest and most commonly used of the two, AUTOSAR C++ — guidelines designed by automotive software experts to act as an update for MISRA C++ 2008 and provide coding guidelines for modern C++ — is fast becoming the preferred choice, and will almost certainly be the standard well into the future.
As vehicle software becomes increasingly complex, C++ is being used more than ever, particularly in safety-critical systems such as braking and engine monitoring. One of the key reasons for this is the fact that not only can it provide high-level functionality, but it also has low-level mechanisms that are relatively close to machine code/assembly code.
Today, C++ is so deeply integrated into so many critical vehicle systems — and the foundational systems of so many of the developing technologies set to be used in the vehicles of the future — that it is virtually impossible for the industry to stop using the language.
Benefits of C++ in automotive development
C++ is very versatile compared to many other languages, which is one of the reasons why there is some real potential for the future of C++ in multiple industries. It can be readily adapted to meet the evolving, often unforeseeable demands of the auto industry.
It also offers huge benefits in terms of compatibility. As it has been so common in computing for the last four decades, C++ enjoys a high degree of compatibility with other programming languages. For this reason, it can be used in conjunction with systems built using these other languages relatively easily. This is a vital trait in an industry as complex, fast-moving, and unpredictable as automotive development.
Fundamentally, C++ is a low-level language, meaning it is very close to the basic binary architecture of computers. As a result, it is structurally very similar to machine-level code. This makes it highly efficient, with very few intermediate steps complicating the code written by automotive developers and what the computers can understand.
This inherent efficiency means that well-written C++ performs very reliably and predictably — characteristics that are essential for safety-critical systems such as those found in modern vehicles.
Support and community
Another big bonus for developers is that, thanks to its long and varied history, C++ has a large and active global community. This community can provide invaluable support for automotive developers. Additionally, there are masses of learning resources, both free and paid, available online, so the barrier to entry for developers is relatively low.
Over its decades of use, developers all over the world have spent hundreds of thousands of hours creating libraries for C++, exploring test cases, and making it as efficient as possible. This makes it a highly refined language and contributes to the support available to automotive developers.
Future applications: C++ and autonomous driving
Autonomous driving has been heralded as the future of the auto industry for many years, and the hype is well deserved. It’s very likely that self-driving cars will be fully developed and accepted by governments and the public in just a few years from now. When this happens, it’s only a matter of time before they take over as the standard type of vehicle on roads globally.
But to realize the goal of truly autonomous driving, auto companies must lean on computer code even more heavily than they currently do. The sheer number of systems involved in autonomous driving is staggering, and the complexity of the code that underlies these systems even more so.
Additionally, the stakes couldn’t be higher, with the lives of passengers and other road users in the balance. This means that all of the systems involved must be extremely reliable, safe, and bug-free.
As we’ve already discussed, C++ is prized in automotive development for its proximity to machine-level code, its efficiency, and its versatility. This makes C++, perhaps surprisingly for some, the perfect candidate for self-driving vehicle systems.
C++ is excellent for achieving interoperability between software and machinery, which makes it ideal for the basic systems involved in autonomous driving such as braking, steering, and acceleration.
Furthermore, C++ has a high degree of compatibility with other languages. This means that other relevant systems, such as AI-based driving technologies, written in more modern languages, can be integrated with existing, tried-and-tested vehicle systems.
Finally, autonomous driving is hugely complex, and even with the most diligently written code, the final piece of the puzzle is compiling. The long history of C++ and the extensive support provided by its community mean that there are large numbers of reliable compilers and other support tools available, making it well suited to the job.
Steering the automotive industry into the future
C++ may be an old language, but its efficiency, reliability, proximity to machine-level code, and extensive community all contribute to it being the dominant language in automotive development.
These very same features translate perfectly to the future of the industry — autonomous driving — meaning that the leading role of C++ in modern vehicle software is set to continue and grow for many years to come, and C++ dev environments will also evolve.
Visit the Incredibuild blog today for more insights into the software and tech industries.