Why will no language ever replace C/C++?

Author | Shalitha Suranga

Translator | Dong Yu

Planning | Yan Yuanyuan

Hundreds of alternatives to C/C++ will come, but C/C++ will always be with us!

Every CPU comes with a circuit language called ISA (Instruction Set Architecture) assembly. ISA assembly is a hardware language that consists of operations for basic data manipulation, mathematical computation, and structured programming (ie, jmp). However, writing assembly code for every computing requirement is undoubtedly time-consuming, so programmers of the past invented human-friendly languages ​​and compilers.

Pioneer computer scientist Dennis Ritchie implemented the C language for the development needs of the Unix operating system. During this period, the entire field of computer technology was in the initial construction of the foundation, so almost all programmers used the C language to build early computing programs, such as compilers, operating systems, database software, and network programs. Later, C++ extended the C language, retaining the performance characteristics of the C language, and a new programming language with more developer features was born.

In the 1920s, programmers implemented C/C++ alternatives, such as Go, D, Rust, and Carbon, with various features that C/C++ never provided. But these languages ​​are still only alternatives to C/C++, not replacements for the following reasons:

1C and C++ are the base languages

If we go back to the roots of every computer program that is active in our lives today, we will always find that they were born in C or C++. Think about what you are doing now, you may have read this article on Google Chrome, the Chrome open source browser (Blink rendering engine, V8 and browser app) written in C++. If you’re running Chrome on GNU/Linux, the Linux kernel is written in C. MySQL, the most popular relational database management system, is written in C/C++. All popular operating systems provide core C or C++ APIs for kernel functions.

Even though stable C/C++ alternatives exist, many programmers still prefer to use C or C++ for systems programming. In most cases, programmers choose C++ because it is the best language for communicating with operating system-level APIs. For example, Google wrote the Flutter engine in C++:

Flutter engine uses C/C++ to apply GTK library functions, screenshots provided by the author

For decades, most of the core components of the computing field have used C/C++ as the implementation language, and the C/C++ language has long maintained the standard of language syntax. Building a replacement for C/C++ is like changing the foundation of a house after all the building work is done.

2C and C++ take full control of what we write

When writing source code, C/C++ is free to deal with program resources. For example, C/C++ allows you to directly allocate/free physical memory used to store data elements. C/C++ provides a way to use native OS-level threads instead of managing separate concurrent runtimes like Go. C/C++ does not provide automatic memory management (garbage collection) features, so programmers should be careful to effectively prevent memory leaks. Take a look at how Meta’s Folly library source code implements a manual memory management strategy:

Meta’s Folly library uses manual memory management

The limitations of automatic memory management and memory handling are certainly a great way to make a language modern, efficient, and more abstract, but these features incur a performance overhead while the language is running, and reduce programmer freedom.

C and C++ do not restrict memory access and provide manual memory management operations, allowing programmers to control the program as they wish, thus giving programmers freedom. When you program in C/C++, your source code will effectively do what you tell it to do, and that’s it.

3C and C++ are really fast and efficient

The efficiency of a particular program depends on two main factors: the time complexity of the algorithm used by the programmer and the efficiency of the binary program. There is no doubt that we can control the complexity of the algorithms because we can change them by updating the source code. On the other hand, binaries are generated by the compiler, so we can’t easily improve efficiency from that.

However, we can choose a compiler that produces fast and efficient binaries. The GNU compiler produces platform-specific binaries without embedding a dedicated runtime environment. The C programming execution model uses the minimal startup code defined in the crt0 assembly instruction section. Take a look at the example below, the crt0 section on Linux:

Startup code executed before main function in C language

C++ is certainly a complex language, but it doesn’t offer a higher abstraction than Python and Golang. Additionally, it gives you a way to compile with your preferred standard language version (i.e. C++14). Therefore, since modern C++ features complicate C++ development, you can use only the smallest features in C++. C++ has been around for over 30 years and has been optimized for performance since the early days of computing.

4C and C++ are academic friendly languages

Programmer programming usually begins at different stages of a career. Some programmers use their first computer device to learn programming while they are still in school. However, most programmers improve their programming skills during college. Fortunately, almost all universities teach C programming in order to give students the opportunity to learn how computer programs work with hardware components. I wrote the following article to further explain how computer programs interface with hardware:

5 things to know before writing optimized code:

https://ift.tt/lthHV8b

These facts help you impress hardware and programmers with optimized performance:

https://ift.tt/lthHV8b

Later, most universities taught the basics of data structures and algorithms in C++ without using the complex parts of C++. College students usually enter the competitive programming field after taking courses related to algorithms. Most competitive programmers prefer C++ because of its speed, high availability of built-in optimal data structures, and little syntax.

Rust is undoubtedly a good language with memory safety, high performance, and built-in features, but the Rust syntax is not friendly to developers writing code for the first time. For industrial use, Go is a great language if your team wants minimal C-like efficient code and a python-like development environment. However, Go’s abstractions are too simple for academic use and do not align with traditional pseudocode, so academic lecturers will never use Go as a replacement for C/C++.

The following article explains why every programmer should start programming in C:

Why every developer should start programming in C:

https://ift.tt/ZvDtESw

You can start programming in any language – but there are more benefits to starting in C!

https://ift.tt/ZvDtESw

5 Modern Alternatives Still Require C, They Focus on Different Goals

As mentioned earlier, all POSIX operating systems and non-POSIX operating systems (ie Windows) provide a C library to handle kernel operations, so calling kernel features from C/C++ is easy since we don’t need to write language-specific bindings custom or third-party wrappers. Some operating systems even pre-include the GNU C/C++ compiler and debugger to facilitate C/C++ development. If we use Rust and Go, language-specific third-party bindings are required to communicate with the operating system APIs. Modern alternative languages ​​still provide a way to call C code. For example, Go provides the Cgo feature to call C code.

Almost all C/C++ alternatives strive to provide missing C++ features with language syntax distinct from C++. If programmers are looking for an alternative to C/C++, they usually expect a smooth and less time-consuming migration process. Also, they don’t expect to learn a new language to find solutions for C/C++ features they don’t like.

Programmers designed and improved the C language for low-level programming use cases, and no modern language was created entirely for the C language’s goals. C++ makes the C language more futuristic and improves it from the low-level programming stage. Rust, Go, D, and Carbon are all C/C++ alternatives – not replacements, and these alternatives have their own future goals.

The following article explains why every programmer needs to learn the C++ language in their career:

Why every programmer should learn C++ in their career:

https://ift.tt/sE7vIn6

Mastering C++ isn’t easy, but once you do, you’ll get invaluable benefits:

https://ift.tt/sE7vIn6

6 Conclusion

Previous programmers wrote our computer history during the evolution of C/C++. They build operating system kernels, programming languages, database systems, mobile operating systems, and networking software in C and C++. Thanks to C/C++, almost all modern web services now work. For example, the most popular Web server software, such as Apache HTTP and Nginx, use C/C++ as the implementation language. Previous programmers wrote almost all popular internal web browsers and web software components in C/C++. Web developers like to choose Java and Node.js for web services, but both Java and Node.js came from C/C++.

Some programmers see popular languages ​​like Rust, Go, D, and Carbon as replacements for C/C++. At the same time, some programmers are considering these languages ​​as alternatives to C/C++, believing that they may replace C/C++ in the future. These modern languages ​​are designed for specific purposes and needs – not to replace C/C++.

Microsoft created TypeScript, but we still use JavaScript. Jetbrains created Kotlin, but we still use Java. Hundreds of alternatives to C/C++ have emerged, but programmers will still use C/C++ because rewriting computer history for C/C++ is impractical. This does not mean that C and C++ are the best languages ​​- alternative languages ​​may be better than C/C++ in some respects (e.g. complexity, memory safety, etc.), but they cannot enter the realm of C/C++ , because previous programmers wrote the entire history of modern computing in C and C++.

Thanks for reading.

The text and pictures in this article are from InfoQ Architecture Headlines

loading.gif

This article is reprinted from https://www.techug.com/post/why-will-there-never-be-a-language-to-replace-cc-plusfcb063a8c401c2f9284a/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment