navwin » Tech Talk » Geek Stuff » Why PHP?
Geek Stuff
Post A Reply Post New Topic Why PHP? Go to Previous / Newer Topic Back to Topic List Go to Next / Older Topic
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296
Purgatorial Incarceration

0 posted 2005-01-19 04:43 PM


Been browsing through some PHP/MySQL books at random as I visit Borders and am wondering why PHP over PERL? (I recall you mentioning somewhere, Ron, that you were either in the process of or considering a change to PHP).

Pros?
Cons?

Is it a separate language? Based on existing languages?


© Copyright 2005 C.G. Ward - All Rights Reserved
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669
Michigan, US
1 posted 2005-01-19 10:32 PM


When you want to output HTML in a Perl script, you embed the content within the script and then print it as needed. PHP stands for Pre-HTML-Processor and was written by a Perl programmer (in Perl, initially) because he wanted a script language that could be embedded directly in standard web pages. He essentially flipped the flop.

The similarities between Perl and PHP are numerous, both in terms of capability and syntax, which is hardly surprising considering its roots. Not siblings, I would think, but certainly first cousins. I personally think PHP is a little clunky and long-winded, but it's not bad, and hey, most people think Perl is much too terse.

I don't think there are any cons to switching to PHP any more (availability of software compared to Perl was a con at one time, but certainly no longer), and really, none of the pros are issues that couldn't be resolved in favor of Perl. For example, database manipulation is built right into the PHP language and pretty easy to use. It's not built into Perl, but the addition of some good libraries can rectify that. It does, however, obviously require more effort and thought to find those good libraries.

The biggest issue today, I think, is implementation.

By default, Perl runs as a stand-alone processor. Every time a visitor calls a script, Apache shells out to the operating system and runs a new process, with all the attendant memory and overhead that involves. PHP, on the other hand, can be (and usually is) compiled as part of the Apache kernel. There are some alternatives, like mod_perl and FastCGI, that allow one to embed Perl into Apache in a similar manner, but they're not as well supported as PHP and, most importantly, most Perl scripts have to be modified to work under them.

There are some tradeoffs, as always, but essentially today's implementation eliminates a ton of overhead and makes PHP almost ten times faster than native Perl.

Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296
Purgatorial Incarceration
2 posted 2005-01-20 12:15 PM


Similiar to JavaScript then, though it sounds like the background server support is the main driver as opposed to client-side support?

Ineresting. I take it it's still a scripting language that doesn't need to be compiled prior to initiation?

Thanks, Ron.

Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669
Michigan, US
3 posted 2005-01-20 03:20 PM


quote:
Ineresting. I take it it's still a scripting language that doesn't need to be compiled prior to initiation?

Correct, which remains a weakness.

An interpreted language goes through several steps prior to execution, and Zend Optimizer can help eliminate some of that for PHP. Essentially, the product tokenizes the script, caches the encoded results, and then runs that instead of the source code version. The claim about 40 percent increase in speed.

Post A Reply Post New Topic ⇧ top of page ⇧ Go to Previous / Newer Topic Back to Topic List Go to Next / Older Topic
All times are ET (US). All dates are in Year-Month-Day format.
navwin » Tech Talk » Geek Stuff » Why PHP?

Passions in Poetry | pipTalk Home Page | Main Poetry Forums | 100 Best Poems

How to Join | Member's Area / Help | Private Library | Search | Contact Us | Login
Discussion | Tech Talk | Archives | Sanctuary