Web App Development – Drawbacks of Using C++ and MySQL?

cMySQLsoftware-as-a-serviceweb-applications

I've inherited a pretty interesting project where there is a good opportunity to take an existing piece of software and turn it into a SaaS web app. As the project is inherited, the code base/ framework is already defined as C++ and MySQL. The app itself is compiled and run as an EXE on Windows Server. The UI is web based and the app works as a kind of server. From what I do know of modern web apps, this is perhaps an unusual choice. These days, most people seem to opt for a PHP framework or Ruby on Rails. Certainly that is the impression I get from reading blogs on the subject. So, I'm very interested to know if a C++ EXE backed by MySQL is a solid foundation for a web app, or whether we should be looking to build in another way?

Best Answer

It is OK to make a web application using C++ IF the benefits outweighs the cost, obviously. Google, Amazon, Facebook are all built with C++ for efficiency in speed, memory and energy - aka servers costs.

However as you guessed, there are drawbacks to using C++ for this. It depends on your tools though.

First let me cite cppcms website on this:

When CppCMS Should Be Used.

C++ language is far from being popular for Web development for many reasons: lack of appropriate tools, skills of developers and many more.

However, there are areas where C++ web programming with CppCMS becomes very useful and efficient, and some where it is just a waste of time.

When CppCMS should or can be used?

1.High load web sites and application with hundreds and thousands hits per second, where high performance, efficiency and scalability is required.

2.Application that require scalable Comet/Server Push technologies --- CppCMS can efficiently handle hundreds and thousands simultaneous HTTP connection with minimal resources usage.

3.Embedding web interface into existing C++ applications/services with a small cost of additional library.

4.Embedded underpowered devices -- CppCMS allows creation of rich applications with relatively low cost of hardware that would perform reasonably fast.

When Not To Use?

If you create small web applications that do not require high loads and require very short time-to-market period -- probably tools like Django or RoR would be more appropriate for such tasks.

The drawbacks specific to C++ are:

  • Compile times can be very very very very slow compared to other languages. This might impact iterations, release interval but also developer's moral. Make sure it's worth it.
  • Most of the time, you need to compile changes. It can be avoided but it's the usual.
  • Writing modern C++ makes it easy (to learn, read, write, debug, etc.), but a lot of C++ developers don't know what is Modern C++. So if you work in team, you need to have good knowledge of Modern C++ from the whole team. If not, you will easily get into very complicated bugs. That said, it's more a people problem than a language problem. It's just that C++ history didn't help make it easy to grasp. Good teaching is not as common as in more modern (historically) languages.
  • Unicode is still poorly supported by the core C++ language, making it a potential source of great pain. Just use UTF-8 everywhere and some libraries (look into boost) to manage it.
  • C++ standard don't know what is a library. So we use conventional ways to manage them on different compiler/linker/OS. This might be a problem if you start to get into cross-platform code that need to load/unload "on the fly" some modules.

Maybe take a look at CPPCMS? Or maybe wt if you want to make a GUI-style website?

Also check these questions: