PHP vs. Python/comp.lang.php?

Suchandra Thapa ssthapa at classes.cs.uchicago.edu
Fri Nov 23 10:05:19 EST 2001


Max M <maxm at normik.dk> wrote:
>I think you will find that the general concensus is that Python is a
>"complete" language. Which PHP is not. Python can be used for both web
>scripting and, shell scripting, application development, small tools and gui
>apps. And is very good at all of them. Wheras PHP is only useable for
>scripting web pages.

	PHP has a command line interpeter so it can be used for scripting
and the like.  I believe there is even a gtk library so it's conceivable to
create a gui app in php.  However using php for something other than web
scripting is very rare.

>Furthermore PHP kind of forces you to write web-apps in one way with
>presentation and logic mixed. Also when your web-apps can do all the
>standard fare that is the staple of PHP you will suddenly need some feature
>that's not available in PHP. Then it is  much easier to use the Python
>standard library to roll your own solution.

	Actually, there are template based packages for php, and it isn't
too difficult to create a new template handling class if you don't like the 
existing ones.  To be fairly, a standard python cgi will also force you
to mix presentation and logic since all your html will be in print or 
stdout.write statements inside your script.
	However, PHP has some fairly large flaws in comparision to python.
For example, using a variable that has never been declared or initialized will
silently be treated as using an empty string (e.g. if you make a typo while
entering a variable's name, you won't get an error).  PHP also has some issues
with case sensitvity.  Variable names are case sensitive while function names 
are not.  In addition, function calls are handled poorly.  If you call a 
function with 3 parameters when it was declared with less than 3 parameters,
php will silently ignore the extra parameter.  
	All of these things basically make php code a lot harder to debug and 
maintain then python code.  I would prefer python if given a choice.

-- 
----------------------------------------------------------------------------
	   		              |
Suchandra Thapa                       | "There are only two kinds of math . 
s-thapa-11 at NOSPAMalumni.uchicago.edu  | books. Those you cannot read beyond 
			              | the first sentence, and those you 
			              | can not read beyond the first page."
			              |                     -C.N. Yang
----------------------------------------------------------------------------



More information about the Python-list mailing list