June 21, 2019

Dlang vs. C++


The D language project is the attempt to replace C++ sourcecode. Similar to C++, it's a compiled language and it comes with a large amount of libraries out of the box. The executation speed is a bit slower, but the syntax is easier to read. So what is the deal, will replace D the C++ standard?
No it won't because of two reasons. The first one is, that dlang is not compatible with C++, which means that the Dlang compiler can't read C++ sourcecode. As a consequence, D stands in competition to C++ which is a hard job because the C++ universe is large, powerful and contains of a large user base. The second problem is, that C++ is more advanced than it looks on the first impression. It's correct, that outdated C++ code from the year 1993 looks for today's eye obsolete, but new standards like C++11 and especially the upcoming C++20 standard will introduce lot of improvements. For example, in the C++20 standard the handling of import modules will become more easier. Very similar to the dlang, it's enough to write down a simple “import std;”
The chance that a programming language is able to replace C++ in the near future is low. Which means, that the C++ compilers are producing the fastest code on earth, that the community is working on improvements and that large amount of productive code is written right now in C++. Smaller attempts to replace C++ like Java, C#, Dlang or Go will fail. In some minor aspects they are working better than the C++ standard, but in general they are not a replacement for the queen of all programming languages.
To understand why C++ is the queen of programming languages it makes sense to take a look into the compiler infrastructure. There are at least three major compilers available: GCC, clang and Visual studio. Additionally, Intel has also a C++ compiler. These compilers are not small projects but they are the backbone in professional computing. It's hard or even impossible to compete with these projects. Calling C++ the standard in modern programming is an understatement. It's the most influential language and the most powerful project available. All the other programming languages from the TIOBE index like PHP, Python, Java, Perl, Javascript and Swift are only an addition to C++. These are niche languages, but C++ is the main development platform for the important code.
Let us understand why C++ is critized. A common argument against C++ is, that the language has to much features and the syntax is changing over the time, which makes it hard to work with existing code and increases the complexity. To adress this issue we have to go a step back and describe what modern programming is exactly. The idea is, that standard libraries are available, and that the language provides object-oriented features to build on top of these libraries new software. This can be realized in the C++ universe very well and results into highly productive workflow. What the average C++ programmer is doing is search for a game library, writes some C++ classes from scratch, tests the code and then he compiles the code into a binary file which can be deployed. So, what is the problem? Right, there is no problem, it's the best practive method for creating software and C++ is doing a great job. Problem which are available can be solved within the C++ ecosystem. They are minor problems in a healthy environment which can be fixed in the next C++ standard or with individual workarounds. That means, if somebody things, that the pointer system in C++ doesn't make much sense and takes this as a reason to switch over to Java, he has taken a small issue for arguing against a powerful language. Sure, the pointer situation in Java is better than in C++, but Java is not better than C++.