Reputation:
I want to create a web application that runs with very little RAM and I think C++ can help me achieve that.
Now, many people say C++ is unsuited for web development because:
But I'm sure the C++ community have found ways to alleviate all those (maybe not the compile time) however since I'm not a regular so it is hard for me to put a value on what I find in Google.
So I'm asking for some guidance. I would appreciate if you share what works, what tools/libs are current and alive. What strategies can help with web dev in C++? FastCGI or embedded server (Asio / POCO / Pion / etc.)? How do you address security concerns?
Thanks a lot for any help
Upvotes: 9
Views: 4253
Reputation: 189
You can try Cutelyst a C++11 built with Qt, with one of the best positions on TechEmpower Benchmarks.
Even though it requires Qt 5.6+ a full CMS (CMlyst) uses around 6MB of RAM while serving around 3000 requests per seconds on a single core.
And for your string manipulation issue QString is just an amazing class for that.
Upvotes: 0
Reputation: 1304
There is nothing wrong with trying to build a web app in C++. It's actually a lot of fun. What you need is a:
Upvotes: 7
Reputation: 112404
Give us some more hints about what you're trying to do.
You can write a good old-fashioned cgi program in C++ easily enough, and run it with FastCGI. We used to do that all the time.
You could write a C++ program embedding a lightweight HTTP server as well.
Both of them are much bigger PITAs than using something like perl or ruby.
So for why C++?
Okay, got it. The main thing about FastCGI is that it avoids a fork-exec to run your CGI program, but it is a little bit different API. That's good, but you still have the problem of handling the HTTP stuff.
There are, however, several very lightweight HTTP servers, like Cherokee and Lighttpd. In similar situations (building web interfaces for appliances) I've seen people use one of these and run their C/C++ programs under them as a CGI. Lighttpd in particular seems to concentrate on making CGI-like stuff fast and efficient.
Another update. I just had cgicc pointed out to me: http://www.gnu.org/software/cgicc/
That might solve some problems.
Upvotes: 1
Reputation: 21393
There's the Wt Project. It uses a paradigm similar to Qt's signals/slots.
Upvotes: 9
Reputation: 71930
Our web app backend is in C++ via CGI and we use Clearsilver templates along with the HDF that comes with it.
Upvotes: 1
Reputation: 20237
In your other question you mention that your embedded system is openwrt. As this router firmware already comes with a embedded web server (for it's administration UI), why don't you use that for you app as well?
Upvotes: 1
Reputation: 45127
ATL Server. It's open source too! And of course there is always ISAPI. Ah, the bad old days. :)
Upvotes: 1
Reputation: 22475
ATL Server is a library of C++ classes that allow developers to build internet based applications.
Upvotes: 1
Reputation: 7799
Have you looked at http://www.tntnet.org/. They have created a... well let me cut and paste from their website:
Tntnet is a modular, multithreaded, high performance webapplicationserver for C++. To create webapplications Tntnet has a template-language called ecpp similar to php, jsp or mason, where you can embed c++-code inside a html-page to generate active content. The ecpp-files are precompiled to c++-classes called components and compiled and linked into a shared library. This process is done at compiletime.
I've used it and it has quite a small overhead plus it has screamingly fast dynamic page generation. Makes PHP, Ruby etc snails in comparison because with tntnet you are running compiled C/C++ code.
Upvotes: 13