Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've been a C# developer for long time, focused on ASP MVC the most. Two years ago, basiclly due to the lower costs and ease of deployment/management I began to migrate my projects to linux using Node.js for serving HTML and Mono for all the backend operations. They talk to each other using HTTP REST API.

As my skills in Linux have improved more and more I find this Node.js/Mono combination kind of weird. Mono is a great thing but there are issues now and then, more related to the implementation itself than the language.

Now I have like three weeks available in between projects and I would like to dive into C++ as my backend. I have tried some Python and I really liked it, but I require fastest responses, that's why C++ came to me. Java is not an option, because although the language itself is pretty close to C#, it has a bunch of stuff I really wouldn't like to bother with (Maven to name one) and at the end of the day, that would decrease my productivity, at least while I become more proefficient on Java (just configuring Eclipse for a Jersey tutorial took me like 2 hours!).

I really don't need anything fancy, since all that node.js does for me is serving html/css/javascript, some real time notifications (socket.io) and that's it. My backends are more reading from tables, complex SQL transformation and validation of the data the client sends. The template engine I use is Jade which is cool since I type less, but I wouldn't mind to switch to plain HTML. 99% of the job in my projects is done using Angular.js via JSON calls. Most of them are single page applications with lots of logic on the client and consuming REST API's.

I really would like to cut all Mono/.NET dependencies and develop on something more native to Linux. At the same time I would like to say goodbye to Node.js as well in trade for one backend to serve my API and static HTML pages.

If you have been here before, please let me know what are the current choices and anything that would help me on this experiment.

Thanks a lot in advance for taking the time to read my concerns.

EDIT: I forgot to mention I read about Casablanca project. It looks promising but again, it belongs to Microsoft under the covers of the white open source, just what I have been avoiding lately.

share|improve this question

closed as too broad by Greg Hewgill, gnat, Bart van Ingen Schenau, jwenting, Kilian Foth May 7 at 10:22

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
C++ has no support for providing a web-interface out of the box. If you want to use C++ for your REST API, your most likely need some additional libraries as well. –  Bart van Ingen Schenau May 7 at 6:51
    
Thanks for your comment. Such as... –  mau May 7 at 7:02
    
@BartvanIngenSchenau so? Neither does C# or PHP. I think only node.js has webserver functionality included in it out of the box. Don't mistake Apache as being part of PHP, or IIS or WCF as part of C#. –  gbjbaanb May 7 at 7:49
    
@gbjbaanb: I was thinking at a far more basic level. Or do you consider the .NET framework also not to be part of the standard library of C#? The C++ standard library doesn't even have the concept of a socket. –  Bart van Ingen Schenau May 7 at 8:40
    
@BartvanIngenSchenau well boost has one, and its pretty much the non-standard standard library. All these languages have this functionality as part of libraries, some libs just happen to be bundled with the default install. C++ doesn't have a controlling company to bundle these for you. Maybe someone should! (BTW Visual C++ does come bundled with "REST services for C++" now) –  gbjbaanb May 7 at 8:53

1 Answer 1

up vote 2 down vote accepted

I recently had to implement some web-server functionality to an existing application and used Mongoose for this (actually I used CivetWeb, the non-GPL version), its very simple embedded web server - add 2 files to your project, read the options, call the server function, and implement a callback for each url route. Trivially easy and its very fast.

eg.

CivetServer myServer(options);
myServer.addHandler("/route", new CallbackHandlerClass());

Then implement a handleGet() method in your handler class. You can get the parameters from the querystring and whatever else you need to do in there.

Its designed for embedded systems but there's no reason it can't work for more feature-rich environments. Obviously, you may have problems in extending your applications as you will have to recompile and then restart the server - no editing a script file and copying it to the server in this kind of compiled, native-code environment, but I guess you're already used to that with .NET

If you do want more, then there are other systems written in C++ that are available. CppCMS comes to mind which does allow dynamic reloading of shared objects so you can change handlers dynamically.

Or you could try the Boost option - boost::asio includes code for a simple http server but I'm not sure you'd want that for production as its single threaded (but that hasn't hurt node.js!)

All in all, after working with the embedded webserver, I think I prefer it simply for its simplicity. All the effort you have to take to get an Apache or IIS environment up and running is gone, its just code a service and run it.

And lastly - check out this SO link that has a link to some benchmarks for several C++ webservers.

share|improve this answer
    
boost:asio looks good, I will give it a try. Thanks! –  mau May 7 at 12:48
    
But beware that web server. I like the look of Nxweb from that link, but YMMV. Enjoy. –  gbjbaanb May 7 at 12:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.