>> I've coded in PHP, and I've coded in Python.  I'd choose
>> Python over PHP any day.  As a matter of fact, I don't touch
>> PHP any more unless I'm paid to (or maintaining some of my
>> old personal PHP code).
> 
> May I ask why this disdain for PHP? OOP type puritanism aside,
> it's a language in which one *can* code elegantly and then
> it's highly maintainable. And it's pretty well supported and
> documented around the web.

I'll enumerate a few frustrations I find with PHP:

-flat namespace vs. hierarchical namespace

-it's harder to read (extra brackets, dollar-signs, C-style 
looping constructs, etc.).  I *can* read PHP, it just takes less 
effort for me to read Python

-you have to work diligently to separate parts (models, logic, 
and presentation...this is a Django/framework specific thing, as 
Python CGI makes it easy to write hard-to-maintain 
tightly-coupled code)  As you note, you *can* code elegantly in 
PHP, but I find it takes far more conscious effort on my part 
than the same sort of development in PHP.  Django encourages 
clean separation.

-small language quirks (what order do the needle/haystack 
parameters come in various PHP searching functions?  It depends 
on which function...)

-the shift from PHP4 to PHP5 has somewhat fractured the community 
(package X requires PHP4 and doesn't run well on PHP5 while 
package Y requires PHP5 but doesn't run well on PHP4; writing for 
both requires some careful work; and PHP4's object syntax is, 
well, objectionable :).  Python 2.2 -> 2.3 -> 2.4 -> 2.5 has been 
a smooth transition.  Python3k may revoke this benefit, but 2.6 
should still stay backwards compat. with previous versions of Python.

-the Python shell and/or pdb.  A great debugging tool.  Yes, PHP 
can be used from the console, but it's primarily a web-language 
and not nearly as friendly for multi-purpose scripting.  Combined 
with Python's built-in dir() and help() functions, I need to hit 
the official Python docs far less frequently than I hit the PHP 
documentation site.

-I have a personal aversion to the various equality tests in PHP. 
  But that's not a make-or-break issue for many folks.  Passing 
by reference (and returning object references) involves some odd 
mental overhead for me as well (especially with the shift from 
PHP4->PHP5, and remembering which one uses which syntax)

-Python's introspection capabilities offer a lot of benefits I 
have difficulty giving up when I go back to PHP.

-Python's properties (getters/setters that behave code-wise like 
attributes, but actually contain programmatic behavior) allow me 
to use attributes, and then easily convert to programmatic 
getter/setter logic without editing my code.

-Python offers built-in unit-testing libraries

I do give PHP one major benefit:  every low-end cheap hosting 
service offers it.  This makes deployment to these services one 
of just getting a cheap hosting package (can be had for 
$1USD/month) and copying your files.  I love that, and wish there 
was a commonly accepted standard for doing the same with Python. 
  WSGI is contending for this role, but it's still not 
universally available on every hosting service like PHP.  There 
are still the occasional headache regarding PHP deployment (does 
the server have register-globals enabled, and other such 
settings), tweaking .htconfig files and mod_rewrite to get pretty 
URLs, etc. but all said, PHP has a far better deployment 
experience on cheap hosting.

PHP also has a minor benefit of baked-in support for a wider 
variety of databases.  Stock MySQL and PostgreSQL bindings are 
something I miss in stock Python (they're just a download away, 
but it's still one more thing to have to do)

I'm not sure I'd describe coding in PHP as "disdain", but more 
like taking out the trash, changing diapers, or washing 
dishes...a chore.  I find writing in Python to be a pleasure.

Just my $0.02 on the matter, since you asked ;)

-tim






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to