Why every programmer should learn C++?

This article was originally published on the Level Up Coding blog.

Mastering C++ isn’t easy, but once you do, it pays off handsomely.

Often, programmers use multiple programming languages ​​in their programming career. However, we also see that some programmers have been using the same programming language. For example, we often meet Java experts and C# experts with decades of experience. However, learning multiple languages ​​will make you more confident and skilled in your software development career. For example, if you master the Go language, you will learn several impressive language design concepts and improve your general programming skills.

Learning Python is also good because we can use Python knowledge to write any automation script and be productive. Learning a new programming language will undoubtedly give us unique experiences and new technical expertise. Compared to other popular programming languages, C++ language can bring us many benefits. Unlike other modern languages, learning C++ is really not easy and time consuming. As a result, most programmers nowadays skip learning C++ and prefer modern languages ​​that provide a more abstract development environment.

I’ll explain why learning C++ is a must for all programmers trying to become programming experts.

C++ inspires you to learn computer science fundamentals

Behind every technically sound software program, several core computer science theories can be identified. For example, Git programs use graph theory, hashing, and many basic computer science algorithms. For example, here’s a merge sort implementation in a Git repository:

Merge sort implementation in Git, the author’s screenshot

Today, every business entity typically moves toward a cloud computing ecosystem and strives to automate business processes. As a result, most programmers now program to solve business problems, not computer science related problems.

But even working on business-oriented software development projects, they often have to apply computer science theory to write better code and make software more efficient. Therefore, knowledge of computer science theory is essential for every programmer.

There is no doubt that C++ is a high-level language that provides higher-level and more human-friendly abstractions than C. However, C++ encourages people to use pointers and manually manage memory like C. In addition, the design of the C++ standard library focuses on computer science concepts, performance, and flexibility, not just ease of development. So when you learn C++, you’re inadvertently learning the basics of computer science.

Build lightweight, high-performance, simple solutions using C++

Most modern programming languages ​​focus on hiding low-level technical details with pseudocode-like syntax, with little regard for performance, light weight, and flexibility. However, C++ can still produce lightweight binaries and is the best choice for writing performance-first software systems.

Modern programming languages ​​like Golang compete with C++ by providing a minimal C-like syntax and automatic memory management (via garbage collection). However, Go generates very large binaries, so it is not suitable for lightweight scenarios. This is why most programmers use Go to build high-performance cloud tools, because the size of the binary is not an issue for cloud environments. Programmers still prefer C++ to Go when it comes to high-performance, lightweight software development.

Go is usually statically linked to the standard library implementation, and when we import fmt, it grows a 1.2MB minimal Go binary to 1.8MB. C++ is usually dynamically linked, and when we include iostream, it increases a minimal 16.5KB binary to 17.3KB. On GNU/Linux platforms, Go binaries have increased in size by 50%, while C++ binaries have increased by less than 5%.

The above simple experiments prove that C++ is more suitable for high-performance, lightweight software development. C++ is a complex fully loaded language, but by choosing your preferred features, you can still write minimal code. The following article will help you practice writing minimal code in any programming language: 5 programming principles to help you code better.

C++ Tricks Let You Learn Other Programming Faster

Language programmers learn various programming languages ​​according to their preferences. Some programmers learn programming languages ​​when they start working on enterprise-level software development projects. At the same time, some programmers tend to learn programming languages ​​as a hobby. Some languages ​​are easy to master, while others require constant experimentation to gain further experience.

C++ requires more time to gain professional work experience due to its complex syntax (C++ has 60 keywords), versatile standard library, hardware-oriented development environment, and lesser-known best practices. C++ is a multi-paradigm, versatile programming language. In other words, you can develop your own programming style and best practices when writing code in C++.

Learning the C++ standard library and development patterns requires solid computer science knowledge and technical skills. So when you’re proficient in C++, learning a new language is a piece of cake.

Best language for interacting with operating system APIs

Each operating system provides developers with a programmable interface for handling operating system-level operations such as process management, file handling, GUI rendering, and network request handling (via sockets). All of these APIs expose C/C++ based interfaces because every operating system is written in C/C++.

GNU/Linux systems provide a Unix-style API and GTK GUI library in the form of C language header files. MacOS also provides an Objective-C interface that we can use with the Apple Clang LLVM compiler. Therefore, we can use C++ to directly access any OS-level API, because C++ is a superset of C, and Apple compilers allow developers to mix C++ and Objective-C. For example, see how Electron uses GTK C headers in C++ source files:

The source code of the file selection dialog in Electron, the author’s screenshot

On the other hand, all other programming languages ​​require language-specific bindings to access the operating system’s API. For this reason, almost all OS-level frameworks are written in C++. Check out these C++-based frameworks below:

  • Electron

  • React Native

  • Flutter

  • Neutralinojs

Additionally, large software projects like Chromium, Firefox, Tensorflow, LLVM, and V8 also use C++ as their primary development language.

C++ knowledge helps you make better technical decisions

Programmers not only write code to specifications, they also design software systems and organize project structures. The design phase is very important in software development because it lays the foundation for the entire software system. We often have to make technical decisions during the design and development phases.

C++ is a complex language – you have many ways to solve the same programming problem. Additionally, C++ was designed to be a fast language, but give programmers full control over the execution of their programs, optimizing the code as they wish. Therefore, you need to make careful technical decisions and choose the best C++ features for your needs based on your preferences.

C++ is a multi-paradigm language, although it is known to be an OOP-based language. Some programmers use the traditional OOP paradigm when programming in C++. At the same time, some programmers use procedural as well as functional programming paradigms when programming in C++. Sometimes, we often have to avoid some C++ features in order to simplify our source code. For example, Google’s C++ style guide recommends against using C++ exceptions. All of these situations improve our technical decision-making capabilities.

summary

We’ve discussed the benefits of learning C++ in your programming career. There are currently more than two dozen stable, full-featured, and popular programming languages. There is no single programming language that is called “the best programming language” – every programming language performs well in a specific domain. So, learning five of your favorite, handpicked programming languages ​​and calling them “my best programming languages” was a wise decision.

If you pick five programming languages ​​carefully, considering all aspects – C/C++ will undoubtedly be on your list as well. In this article, I introduce my favorite programming languages: 5 programming languages ​​every developer should learn.

Learning C++ without learning C is like learning React.js app development without experimenting with native JavaScript and DOM – so learning C first and then learning C++ further can bring all the above benefits to your programming career.

Thanks for reading.

View the original English text:

https://levelup.gitconnected.com/why-every-programmer-should-learn-c-during-their-careers-959e1bc2ea68

The text and pictures in this article are from InfoQ

loading.gif

This article is reprinted from https://www.techug.com/post/why-should-every-programmer-learn-c-plus.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment