Why is C++ not commonly used in AI research?

2024-06-24

C++, a language that once shone in the late 20th century, was at the forefront of technological development, especially in space exploration.

However, with the emergence of newer, more visually appealing programming languages, C++ is no longer in the spotlight.

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

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

Lack of Interest in the AI Field

Although C++ has many advantages in terms of performance and is applied in various AI fields such as speech recognition and computer vision, it is not the preferred language for AI development.

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

In addition, C++ requires manual memory management, which can lead to memory leaks and errors if not handled properly. This can be a serious issue in large-scale AI projects.

Microsoft emphasized this point when revealing that 70% of its updates in the past 12 years were aimed at addressing memory safety vulnerabilities, as Windows is primarily written in C and C++.

Google's Chrome team also published their own research, revealing that memory management and security vulnerabilities account for 70% of all major security vulnerabilities in the Chrome codebase. Chrome is primarily written in C++.

C++ also lacks built-in support for garbage collection, database access, and thread support, which may require additional development efforts.

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, this can be particularly challenging.

To overcome these limitations, developers often use third-party libraries and frameworks that provide thread support, such as OpenMP or Boost. However, these libraries can increase code complexity and overhead, making them suitable for only certain applications.

C++ is Quite Complex

If you have visited the C++ FAQ page, you would understand how difficult C++ can be. In earlier language versions, a misplaced comma could result in hundreds of compilation errors.

Since C++11, the language has improved with the addition of move semantics and rvalue references for transferring ownership, but the learning curve remains high.

Developing New Applications

In recent years, we have witnessed the development of various programming languages that have the potential to replace C++ for low-level system tasks, such as Rust, which provides security and stability by eliminating buffer overflows and memory leaks (and is easier to learn than C++).

When comparing the feature sets of modern languages like C++, Python, and Rust, C starts to look outdated like a dinosaur! The C standard has not introduced new features since 2011!

The 2017 standard version mainly consisted of technical corrections and clarifications, and the 2023 standard version did not cause a major stir.

Is C++ Losing Popularity?

Mark Russinovich, Chief Technology Officer of Microsoft Azure, stated that developers should stop using C and C++ programming languages and that the industry should consider these computer languages as "deprecated."

Ken Thompson, a researcher at Bell Labs and the original designer of the Unix operating system, referred to C++ as a "bad language" that is "too big, too complex," and "obviously built by a committee."

GitHub compiled a list of the top ten programming languages in the machine learning field. Python is the most popular language in machine learning repositories, while C++ ranks sixth.

According to Stack Overflow's Developer Survey, beginners in programming are more likely to choose Python over C++.

Although C++ has advantages in terms of speed and memory management, it also has some drawbacks, such as a steep learning curve and limited community support.

Despite these challenges, C++ remains a powerful choice for machine learning applications that require high-performance processing and advanced memory management. The choice between C++ and Python in machine learning ultimately depends on the specific requirements of the application and the developer's skill level.