Web technologies paradox

Reading The Art of Unix Programming… This talk about C/C++ being put out of general use by higher-level languages. Well, I can sort of understand this, there are really specialized languages that better suited for a specific jobs than C or even C++. Take Perl for example. There is no way you can achieve the same degree of text processing power with C++, provided that you do not have too much free time. And even if you do have this time, you probably will just end up with another Perl implementation in C++ ^_^

But I am here not to judge about it all. I just want to note one strange thing. Among all kinds of development, there is one area where lower-level languages would be more appropriate than anything. No, I am not talking about nuclear explosions modeling nor about real-time streaming application (telemetry?) and 3D graphics. There is much more common thing. We all know it by the name of WWW. Yes, the World Wide Web. I mean that even nowadays web applications have pretty high hardware requirements. Not just to run, but to process a lot of requests simultaneously and to share limited resources of the same web server. Look at the prices and resources! Lowest possible configuration for a virtual dedicated server gives you only about 32 MB RAM! And people still tend to run Perl CGI scripts on that! At the same time, people tend to write desktop software in C, while it could be also written in any language without any visible effect on the performance at all (well, I am not talking about buggy Java implementations here!).

I am not going to blame people for using C and C++ for desktop software development. In fact, I am one of those people as well – it is way too difficult to develop desktop software in plain C or C++, but with the help of great toolkits such as Qt (and possibly GTK+) it is much easier and more fun. And after all, if I am able to quickly produce a short, high-quality maintainable source code in C++ for some task, why in the world should I go with another language? Well, enough of this, it is too philosophic question to answer it in a short and definite way.

What I am talking about is another part of this paradox. Why in the world are people using Perl, PHP and even Java for web software development?! Because C/C++ is importable? Bullshit! C is one of the most portable languages in the world and C++/Qt combination is more portable than Java, for example. And if we are talking about binary code portability, then I am going to ask: how often you are going to move your web applications from one server to another? Probably not too often. Another reason may be lack of the web technology in C/C++ toolkits. Well, I can sympathise with this. But then the next question arises: why are web technologies in C/C++ world so underdeveloped? Why have we monsters like Java JSP/Servlets, Perl mod_perl and CGI modules, PHP as a specialized language and a lot of other stuff, but have not simple libraries that would allow us to do the same things in C++? I am completely at a loss here!

Just being curious, I have made a prototype of such a technology. It took me about one week of lazy coding in evenings. It is a simple module for the Apache web server that looks for specific requests, then maps these requests to the application (which is just a shared library, to reduce latency), loads and runs it. It gives low enough latency, I have compared it with equivalent Perl CGI (without mod_perl), C CGI, C++ CGI and PHP. Of all those, only PHP has lower latency because of its high integration with web server. But I am talking only about startup latency here! If I were to measure execution performance for some typical task, I am sure that implementation in C++ would be much faster than in PHP, just because it is not interpreted language. And there are also optimizations possible, such as application caching and deferred unloading.

I am not sure yet whether I will be able to make this technology into something better than just a prototype, but the point is that I just do not see any good reason why nobody did not do that before me!

Leave a Reply