[OPINION] - does language really matter if they all do the same thing?

Cliff Wells clifford.wells at comcast.net
Sat Jan 24 23:40:04 CET 2004


On Fri, 2004-01-23 at 10:31, Python Baby wrote:
> Are programming languages like spoken languages, in the sense
> that they all say the same things, just using different words?

As others have said, languages all constrain how you think in one way or
another, even "natural" languages.  Programming languages are even
worse, since even "general purpose" programming languages are designed
to fit a certain criteria that makes them more expressive in one way and
less in another.

> Can Ruby do something (important) that Python can't?
> Can Python do something (important) that PHP can't?
> Can PHP do something (important) that Ruby or Python can't?

It's interesting that you mention this as I'm a long-time Python
programmer who just got his first taste of PHP (required for a job).  If
it's a simple matter of choosing between Python and PHP, the things that
have struck me so far are as follows:

1. PHP is a much "noisier" language than Python.  Braces, semicolons,
variable declarations, $ notation on variables, arrays declared as if
they are a function (array()) rather than direct language syntax, etc. 
This is mostly cosmetic and doesn't detract from the usefulness of the
language, and for a language targeted at the web, there is a definite
advantage to using braces as block-delimiters, if not the other "noise".

2.  PHP and Python are both very dynamic, although they do it in
somewhat different ways.  As an example, in Python, to get a reference
(pointer) to a function, you'd just refer to the function without
parentheses.  In PHP you'd probably use a string with the function name
and call it.  I prefer Python's method of string interpolation over
PHP's.  This sounds like a minor nit, but if you're dynamically
generating text, then you get this minor nit a lot.  PHP's method isn't
bad if the strings are inline, but if you are reading text from one file
and substituting values into it from another, Python's method is much
simpler.

3.  PHP's object-model appears remarkably similar to Python's on the
surface.  This similarity is only skin-deep, however. It is openly
acknowledged that OO won't fully be supported until PHP5 is released,
but it's possible to use it in 4 (as I have been).  As such, I'm
reluctant to criticize it too much as it really isn't bad, but it
appears incomplete (and some features are outright broken at the
moment).  Not to mention it's pretty damn slow.  Hopefully this will be
taken care of in PHP5. 

Most of the problems I've had with PHP have not been with the language
itself (which really doesn't seem that bad), but rather with the
implementation (i.e. the interpreter).  Poor error reporting, bugs,
general slowness, immature libraries, etc.  Obviously PHP has some
strengths in the web arena (ability to arbitrarily intermix PHP and HTML
being the most noticable, although getting carried away with this seems
like a bad idea).

> Are they all just the same, and it's just a matter of taste?

It depends.  If you're comparing PHP and Python, then the answer is
"yes, to a great extent".  If you're comparing Python and a language
like C, then the answer is a definite no.  You might be able to get
similar results, but how you get there will be completely different.

> Should I stick with PHP for the same reason that pop singers
> worldwide sing in English for maximum compatibility with the medium?

Only you can decide that.  Try Python and see if it "fits your brain" as
many here like to describe it.  Just be sure to give it a fair shake as
any new tool is bound to be occasionally frustrating (as has been the
case for me with PHP).

> Though PHP wasn't design for OOP should I use it that way anyway?

If you aren't familiar with OOP, then no.  There are far too many bugs
and problems with the current OO implementation in PHP.  You'll pull
your hair out trying to get things that *should* work to do as you
expect.  If you're familiar with OOP and think you can work around PHP's
shortcomings in this area, then sure.  I'm fairly happy with the results
I've gotten, although it took twice as long as it would have taken were
I to have done it in Python (at least some of this is due to my being
new to PHP, but more of it was due to the lack of adequate error
reporting and obscure bugs and misfeatures).


Regards,
Cliff


-- 
I have seen too much, wipe away my eyes
                              -Bauhaus





More information about the Python-list mailing list