Article complete

Why is C++ Not Used in AI Research?

The introduction of new and modern languages has made C++ superfluous. Its little use in AI research hasn’t helped either.

A surreal collage featuring a face with flowers emerging from a computer monitor against a bold red background.

Key takeaways

  • C++ is declining in AI research due to the rise of more modern programming languages.
  • Python's user-friendly nature and extensive libraries have made it the preferred choice for AI development.
  • C++'s complexity and manual memory management lead to challenges that deter developers in large-scale AI projects.
  • Industry leaders like Microsoft advocate for moving away from C++ for new projects.
  • Despite its historical significance, C++ may be becoming a relic in the AI field.

Takeaways drafted with AI from the article text.

C++, a language that once shone brightly in the late twentieth century, was at the forefront of technological advancements, particularly in space exploration. 

However, the emergence of newer, more visually appealing programming languages has shifted the spotlight away from C++. 

At the AI+Data Summit 2024, researcher Yejin Choi said that researchers no longer use the language for AI research.

So, is C++ becoming a relic of the past? 

Not Many Takers for AI

Despite its performance benefits and applications in various AI fields, such as speech recognition and computer vision, C++ is not the go-to language for AI development. 

Its complexity and steep learning curve pose significant challenges. In contrast, Python's user-friendly nature, extensive libraries, and large developer communities have propelled it to the forefront of AI programming.

Furthermore, C++ involves manual memory management, which can result in memory leaks and errors if not done correctly. This can be a considerable issue, particularly in large-scale AI programmes. 

Microsoft emphasised this issue when it revealed that 70% of its updates in the previous 12 years were solutions for memory safety bugs, owing to Windows being mostly written in C and C++. 

Google's Chrome team released their own research, which revealed that memory management and safety flaws accounted for 70% of all major security bugs in the Chrome codebase. It is largely written in C++.     

C++ also lacks built-in support for garbage collection, database access, and threading, which can necessitate extra effort to develop. 

This can be particularly challenging in AI applications that require concurrent processing of data and tasks, such as deep learning and neural networks, real-time systems and embedded systems, data processing, and data science.

To overcome these limitations, developers often use third-party libraries and frameworks that provide threading support, such as OpenMP or Boost. However, these libraries can add complexity and overhead to the code, which may only be ideal for some applications.

C++ is Complicated

If you've visited a page like the C++ FAQ, you'll understand how hard C++ can be. A comma in the wrong location might trigger hundreds of compile errors in earlier language versions.

The language has improved since C++ 11, with move semantics for transferring ownership and rvalue references, although there is still a high learning curve.

Developing a New Application

In recent years, we've witnessed the growth of various programming languages that potentially replace C++ for low-level system tasks, like Rust, which provides safety and security by eliminating buffer overflows and memory leaks (and is much easier to learn than C++).

When you compare the feature sets of modern languages like C++, Python, and Rust, the C language begins to look like a dinosaur! The C standard has not had new features introduced since 2011! 

The 2017 standard release included technical corrections and clarifications, and the 2023 standard release did not rock the boat either.

Is C++ Losing Popularity?

Ken Thompson, the Bell Labs researcher who designed the original Unix operating system, called it a "bad language" that is "way too big, way too complex" and "obviously built by a committee”.

According to Stack Overflow's Developer Survey, beginners beginning to code are more likely to prefer Python over C++ than professionals.

While C++ provides advantages regarding speed and memory management, it also has disadvantages, such as a high learning curve and little community assistance. 

Despite its challenges, C++ can be a powerful choice for machine learning applications that require high-performance processing and advanced memory management. The choice between C++ and Python for machine learning ultimately depends on the specific needs of the application and the developers' skill level.

Published

Spotted an error? Tell our editors. Read our editorial standards and corrections.

About the author

Contributor

Anshul Vipat is a tech aficionado, enthusiastic about the latest innovations in the digital world. He also holds keen interest in traveling, exploring and cooking

All stories
Belamy · Daily

The day’s AI news, before your first meeting.