(source: atmel.com)
Background
I've a 5 years PHP background and in the last month I've been busy finding a way to do web with C++ (even if I know this is childish and stupid, I feel like C++ is the only true programming language and I have this sort of religious faith in it that makes me love it and only it).
My CGI trip
I've come across several blog posts (mostly from 2000-2003), discussions and had some chat discussions here. This is what I've gathered:
- PHP is designed for the web while C++ is a generic purpose language.
- PHP is inconsistent and have a lot of hate on the web
- PHP is the most common and supported scripting language out there
- CGI is a pretty old and common technology that was used in the days before PHP (PHP1 was actually a CGI library for C)
- In CGI (vs PHP) we have the problem of the
fork-exec
execution for each process which kinda slows everything down
- ^ this is what FastCGI is there for
- For some common mathematic operations C++ is 200X faster than PHP (because of PHP being an interpreted language)
- Big websites that requires performance doesn't use pure PHP (Facebook use HipHop which is something related to C++ and on Google there are several rumors about it being written in Perl, C++, C or some other language but PHP)
- PHP is faster to learn and to write
- C++ has very bad string manipulation methods
- There are some good (subjective) libraries for C++ CGI like wT (witty).
- Some people just told me to stay away from PHP as far as I could
Real question(s)
Today I have to decide whatever to go with PHP or CGI. And I'm asking you:
- Is CGI dead in 2013? (yeah I know it has been asked before)
- Since everybody needs performance and considering that I've time to spend like 1 year to build a solid C++ library for the web and that I don't like easy things, what are the cons in using CGI (or FCGI) nowadays (in comparison to newer techonologies)
- Is there a more efficient way to build websites with C++
- What is the real deal with FastCGI?
- Is FastCGI widely supported?
- Considering a project where I have to build a web tool, web app, iphone app, pc app and mac app all around a single website/server/database, can I actually reuse some code from the C++ website for my applications? (the database interaction for example)?
- Almost used for only very specific cases
- Don't build one use one: CppCMS*
- Yes, C++ Web Frameworks
- Because it is dead for a long time ago
- It replaces CGI making it VERY efficient
- Yes - all major (and minor) web servers support it
* Full-disclosure: I am the author