Right now, most webservers were programmed in Python, PHP, Java and ASP.net The reason why has historical reasons. The first scripting language for building web-service was Perl, which is bash-language under UNIX. Later, more advanced languages like Python and PHP were developed. They have object-oriented features and have a simplified syntax. Most web developers today see Python and PHP as a here to stay language, but in reality their choice makes no sense. From Python for example it is known, that the language is 20x times slower then a native compiled C++ application. If a webserver is driven by Python this a huge slowdown.
At the same time, web scripting language are not very powerful and produce a lot of programming errors. The better alternative is to replace them all with modern C++17. The CppCMS framework is one example. It provides a blog engine, a wiki system and a general web application framework. Their main difference to existing PHP frameworks is, that it is fast and was programmed in C++. That means, if somebody doesn’t like a compiled language which is run naively on hardware he will don’t like CppCMS. What would happen if the server in the Internet switch from past PHP scripts to modern C++ programs? A huge saving in energy cost is the result. That means, the power consumption of the CPU is lower, if the program they run is programmed more efficient. A second aspect is, that projects written in C++ have the tendency into a higher software quality which means less bugs, and less attacks from hackers.
Teaching C++ for webprogramming isn’t a technical problem. Writing a C++ application which is able to print HTML5 tags to the screen is easier then with PHP. The problem is, that most web developers are not familiar with C++. They belief that a webserver has to be programmed with a scripting language which runs in a virtual machine and which isn’t C/C++. Some of them belief, that a Java based webserver is a high-performance application. But they never have seen the power of C++.
Sometimes the argument is, that the advantage of C++ against PHP is only small. A performance improvement of factor 3 is not a reason to switch the entire application. But let us ask the question from the opposite direction: Why should somebody stay on PHP, if C++ is better? The main advantage of C++ is, that the language can used for any project: in the Web, on the desktop, for games and so on. In contrast to PHP which is a web-only language. Somebody who is able to write PHP code, isn’t able to program a jump’n’run game with SFML. C++ was designed as general purpose language, that mean it compiles under any operating system, can be used for any purpose, is the fastest language and can’t be replaced by any other language.
The historical reason why C++ was ignored by early web developers has to do, that the opinion was that C++ the language is complicated and they want to make things easier. But, which part of C++ is difficult to handle? C++ consists only of some statements like if-then, for loop and class. The reason why C++ projects become complicated has to do with the domain. For example, programming a web framework or a 3D game can become a demanding task. Switching the language from C++ to Python doesn’t make things easier, because Python has only the same keywords (if-then, for loop, class statement). The real problem is domain centric, and to overcome it some kind of better library, a version control system and a bugtracker are the answer.
Perhaps a small example, why C++ is a easy programming language. Suppose we want to write HTML tags into a file:
myfile << "subject " << "predicate "<< "object\n";
Is the syntax more complicated then with PHP? No, what the programmer has to do is open the file, write some text to it and close the file. The only challenge is, that this kind of programming (using C++ for output a HTML file) isn’t very common. Only few tutorials are describing it.