![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
in a van by the river
Industry Role:
Join Date: May 2003
Posts: 76,806
|
c++ vs PHP/mySQL
I'm not a programmer but can anyone explain why server side scripts written in c++ tend to be better than those written in PHP/mySQL? my understanding is the c++ is faster and uses less resources..
I'm talking to some guys about having a custom script programed for a service I want to offer. They are trying to convince me to go with PHP/mySQL, I'm not sure that will be the best option for what I'm wanting to do. I'm just looking for some basic information on why c++ is better for some things and PHP/mySQL is better in other areas
__________________
In November, you can vote for America's next president or its first dictator. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Industry Role:
Join Date: Jan 2003
Location: In a Tater Patch
Posts: 2,321
|
well for one.. c++ is precompiled application thats written. where as php is a scripting language that is thrown through an interpretor(spelling) and then spits out the results.
lots of bench marks against the two.. simple.. compile a program once.. give stuff to spit out.. or.. compile give/ get results.. over and over and over again. php is just easier to use. but if you want speed and so forth c++ and mysql++ (the c++ library for mysql) is a way to go. what are you looking to do? hit me up on icq.
__________________
Managed Hosting - Colocation - Network Services Yellow Fiber Networks icq: 19876563 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: May 2003
Posts: 500
|
Because PHP Is a scripting language that was written in C and C is the actual language.
Anytime you stack something on top of something else it becomes less efficent. You should have all of your scripts written in Assembly BMF |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Join Date: Jun 2001
Posts: 853
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Jun 2003
Location: PornStudio
Posts: 868
|
if you use caches and compiled php code it gets a whole lot faster. not many people really need the speed of c++ my
![]()
__________________
http://www.fastthumber.com |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
Confirmed User
Industry Role:
Join Date: Jan 2003
Location: In a Tater Patch
Posts: 2,321
|
Quote:
__________________
Managed Hosting - Colocation - Network Services Yellow Fiber Networks icq: 19876563 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
in a van by the river
Industry Role:
Join Date: May 2003
Posts: 76,806
|
ok, that's the basic Idea I had.. I didn't know the specifics of each language as I'm not a programmer, but I kinda figured with the traffic adult can push c++ would probally be a better option.
__________________
In November, you can vote for America's next president or its first dictator. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
CjOverkill
Industry Role:
Join Date: Apr 2003
Location: Woldwide
Posts: 1,328
|
Nah, C and php are lame, better go on pure assembly or plain binary. Why not just a hardware device? FPGAs are cheap
![]() Just joking. The main difference is that php+mysql is very easy to be scaled and is completely painless. C in exchange is not. If you start from there you can make a better decision than speed of C and php.If you use zend or turck encoded php it will be the same fast as C (don't forget that C loads lots of system libraryes on each run). It's not A is faster than B, it's more like program design A is faster than program design B (whatever it is written on). You can have slow program running C. Windows is a perfect example ![]()
__________________
CjOverkill Traffic Trading Script Free, secure and fast traffic trading script. Get your copy now ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Damn Right I Kiss Ass!
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,409
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Join Date: Oct 2002
Posts: 3,745
|
C or C++ can do many things that PHP can't
(for example, PHP is written in C), and C or C++ apps will generally run a shitload faster using the same algorithm, this is true. However, I think that's a tiny percentage of the reason most C apps are a shitload better than most PHP apps. PHP was designed to make easy things easy - very, very easy. Building a program with PHP is as easy as building a toy with Legos. Well, at least it's a good comparison to say that Legos are to welding what PHP is to C. Highly skilled professionals don't often use Legos, children do. Same thing with PHP - being super easy to use makes it attractive to middle school geeks, but means that "hard" concepts like "integer variables" are leeft out of the language. These "hard concepts" are what the pros consider to be the basic tools of their trade. Also, PHP, like Lego, make it really easy to build crap, shit that doesn't hold together, and very, very difficult to build a quality product. Specifically, after 7 years in this business I'm still looking for a PHP script that doesn't have a serious security issue. I'm sure I'll find one someday. The guys who code C tend to be the same guys whose bathroom books include 800 page tomes on such computer science topics as relational calculus (like me). So I'd say while there are inherent differences in the languages, it's the programmers that they attract which makes a much bigger difference. Perl and VB are both in the middle, and spread thinly. With the "strict" pragma in force and using good OO design principles Perl (and VB) can be professional languages that a software engineer can be comfortable with. On the other hand both can also be used sloppily.
__________________
For historical display only. This information is not current: support@bettercgi.com ICQ 7208627 Strongbox - The next generation in site security Throttlebox - The next generation in bandwidth control Clonebox - Backup and disaster recovery on steroids |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Join Date: Aug 2003
Location: Netherlands
Posts: 816
|
<?
echo "Hello World!"; ?> first php program without security holes |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Industry Role:
Join Date: Jul 2003
Posts: 3,108
|
I hate to TOTALLY disagree to all of this, but I sadly have to
![]() C++ vs PHP/mySQL is first of all a bad comparision. 1) We need to compare C/C++ vs PHP.. the database type will be the same, makes no sense otherwise. 2) We need to make sure what EXACTLY we are talking about: a) C/C++ CGI App vs PHP Script b) C/C++ FastCGI App vs PHP Script c) C/C++ Apache Module vs PHP Script I would say, most of you here were thinking of a), so lets look at that one: Overhead when executing a C/C++ CGI app is rather huge. Why? Well, Apache first has to run an exec call, which basically FORKS apache and then lets the CGI app take over the process. This prosess is rather time consuming and resource hungry. A PHP Script is simply loaded by the php module, which gets called instead of the base module. So no time is lost here, then PHP has to compile the script, obviously, not the fastest thing, but in terms of resources, its a HUGE advantage to the exec involved in the C/C++ App. Now, for Database connection, the C/C++ CGI app has to open a new connection to the Database, whereas PHP will have it already in most cases. Although also connects are fast, its still a time saver for PHP. Last but not least, C/C++ apps will tend to be harder to write and a lot less flexible. Load on the server will very likely also be higher when using C/C++ apps because more apps are running. And, like many posted here, PHP can be extremely speed up by taking out the rather slow parsing step and by caching the system. This caching does not mean caching the OUTPUT, it means caching the fully compiled and optimized script in various stages in memory to run it even faster. So, unless the person writing the app in C/C++ really has a _VERY VERY VERY VERY_ good rep of knowing how to do CGI correctly, I would ALWAYS prefer PHP over anything else.
__________________
"Think about it a little more and you'll agree with me, because you're smart and I'm right." - Charlie Munger |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 | |
Registered User
Join Date: Dec 2002
Posts: 1,291
|
Quote:
Code:
[BITS 16] ;16 bit code gen [ORG 0100H] ;start address for com file [SECTION .text] ;code portion START: mov dx, hellomsg ;load the address mov ah, 9 ;func 9 displays to stdout int 21H ;call to dos mov ax, 04c00H ;exits prog int 21H ;return control to os [SECTION .data] ;section containing data hellomsg db "Hello World!", 13, 10, "$" ;push the msg |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 | |
Confirmed User
Join Date: Jun 2003
Location: PornStudio
Posts: 868
|
Quote:
![]() caching can produce some overhead, true. it always depends what you wanna do ![]()
__________________
http://www.fastthumber.com |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
pain in the Ass
Industry Role:
Join Date: Jan 2004
Posts: 3,727
|
I read a LOT of crap here.
At first you are mistaken C with C++, which is a HUGE difference in performance as well as program design. C is the fastest thing there is, you can easily use it to create webapps using the cgi library. C++ is an OO language that's a tat slower, more like JAVA. About C (not C++) versus PHP : PHP is SLOW when you use it as an Apache module, average as a standalone app, and reasonable to good with Zend accelerator (cache). It's very easy to learn, mature, but still, every time you start a thread (user request) you have the 8 megs of memory use for every thread. With C, if you start an executable that's 5 kB, you use 5kB of memory. That's a lot of threads, huh ? You say C is slow if used with Apache ? That's because Apache is SLOW, use THTTP with FastCGI and be very surprised. You can have 500 concurrent users with CGI with no noticable system slowdown. Now try that with Apache (40 - 60 concurrent maximum). Here's a good link to compare some languages (benchmark) : http://scutigena.sourceforge.net/ |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
Confirmed User
Join Date: Jun 2003
Location: Kona, HI
Posts: 204
|
Quote:
In my opinion, the highest performing web app is going to be a pure C application with built-in web serving. Of course, this is massive, insane overkill for almost any application, and it means that in addition to your actual app, you effectively have to maintain a web server as well (well, you can buy web server source code off the shelf, or a few other options, but it gets crazy). All that said, I can't imagine a web app that anyone in this industry is going to need that PHP wouldn't be able to do just fine. The development costs and complexities with C/C++ are dramaticalyl higher, so if raw performance is an issue you'd probably be better off going PHP and just throwing more hardware at it than going C. Cheers -b
__________________
ICQ: 12005327 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 | |
Confirmed User
Industry Role:
Join Date: Jul 2003
Posts: 3,108
|
Quote:
__________________
"Think about it a little more and you'll agree with me, because you're smart and I'm right." - Charlie Munger |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
in a van by the river
Industry Role:
Join Date: May 2003
Posts: 76,806
|
lot's of good points guys.
__________________
In November, you can vote for America's next president or its first dictator. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 | |
Confirmed User
Industry Role:
Join Date: Jul 2003
Posts: 3,108
|
Quote:
![]() I totally agree with you there, but I did not talk about that. Why wouldn't I agree, I'd say I am the best example. You mentioned that you can not imagine a web app that anyone in this industry is going to need that PHP wouldn't be able to do just fine. I'll tell you one, counters. I mean public ones, not your own little counter for your webpage. In that kind of environment, a standalone web server is your best bet. Or else you will be a second web side story and need 50 servers to handle your traffic, or 10 like sextracker (I think its 10? not sure exactly, might be 5). I have written statistics apps that at peak times handled over 80 million impressions a day on a single server without huge problems, and that while offering statistics others dreamed of. Thats over 1000 concurrent users at peak time btw AnalProbe ![]() So yes, for HIGH-END performance HUNGRY systems, you will need to use C, obviously. Why would you not anyway. But like I said before, 99% of the people here will NEVER have a system that needs more than PHP.
__________________
"Think about it a little more and you'll agree with me, because you're smart and I'm right." - Charlie Munger |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 |
pain in the Ass
Industry Role:
Join Date: Jan 2004
Posts: 3,727
|
Hey man,
I LOVE php, really. I write almost all my webapps in PHP, sometimes Perl or Python. But I write my stats app and OS like stuff in 100% C. Nothing beats the speed of C, my stats server (seperate) counts millions of hits a day with an average serverload of 21 - 23 %. Every hit gets stored in a SQLite DB, storing 42 fields / hit. BTW, did you like the benchmark link ? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#21 | |
Confirmed User
Industry Role:
Join Date: Jul 2003
Posts: 3,108
|
Quote:
And yes, like I said in my reply to aiken, very few things need C, but big stats systems definately do. We had 80 million hits a day, server load at 70% (dual system), collecting over 100 static fields and path, referrer, multi page, browser and os dynamic data. dynamic as in, they were not just count-increases, its shit that had to be sorted and so on and searched for to add up.
__________________
"Think about it a little more and you'll agree with me, because you're smart and I'm right." - Charlie Munger |
|
![]() |
![]() ![]() ![]() ![]() ![]() |