Why C++ is the best programming language?

Alex Aramyan
Nerd For Tech
Published in
5 min readFeb 4, 2021

--

A lot of developers in different communities argue about the best programming language. Obviously, those who are more into Web development, most probably prefer JavaScript, those who are more into AI & ML, prefer Python, etc. Actually it is impossible to identify which tool is indeed the optimum variant for ALL problems, since different languages are designed for different kinds of problems. Nevertheless, the C++ language has some powerful arguments up its sleeve.

Let’s look at the factors that are considered when choosing a good language:

  1. Performance.
  2. Syntax.
  3. Opportunities it gives.
  4. Platforms on which it can be exploited.

Speed

When it comes to speed, C++ has no equal in today's popular languages’ list.

Comparing some of the most popular programming languages’ performance, writing a simple app, it is easy to notice the tremendous contrast between the numbers. C++ is extremely fast, since it is a quite low-level language, compared to Java, Python, JS, and some other common languages. It is easy to prove that C++ is faster than other languages included in the list of most popular languages, using one uncomplicated program.

C++ code

Repl.it online C++ compiler

Java code

Repl.it online Java compiler

Python code

Repl.it online Python editor

In this example all three codes demonstrated in the above windows do the same, they simply do 10,000 iterations and output the execution time in microseconds. If we compare the performances of those three, it is easy to notice that C++ smashes the rest of the languages. But here a seemingly obvious yet a tricky question emerges. Why?! Why the heck C++ is that fast?! Actually, everything becomes pretty simple, when we take a look at the way the language works. A huge point worth to mention is that C++ is a low-level language. Since it is a low-level language, it is closer to the machine code than the others, hence it needs less time to execute.

So compared to C++, Java is a higher level language, i.e. it has more features such as garbage collector, it has more intermediate processes, like JIT (just-in-time compilation) and other stuff that slows down the execution time. Despite everything, Java serves here as a model to represent the side-effects of being a higher level language. The same thing is with Python. It is considered to be a high-level language, while Java is a middle-level one. Like other interpreted languages (and unlike Java, which is a compiled one), Python code is interpreted by an interpreter which is basically a C++ program, that reads and understands the Python syntax and runs it accordingly. So because it has no direct connection with the CPU, it is slower than other lower level languages.

Syntax

When it comes to syntax, it is a bit harder to choose the best option. Today the majority of popular programming languages have a pretty nice syntax. Of course, it isn’t easy to learn and neither convenient to use a language with a complicated syntax. Unlike some other languages, C++ has quite intuitive syntax, which is actually not so hard to comprehend, by looking at the code a bit more creatively. Of course, the prize named “Easiest syntax of 2021” doesn’t go to C++, since it has more elements to write in contrast to some other languages. For instance, we don't write the main executed code in the main() function in most high-level languages, such as Python or Swift. Nevertheless, we are required to use the main() function in C++.

Despite its length, C++ has a pretty straightforward syntax.

#include "somelibrary.h"int main()
{
// code required to be executed...
return 0;
}

So this is a template example of a C++ code. Here we simply include, or take into account the required dependencies from a library called somelibrary.h and use it in the main() function. Nothing else. Pretty easy, isn’t it?

Opportunities it gives

C++ is an exceptional language, when it comes to its abilities. It lets us do virtually anything possible and impossible. Today, that tool can be used to accomplish a tremendous variety of tasks. C++ is used in projects like a Back-End server, Arduino robot, Operating Systems, and so on. With its vast list of libraries, C++ developers are welcome to nearly every software development companies. C++ developers are always welcome, since there is a variety of jobs they can have. A C++ dev can have any type of programmer’s job. For instance, if one wants to work as a back-end C++, they can use Boost.ASIO library, if they want to write cross-platform codes for mobile devices, they can use Qt, in case they want to use 3D graphics, OpenGL is ready to serve like other libraries that are ready for tons of other purposes.

The magical language (as I call it) is compatible even with MCUs. It is easy to write an MCU app using Qt, which is a super powerful technology needed for C++ developers. It allows the same developer to create a fast, powerful, efficient, and limitless (regarding to the opportunities) app for a variety of devices. It supports nearly all most common platforms:

Platforms that support Qt

Platforms that support C++

The answer to this is “disappointingly” simple. ALL platforms :D In order to make C++ code run and execute, they give it to a compiler, which does all that stuff. So, there are compilers for all common platforms. Therefore, the same C++ code can be compiled on Windows, macOS, Linux, as well as UNIX systems and I think it’s beautiful✨

To sum up, C++ is very powerful and flexible, it gives a diversity of opportunities, it is fast, and also it is cross-platform. Of course, it is not the best option in all cases, however when it comes to large and global projects that require stability, performance and cross-platform state, C++ can be extremely useful. Despite it is a quite old language, I believe it will be considered to be one of the base languages for about 8–10 years at least.

Thanks for reading 🙂

--

--