
Ask HN: Do you C++ for Web App Dev?  - dryicerx
How come C++ is so rare in the web app realm?<p>It's a pretty bad choice for using on frontend of sites, but for backend stuff where you have CPU bound tasks it's great. Lean and Fast. But when ever I bring this subject up, I get weird or confused looks...<p>* Some reasons I am given is that it's complicated. Not really, writing web applications in C was complicated, but with the C++ STL and Boost, lot of your generic things are a breeze like string manip, not to mention the millions of other libraries out there.<p>* Development time: For me writing a Python or PHP app that does the same thing takes equally the same amount of time as writing it in C++. (this is for backend related stuff like computations and other CPU hard stuff, not front end)<p>* Other's are equally fast. They can be, but you have to add additional layers on top, accelerators, caching systems, etc etc and make sure everything is all optimized. A lot of things on top of what you would normally do to achieve a C++ level app aperformance<p>C++ with FastCGI is a excellent choice for backend development, yet it's so rare. I don't even recall a single time this was brought up during web development talk or conference.<p>Why do you think this is?<p>(Backstory: The backend for our project is a lot of C/C++ on FastCGI on Apache. My workflow usually consists of Pyhton for prototyping and verification of design, then writing it in C++ for production, the speed is not even comparable).
======
cperciva
No, I don't use C++. But all of my code for Tarsnap (including website) is
written in C, aside from a few very small shell scripts.

------
arghnoname
Perhaps a good C++ programmer writes equivalent code in C++ just as fast as he
would in Python (For some kind of tasks I've found this to be true as well),
but how many good C++ programmers are there? It's a brutally tricky language
and getting quick requires knowing how to avoid the sometimes subtle pitfalls.

I suspect that for the vast majority of web apps though, PHP, C#, Rails,
whatever is 'good enough' and they run into the db as a bottleneck if anything
and would rather scale out their scripting layer with more machines. The
framework ecosystem around C++ as a web app language also isn't as rich, so it
requires more work to get started.

------
keefe
Long post is long. I don't see any big advantage to using C++ vs Java -
performance is similar with recent optimizations and the vast majority of web
services and libraries support java.

------
swolchok
Re: development time, you must have a pretty fast compiler. One big argument
in favor of dynamic languages is the shortened edit/compile/test cycle; it's
down to edit/test.

Re: speed, I think the prevailing wisdom is "write the damn thing in Python
and if it's too slow, we'll profile it and write the tiny bit that needs to be
fast in C or C++". You still have to do this with C++ -- native code does not
magically make your application bottleneck-free.

------
astrodust
If there was a good, straightforward Mongrel-type HTTP service builder for C++
it might be more popular.

~~~
dryicerx
There is, FastCGI.

On the FastCGI module to the web server (eg. Apache) you can configure the
number of processes to spawn for that application, and the FastCGI library
will also provide you with many routines to take care of the input, output,
and http header parameter handling.

(I hope that's what you meant by Mongrel like HTTP service builder, assumed
you were talking about the clustering using it)

~~~
blasdel
No, that is absolutely not what is meant by "Mongrel-type".

FastCGI != HTTP. There is no good reason for FastCGI to exist, it doesn't do
anything HTTP wouldn't do better.

~~~
cperciva
_There is no good reason for FastCGI to exist, it doesn't do anything HTTP
wouldn't do better._

Not true. The FastCGI interface is much simpler than the HTTP interface, which
makes it much less bug-prone.

------
silas
fastcgi++: <http://www.nongnu.org/fastcgipp/>

