[newbie] Equivalent to PHP?

Octavian Rasnita orasnita at gmail.com
Tue Jun 12 07:28:22 EDT 2012


From: "Chris Angelico" <rosuav at gmail.com>
Subject: Re: [newbie] Equivalent to PHP?


> On Tue, Jun 12, 2012 at 7:39 PM, Gilles <nospam at nospam.com> wrote:
>> Since web scripts are usually very short anyway (user sends query,
>> server handles request, sends response, and closes the port) because
>> the user is waiting and browsers usually give up after 30 seconds
>> anyway... why did Python solutions go for long-running processes while
>> PHP was built from the start as short-running processes?


Perl, Ruby, Python and PHP also can do the same thing.

You can use a persistent program which is loaded/parsed/compiled once and kept into memory and it will just answer the requests, or you can create a program which is loaded/parsed/compiled on each request.

The first way is much better for performance reasons but it consumes much more memory and it is more complicated, because the programs can have memory leaks (they will consume more and more memory after a long period), while the second way is more simple to do, but the performance is not great.

Most PHP programs are done using the second way, because it is much simple to do and it is much simple to configure the environment for it, and most of the free web hosting sites that offer PHP support don't offer something better.
And... most of the sites don't need a very good performance, because they usually don't have millions visitors per day.

Also, most of the sites made in PHP use low level programs using only what the default PHP distribution installed on the server offers, so no web frameworks, or form managers, or templating systems or many other modules that can do a part of the work.
The PHP distribution has compiled C programs which run pretty fast, while loading/parsing/compiling a lot of other modules made in Ruby/Perl/Python/PHP would decrease the performance, so a persistent environment is usually required in case those modules are used. And usually Python and Perl and Ruby programs use a lot of modules because for these languages there are a lot of modules available that can do a lot of things for free, while for PHP there are much fewer, and even if there are, (because there are templating systems and web frameworks for PHP also), they are much seldomly used, because those who choose to use a broken language like PHP, usually choose it not only for its main advantage regarding the easiness of deployment, but choose it because it is much more simple and easy to learn, and they usually don't like to learn a lot of other modules.
Otherwise... if you want you can also create a web app using PHP and CodeIgniter web framework and run it with fastcgi...

Octavian




More information about the Python-list mailing list