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.
7
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.
2