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?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
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.
The drawbacks specific to C++ are:
Maybe take a look at CPPCMS? Or maybe wt if you want to make a GUI-style website?
Also check these questions:
Wordpress running in PHP with a few plugins installed brings my Winders server to it's knees. So I have no problems at all with the idea of implementing a web application in C++. Speed is a critical part of the web experience.
Graphic design tents to drive the majority of web projects. PHP is an obscure scripting language that runs inside HTML. Allowing the PHP authors to escape in and out of HTML. There are many benefits with working with HTML as a result.
Still, you could implement any number of HTML template solutions in C++.
One could provide you with an long list of Python and PHP frameworks that make for rapid development, but if you have lots of time then C++ is definitely possible.
What I don't understand is your decision to do C++ on Windows. lol
It certainly is an unusual choice. C++ wasn't designed with web applications in mind, and while libraries exist to write, say, FastCGI applications with C++, you have to do a lot more work to get your basic application up. "Web languages" usually do a lot of things for you that you have to get from elsewhere in C++, such as implementing the HTTP protocol, generating HTML, etc.
Also, web applications are mostly about strings, which isn't exactly C++'s strongest side - there is no string type built into the language itself, and this leads to a few quirks and makes string processing more clumsy than it would be in more high-level languages. Handling character encodings correctly in C++ borders on black magic. And C++ can crash really hard, on fairly innocent-looking code, which is far less likely with a higher-level language (they too can crash, but in most cases, the web server can recover gracefully, especially on platforms that use a per-request lifecycle model, like PHP).
That said, if you have most of the codebase written already, C++ might still be a viable choice. You will need to find some libraries to cover all sorts of web things (most notably, you want to be able to either integrate a standalone HTTP web server into your program, or hook into, say, Apache, either through FastCGI or by compiling to a module; you will also want some kind of templating library to make rendering HTML documents painless).
Finally, there's the developer market issue. There are plenty of C++ developers available, and even more web developers, but the overlap is probably not that large, so if you ever need to hire people to work on this thing, you'll have a somewhat harder time than with, say, PHP.
As others have said, conceptually, C++ is a fine environment for a web server development. There are however, several considerations as you make that decision.
The popularity of scripting languages for web server design is turn around time. Simple changes can be made easily with the demonstration of results nearly immediate. You will find that any good web server design will offer similar capabilities. Indeed, C++ is an excellent environment for achieving that goal.
The key to building a good web server application system is a separation of UI from code. A goal in building a web application environment is to avoid "Your UI is in my code and your code is in my UI."
I would like carefully at systems like cppcms. I would expect that it offers something similar.
You don't need a scripting language to offer flexibility and performance.