473,769 Members | 6,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing my serverside stuff in C or in PHP?

Hi,

I am trying to figure out if I should learn C and C++ to write CGI
programs, or if I should just use PHP for my web site.

I want to write a high traffic website that would call executibles a
lot dealing with text.

Are CGI programs written in C faster then PHP script programs?

Nick
Jul 17 '05 #1
5 1783
ma******@hotmai l.com wrote:
Hi,

I am trying to figure out if I should learn C and C++ to write CGI
programs, or if I should just use PHP for my web site.

I want to write a high traffic website that would call executibles a
lot dealing with text.

Are CGI programs written in C faster then PHP script programs?


It depends on the implementation. Compared to CGI I'd say that PHP would
probably be faster, since PHP doesn't require forking an additional
process each time.

If you were to do it in C for speed, you'll probably want to check into
the API of the web server. (Such as Apache modules) In that case, C
would be faster.

You whould probably ask yourself how valuable your time and portability
are. Doing it in C can cause problems if you wanted to go from one OS to
another. (Or even web server to another)

Depending on the complexity of the application, it'd probably be
cheaper (and easier) to balance the load across multiple servers and use
something like PHP or Java servlets. (java servlets/JSP is slow at
first, but once the JSP's are compiled they run a lot faster)
Jamie

--
http://www.geniegate.com Custom web programming
User Management Solutions Perl / PHP / Java / UNIX

Jul 17 '05 #2
Using mod_fastcgi the C app will be much faster.
That may or may not matter to you.
(PHP being interpreted is 10-400 times slower than C
depending on what you are doing.)
However time to maket will likeley be 10 times longer for
the C app. You way the pros and cons.

På Fri, 23 Apr 2004 02:12:43 GMT, skrev <ma******@hotma il.com>:
Hi,

I am trying to figure out if I should learn C and C++ to write CGI
programs, or if I should just use PHP for my web site.

I want to write a high traffic website that would call executibles a
lot dealing with text.

Are CGI programs written in C faster then PHP script programs?

Nick


--
Sender med M2, Operas revolusjonerend e e-postprogram: http://www.opera.com/
Jul 17 '05 #3
"John Thingstad" <jo************ @chello.no> wrote in message
news:op******** ******@news.che llo.no...
Using mod_fastcgi the C app will be much faster.
That may or may not matter to you.
(PHP being interpreted is 10-400 times slower than C
depending on what you are doing.)
However time to maket will likeley be 10 times longer for
the C app. You way the pros and cons.


100 times longer is more like it, as the OP implies that he isn't already an
experienced C/C++ programmer. Text handling is notoriously hard in C/C++,
since there're all sorts of places where memory leaks, corruptions can
occur. Even for a seasoned pro it's a difficult tasks to write something
bullet-proof, let alone a beginner.
Jul 17 '05 #4
On Fri, 23 Apr 2004 19:52:32 -0400, "Chung Leong"
<ch***********@ hotmail.com> wrote:
100 times longer is more like it, as the OP implies that he isn't already an
experienced C/C++ programmer. Text handling is notoriously hard in C/C++,
since there're all sorts of places where memory leaks, corruptions can
occur. Even for a seasoned pro it's a difficult tasks to write something
bullet-proof, let alone a beginner.


"PBCC and CGI"
http://www.powerbasic.com/support/fo...ML/002700.html

:-)

Fred.
Jul 17 '05 #5
ma******@hotmai l.com wrote:
Hi,

I am trying to figure out if I should learn C and C++ to write CGI
programs, or if I should just use PHP for my web site.

I want to write a high traffic website that would call executibles a
lot dealing with text.
CGI of any kind is one of the slowest, worst-performing ways imaginable
to do anything. As another poster mentioned, things like Apache's
mod_fcgi make it easy to adapt a CGI to run inside the server for vastly
improved performance, but there's little reason to set out to write a
C/C++ CGI in the first place these days.

C/C++ compiled into native server modules, not as CGI, can indeed be
extremely fast. But practically nobody writes web applications that way
except maybe Google, and not even them for a lot of the things they do.

Nearly every high (VERY high) volume website is now done in the likes of
PHP, Java, Python, Perl, VB Active Server Pages, and other high-level
languages, and none of them ever as a CGI. Yahoo itself is transitioning
away from its own in-house scripting language to PHP. I think their
mapping site uses Python, and I think their shopping site uses LISP. In
the case of interpreted and runtime compiled langauges like Perl and PHP
there are readily available, free, mainstream server modules (e.g.
mod_perl and PHP accelerators) that compile the scripts transparently
the first time they're run and have them running at speeds comparable to
C from there on out.

The exceptions to the rule, where people opt to write a web app in C
these days, are usually for embedded devices where memory is at a
premium, or for the "connectors " that other programming languages like
PHP use to interface with the webserver.

You are probably not doing anything higher-volume than Yahoo. Write your
application in whatever language you and your team will be most
comfortable with and is best suited to the application. A low-level
language like C is probably not that language.

Are CGI programs written in C faster then PHP script programs?
No. CGIs that have been made thread-safe and then run under a fast-cgi
module can be, sometimes. But you will spend far more time writing it
and you'll have several times the amount of code to maintain.

Nick

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

48
8506
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential problem. The program may crash unexpectedly while writing to the file. If so, my program should detect this during startup, and then (during startup) probably delete the data added to the file and redo the writing operation.
40
4275
by: post400 | last post by:
Hi, there is another famous book 'Writing solid code' but does it apply to Python ? Or it's usable only by Microsoft C programmers ? The author seems to be an ex-Microsoft guy ! Thanks , post400
2
1745
by: James D. Marshall | last post by:
I have a need to write user gathered input to a file as a single line. I not found any tutorials or code examples that would accomplish this. Would this require cgi scripting or vb net script or is JavaScript capable?
385
17293
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like extraneous jargons, such as in the Unix & Perl community. Unlike mathematicians, where in mathematics there are no fewer jargons but each and every one are
17
7685
by: Eric Lindsay | last post by:
Is learning to write CSS a better use of time than finding and using a package that produces complete web pages? I've moved to a new platform (Macintosh), taking with me about 400 personal web pages, some dating back so far I probably wrote them in vi. About 4 years ago (thanks in part to hints found in this group) I converted about 80 pages to CSS, and was fairly happy with the result, plain though they are. Since then I've forgotten...
10
2185
by: Jason Curl | last post by:
Dear C group, I'm very interested in writing portable C, but I only have GNU, Sparc and Cygwin to compile on. What I find is the biggest problem to writing portable C is what headers to include. What sites do people know about that are comprehensive in their differences? For example, MacOSX complained about <string.h>. With Solaris I needed
7
2052
by: Dennis C. Drumm | last post by:
I would like to be able to update an xml file located on my hosted server from my local computer. The server requires a user name and password to access the web site for writing or updating files. Could someone refer me to a doc that explains this or provide some sample code? Thanks,
0
983
by: Allan Ebdrup | last post by:
Why doesn't the Hyperlink Control have a serverside click event? I would like to run some serverside code when a user clicks on a link, do I really have to insert a button and format it as a hyperlink? I'm using ASP.Net 2.0 Kind Regards, Allan Ebdrup
6
11730
by: L. Ximenes | last post by:
Greetings, I've recently been struggling with the idea of writing an XML document based on user-submitted content using javascript. Using various instances of document.write on a newly opened window I succeeded in the task of outputting a perfectly valid XML document, although I have been experiencing a few problems. If I look at the source code of the new window, what I have is a perfect XML document, such that if I copy the source...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.