Web Applications using FastCGI with PHP vs. FastCGI with C++

EZMode

New Member
Aug 14, 2013
5
0
Topic: title
Rules: I am open to also discussing CGI with both (but keep it as mainly a FastCGI discussion, we're 2013) and/or contracting certain functionality from a primarily PHP based website to a C++ CGI (or FastCGI) application. What are your thoughts on the two? Justify your thoughts with benchmarking results and sources.

If you have a claim, please support it with a benchmark result, C++ standard citation, or reference that we (I) can follow-up on. The goal is to cover (and discover) as many pros/cons for each and discuss them in brief or extreme detail.

The goal of this discussion thread is to discuss in detail (or in brief) some of the pros and cons of both FastCGI with PHP and with C++. Sample topics include: sorting, querying a database, datagram sockets, etc.

** Do not mention anything about C++ web applications having a small crowd compared to PHP, this is only a gratuity and will not impact any benchmarking results. Also, do not try and compare CGI vs FastCGI... that is not what this topic is about. **

** Do not post if you have no intimate knowledge of the technology being discussed, no need for google scrapers. **
 

EZMode

New Member
Aug 14, 2013
5
0
my thoughts are they are both only useful depending on the application being written.

... and can you elaborate on your thoughts? Justify them? Show some examples? What you have just communicated to me (as is) is entirely useless and has unfortunately (for me) wasted about 2 minutes of my life. I am looking for a serious discussion on the topic presented here.
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
... and can you elaborate on your thoughts? Justify them? Show some examples? What you have just communicated to me (as is) is entirely useless and has unfortunately (for me) wasted about 2 minutes of my life. I am looking for a serious discussion on the topic presented here.

reading that wasted 2 minutes? wow you must read slow.
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,398
962
... and can you elaborate on your thoughts? Justify them? Show some examples? What you have just communicated to me (as is) is entirely useless and has unfortunately (for me) wasted about 2 minutes of my life.

This entire thread is useless. You're asking a ridiculously vague question. You're wanting to compare a scripting language that is compiled and executed by a web server with a general purpose programming language compiled by the machine. Actually, you just wanted our thoughts on the two. You can't debate functionality of two distinctly different languages without first defining what sort of functionality you are aiming for.
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
Several years ago, I more or less learned web app programming on the job. C was the main language I knew, so I wrote the (fairly large-scale) web app in C. Bad mistake. C's string handling and memory management is tedious, and together with my lack of experience in web apps, it quickly became a hard-to-maintain project.

C++ would be significantly better, mainly because std::string is much nicer than char*.

However, now I'd use Python every time (though PHP is not a terrible choice, and perhaps easier to get started with). Python's string handling is awesome, and it handles Unicode seamlessly. Python has much better web tools and frameworks than C++, and its regex handling and standard libraries (urllib, email, etc) work very well. And you don't have to worry about memory management.

I'd probably only use C or C++ for a web app if I was severely RAM-constrained (like on an embedded micro) or if I worked at Google and was coding a search engine that was going to have to respond to thousands of queries per second.
 

EZMode

New Member
Aug 14, 2013
5
0
This entire thread is useless. You're asking a ridiculously vague question. You're wanting to compare a scripting language that is compiled and executed by a web server with a general purpose programming language compiled by the machine. Actually, you just wanted our thoughts on the two. You can't debate functionality of two distinctly different languages without first defining what sort of functionality you are aiming for.


It's a fairly generic question with a specific topic to allow discussion to span each pro/con. If you had knowledge of either approach then it would be fairly easy to discuss say: implementing a quick sort algorithm to sort 100,00 nodes of a linked list and benchmarking the performance using Fast CGI with PHP and Fast CGI with C++, or benchmark the elapsed CPU time and resources required to query a specific table from a database 100,00 times repeated, or if C++ scales well as the application size grows in comparison to PHP using Fast CGI (however the Fast CGI aspect is not relevant). These are the types of input I am looking to see.

Don't contribute to this discussion if you have no knowledge of both topics (or even one for that matter). I have stated what I wanted to see as input in both the original thread and this post, use it as a guideline.
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Using C++ is likely to result in a radically faster application than PHP, Perl or Python and somewhat faster than C# or Java.
On the other hand, due to the reasons Macemore mentioned, developing a web app in C++ will take longer and will be harder to maintain. Furthermore, it's far more likely to contain serious security holes (nowadays everyone worries most about SQL injection and XSS - but if they were writing their web apps in C++ it would be buffer overflows and it would be their entire networks getting p0wned rather than just the data).
And that's why almost nobody writes web apps in C++ these days.
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,398
962
It's a fairly generic question with a specific topic to allow discussion to span each pro/con. If you had knowledge of either approach then it would be fairly easy to discuss say: implementing a quick sort algorithm to sort 100,00 nodes of a linked list and benchmarking the performance using Fast CGI with PHP and Fast CGI with C++, or benchmark the elapsed CPU time and resources required to query a specific table from a database 100,00 times repeated, or if C++ scales well as the application size grows in comparison to PHP using Fast CGI (however the Fast CGI aspect is not relevant). These are the types of input I am looking to see.

Don't contribute to this discussion if you have no knowledge of both topics (or even one for that matter). I have stated what I wanted to see as input in both the original thread and this post, use it as a guideline.

In your original post you offered little to no insight on what you were actually looking for. Benchmarking specific tasks is only performance based comparison of that specific task. It offers no comparison of the functionality of the two languages. Like Kryptos said, C++ is not used in small scaled web environments because it creates unnecessary overhead and, if inefficiently written, can lead to memory leaks. Its portability is also minimal.

This thread would be better off comparing functionality and performance of PHP vs Python.
 

EZMode

New Member
Aug 14, 2013
5
0
In your original post you offered little to no insight on what you were actually looking for. Benchmarking specific tasks is only performance based comparison of that specific task. It offers no comparison of the functionality of the two languages. Like Kryptos said, C++ is not used in small scaled web environments because it creates unnecessary overhead and, if inefficiently written, can lead to memory leaks. Its portability is also minimal.

This thread would be better off comparing functionality and performance of PHP vs Python.


No, the thread would be better off as-is as these are the topics I wanted to compare. The only improvement would be less clutter of off-topic posts and clarification requests.

Using C++ is likely to result in a radically faster application than PHP, Perl or Python and somewhat faster than C# or Java.
On the other hand, due to the reasons Macemore mentioned, developing a web app in C++ will take longer and will be harder to maintain. Furthermore, it's far more likely to contain serious security holes (nowadays everyone worries most about SQL injection and XSS - but if they were writing their web apps in C++ it would be buffer overflows and it would be their entire networks getting p0wned rather than just the data).
And that's why almost nobody writes web apps in C++ these days.


Can you show your benchmarked results to support your claim -- I would be curious to see the tests you ran. This is true and of course a concern, however it's a concern regardless of the platform I feel. I disagree with the last statement, I feel as if C++ web applications are under-valued as they are hyped to be too difficult. The overhead is in the amount of initial code you will need to write to support your infrastructure, however I feel that it will quickly trade-off (no proof, just an assumption).
 

Adil

DevBest CEO
May 28, 2011
1,278
716
Why would you even contemplate writing a web app in C++? What benefits other than *speed* would it have?
Write your backend services in it, it's more suitable for that kind of stuff.
 

Users who are viewing this thread

Top