php vs python

11 views
Skip to first unread message

notbob

unread,
May 21, 2008, 4:10:41 PM5/21/08
to
I'm not posting this just to initiate some religious flame war, though it's
the perfect subject to do so. No, I actaully want some serious advice about
these two languages and since I think usenet is the best arena to find it,
here ya' go.

So, here's my delimna: I want to start a blog. Yeah, who doesn't. Yet, I
want learn the guts of it instead of just booting up some wordwank or
whatever. I started to learn python, but heard php was easier or faster or
more like shell scripting or... fill in the blank. Anyway, so I change over
to learning php. Then I run across that blog, Coding Horror, and start
reading articles like this:

http://www.codinghorror.com/blog/archives/001119.html

Now what? Go back to python. Soldier on with php? What do I know? Not
much. I can setup mysql and apache,, but don't know how to use 'em, really.
I use emacs and run slackware and can fumble my way through bash scripts,
but I can't really write them or do lisp. I've taken basic basic and basic
C, but am barely literate in html. Sometimes it seems overwhelming, but I
persevere because it's more fun/challenging than video games, which bore me
to tears.

Well, that's my actual question, then. Is php really so bad I'm just
wasting my time? Or is it really the quickest way to blog functionality?
Would I be better served in the long run learning python, which claims to be
easy as pie to learn/program (still looks hard to me). I admit I'm no code
geek. But, I'm not completely brain dead, either, and I need something to
keep my geezer brain sparking. What say ye?

nb

Jeffrey Froman

unread,
May 21, 2008, 4:55:40 PM5/21/08
to
notbob wrote:

> I
> persevere because it's more fun/challenging than video games


This is the crux of the matter from where I'm sitting. If the purpose of
learning a programming language is fun, then the primary relevant question
is:

Is it more fun to code in Python or PHP?

The answer is a no-brainer for me. It seems to me that Python is designed
from the ground up with my enjoyment in mind. Your Fun May Vary :-)


Jeffrey

Message has been deleted

Carl Banks

unread,
May 21, 2008, 5:13:15 PM5/21/08
to
On May 21, 4:10 pm, notbob <not...@nothome.com> wrote:
> Sometimes it seems overwhelming, but I
> persevere because it's more fun/challenging than video games, which bore me
> to tears.

Ha, exactly the opposite here.

> Well, that's my actual question, then. Is php really so bad I'm just
> wasting my time? Or is it really the quickest way to blog functionality?
> Would I be better served in the long run learning python, which claims to be
> easy as pie to learn/program (still looks hard to me). I admit I'm no code
> geek. But, I'm not completely brain dead, either, and I need something to
> keep my geezer brain sparking. What say ye?

If you just want to write a simple blog, PHP is probably good enough.
It's undeniably easier to jump into web programming with PHP--
partially because of it's widespread support and straightforward
usage, partially because Python web solutions tend to aim for
separability of content and presenation which raises the bar for
entry--and that could easily outweigh your concerns over quality of
the language.

(Incidentally: if you didn't want to start a religious war, it would
have been better if you had posted it separately to the two groups.
Lots of flamewars start by one person posting a cutdown not intended
for the ears of the other group.)


Carl Banks

Damon Getsman

unread,
May 21, 2008, 5:19:56 PM5/21/08
to
In my opinion, with the previous experience that you have in coding
that you've mentioned, you're probably better off if you minimize the
amount of new syntaxes you'll have to pick up. Standard technique for
what you're trying to accomplish is more often than not Apache with
the PHP and MySQL support built in. PHP has great support for
accessing a MySQL database, which is where the script would store and
load your entries (and/or other applicable data) from. Then again,
you are really learning HTML, PHP, and MySQL at the same time, which
can be a pain in the ass. There are some excellent books by O'Reilly
and Associates on just that subject, though. They combine the PHP &
MySQL into one book that'll get you started and able to handle that
kind of task really quick. The HTML syntax is going to be separate,
wherever you go. It'll be simple if you want it dumping text to the
screen, and a pain in the ass if you want pretty formatting with
designs and text that lays out just in a certain area.

My suggestion, if you want to keep that gray meat sparking, is to go
with only html & php. You could have the php dumping your entries
into date/time named textfiles on there when you're writing, and when
someone is reading, it just orders them sequentially by the date &
time in their filenames.

Then again, you learn the HTML+PHP+MySQL thing and you've got a skill
that you can market on Craigslist to a bunch of people for $20/hr
+. :)

<a href="http://unix.derkeiler.com/Newsgroups/comp.sys.sun.apps/
2008-04/msg00000.html">
-Damon A. Getsman
Linux/Solaris Systems Administrator
</a>

notbob

unread,
May 21, 2008, 5:26:43 PM5/21/08
to
On 2008-05-21, Michael Vilain <vil...@NOspamcop.net> wrote:

> your site. They may even have a blogging package you can administer
> entries without any programming.
>
> What's your end-goal here? If you can't program, you may be better off
> with a package or tool that does all the heavy lifting for you.

I said I didn't want to do that, but that's not entirely true. I figured
I'd use one of the CMSs while learning how it works, much like linux. I
hate doing something without knowing why. Windows and Dreamweaver are good
examples. Nope. I want to get under the hood.

nb

notbob

unread,
May 21, 2008, 5:30:39 PM5/21/08
to
On 2008-05-21, Carl Banks <pavlove...@gmail.com> wrote:

> If you just want to write a simple blog, PHP is probably good enough.
> It's undeniably easier to jump into web programming with PHP--
> partially because of it's widespread support and straightforward
> usage, partially because Python web solutions tend to aim for
> separability of content and presenation which raises the bar for
> entry--and that could easily outweigh your concerns over quality of
> the language.
>
> (Incidentally: if you didn't want to start a religious war, it would
> have been better if you had posted it separately to the two groups.
> Lots of flamewars start by one person posting a cutdown not intended
> for the ears of the other group.)

Yeah, but years of usenet have taught me how to navigate the battlefield.
Your top paragraph above is the kind of advice I'm looking for. Thank you.

nb

notbob

unread,
May 21, 2008, 5:57:00 PM5/21/08
to
On 2008-05-21, Damon Getsman <dget...@amirehab.net> wrote:

> My suggestion, if you want to keep that gray meat sparking, is to go
> with only html & php. You could have the php dumping your entries
> into date/time named textfiles on there when you're writing, and when
> someone is reading, it just orders them sequentially by the date &
> time in their filenames.
>
> Then again, you learn the HTML+PHP+MySQL thing and you've got a skill
> that you can market on Craigslist to a bunch of people for $20/hr
> +. :)

That certainly couldn't hurt. Thank you for your advice.

nb

Paul Rubin

unread,
May 21, 2008, 6:44:39 PM5/21/08
to
notbob <not...@nothome.com> writes:
> Well, that's my actual question, then. Is php really so bad I'm just
> wasting my time? Or is it really the quickest way to blog functionality?

php is very easy to get started with and some big sites have been
written in it. There is lots of low cost php hosting available. It
is not as good a language as Python. However, Python's advantages are
strongest in more complex projects. For simple stuff, php is frankly
less hassle just because of its wide deployment and that extensive
function library that the blog post your quoted described as a bad
thing. Python's libraries are not bad, but php's are more intensely
focused on web apps and includes what you need as part of the standard
build. With Python, if you want a database adapter or web template
framework, you have to choose between a bunch of different ones and
download and configure it which often involves head scratching when
the auto-install stuff hits some quirk of your system. With php, it's
all right there when you flip the switch.

Knowing lots of languages is good for you. php is probably your
quickest route to getting a rudimentary web app running. Python
is a longer term project. Do both.

Baris-C

unread,
May 21, 2008, 9:20:18 PM5/21/08
to

By the way anything goes to you..

Larry Bates

unread,
May 21, 2008, 9:48:44 PM5/21/08
to

Check out the Pylons blog tutorial. You will have a simple blog up and running
in less than 30 minutes and have a platform to extend it with as much
functionality as you want later on.

Larry Bates

Pylons blog tutorial:

http://wiki.pylonshq.com/display/pylonscookbook/Making+a+Pylons+Blog

NC

unread,
May 22, 2008, 1:28:32 AM5/22/08
to
On May 21, 1:10 pm, notbob <not...@nothome.com> wrote:
>
> So, here's my delimna: I want to start a blog. Yeah, who doesn't.
> Yet, I want learn the guts of it instead of just booting up some
> wordwank or whatever.

Here's a simple computation to consider... WordPress' codebase is
approximately a megabyte of PHP code and megabyte of JavaScript code.
Assuming that the average line of that code is 50 characters long, you
are looking at 20,000 lines of code in PHP and as many in JavaScript.
Based on the notion that the average developer out there writes 100
lines a day, either you're in for a two-year project or your product
is going to have seriously reduced functionality compared to something
that's been freely available for years. What's your choice?

> Then I run across that blog, Coding Horror, and start reading
> articles like this:
>
> http://www.codinghorror.com/blog/archives/001119.html

You should read what some computer scientists write about SQL... :)

> Now what?

Nothing. Everyone is entitled to their opinion. You are free to form
your own.

> I've taken basic basic and basic C, but am barely literate
> in html.

Maybe that (and some JavaScript) is something to work on first before
delving into server-side programming?

> Well, that's my actual question, then. Is php really so bad
> I'm just wasting my time? Or is it really the quickest way
> to blog functionality?

The quickest way to blog functionality is an account on a blogging
service... :)

> Would I be better served in the long run learning python, which
> claims to be easy as pie to learn/program (still looks hard to
> me). I admit I'm no code geek. But, I'm not completely brain
> dead, either, and I need something to keep my geezer brain
> sparking. What say ye?

If the purpose is to keep the brain sparking, it doesn't matter what
you learn as long as you're enjoying the process. You might as well
take up Japanese while you're at it...

Cheers,
NC

Nick Craig-Wood

unread,
May 22, 2008, 11:30:07 AM5/22/08
to
Damon Getsman <dget...@amirehab.net> wrote:
> PHP has great support for accessing a MySQL database,

Actually I'd say PHP's mysql support is lacking a very important
feature. mysql_query() doesn't support parameters (or placeholders,
usually '?') which means that unless you use
mysql_real_escape_string() on all user input you are leaving yourself
wide open for SQL injection attacks.

With all the other non-PHP mysql programming I've done you use
parameters for all user input and you don't have to worry.

It is not a big deal, but I've had it drummed into me to always use
parameters for user input and I was really suprised PHP didn't have
them.

--
Nick Craig-Wood <ni...@craig-wood.com> -- http://www.craig-wood.com/nick

notbob

unread,
May 22, 2008, 12:25:41 PM5/22/08
to
On 2008-05-22, Larry Bates <larry...@websafe.com`> wrote:

> Check out the Pylons blog tutorial. You will have a simple blog up and running
> in less than 30 minutes and have a platform to extend it with as much
> functionality as you want later on.
>
> Larry Bates
>
> Pylons blog tutorial:
>
> http://wiki.pylonshq.com/display/pylonscookbook/Making+a+Pylons+Blog

Thnx, Larry. FYI: the above page doesn't exist:

"The page you were trying to reach does not exist. You may want to try a
search, or browse the site to find the page you were looking for."

....but, there's a link to a pylons cookbook, which I will explore.

nb

notbob

unread,
May 22, 2008, 12:29:37 PM5/22/08
to
On 2008-05-21, Paul Rubin <http> wrote:

> Knowing lots of languages is good for you. php is probably your
> quickest route to getting a rudimentary web app running. Python
> is a longer term project. Do both.

Good advice. Thank you.

nb

Rafe Culpin

unread,
May 22, 2008, 12:37:00 PM5/22/08
to
In article <slrng3b38...@irishsea.home.craig-wood.com>, ni...@craig-wood.com
(Nick Craig-Wood) wrote:

> Actually I'd say PHP's mysql support is lacking a very important
> feature. mysql_query() doesn't support parameters (or placeholders,
> usually '?') which means that unless you use
> mysql_real_escape_string() on all user input you are leaving yourself
> wide open for SQL injection attacks.

Use the MySQL Improved Extension - mysqli, not mysql

--
To reply email rafe, at the address cix co uk

Peter H. Coffin

unread,
May 22, 2008, 1:38:59 PM5/22/08
to
On Thu, 22 May 2008 10:30:07 -0500, Nick Craig-Wood wrote:
> Damon Getsman <dget...@amirehab.net> wrote:
>> PHP has great support for accessing a MySQL database,
>
> Actually I'd say PHP's mysql support is lacking a very important
> feature. mysql_query() doesn't support parameters (or placeholders,
> usually '?') which means that unless you use
> mysql_real_escape_string() on all user input you are leaving yourself
> wide open for SQL injection attacks.
>
> With all the other non-PHP mysql programming I've done you use
> parameters for all user input and you don't have to worry.
>
> It is not a big deal, but I've had it drummed into me to always use
> parameters for user input and I was really suprised PHP didn't have
> them.

Buhwha? What's mysqli_prepare() for then?

http://us.php.net/mysqli_prepare

PHP didn't used to have that kind of functionality, but that knowlege is
about three years out of date.

--
For why should my freedom be judged by another's conscience?
-- Paul (I Corinthians 10:29)

Mike Driscoll

unread,
May 22, 2008, 2:34:55 PM5/22/08
to

TurboGears and Django are pretty cool Python web application
frameworks. I would recommend looking at them too.

Mike

inhahe

unread,
May 22, 2008, 6:14:53 PM5/22/08
to
I don't like php. I tried it once and I had it sort a list, but the list
was apparently too long for its sorting function because it just sorted the
first so-many elements of it and left the rest in order, and didn't generate
any error. I like a language that's actually determined by what you tell it
to do. I hear it has a lot of security issues too. I'm not sure that php
*runs* faster than python, having seen benchmarks, but it certainly loads
faster. Maybe not so much of a difference once python25.dll is already in
the cache though (speaking from a windows perspective). because when i load
a program it can take a while but it's pretty quick if i'd just loaded one
recently. but you don't necessarily have to load python for each page
rendering anyway.

I like the Python language a lot better than php. but I just really like
Python.

php mixes html and code out-of-the-box (sort of.. i guess it's more like a
reversal of which one is explicit)... if you use Python you should look into
a 'templating engine' like mako. i use cheetah, but mako is supposed to be
better.

i think Python is the easiest language to learn, with the possible exception
of qbasic (just because making multidimensional arrays in python isnt that
obvious, although maybe it is using numpy, i've never tried it). Python
isn't as easy as basic if you use/have to read the more advanced features,
but those aren't even available in basic. so I find it a comfortable
learning curve.


Jerry Stuckle

unread,
May 22, 2008, 11:09:34 PM5/22/08
to
inhahe wrote:
> I don't like php. I tried it once and I had it sort a list, but the list
> was apparently too long for its sorting function because it just sorted the
> first so-many elements of it and left the rest in order, and didn't generate
> any error. I like a language that's actually determined by what you tell it
> to do.

Then I suspect you had an error in your code. PHP's sort functions work
fine.

> I hear it has a lot of security issues too.

The language has no security issues. Programmers have security issues -
whether it be PHP, Python or any other language.

> I'm not sure that php
> *runs* faster than python, having seen benchmarks, but it certainly loads
> faster. Maybe not so much of a difference once python25.dll is already in
> the cache though (speaking from a windows perspective). because when i load
> a program it can take a while but it's pretty quick if i'd just loaded one
> recently. but you don't necessarily have to load python for each page
> rendering anyway.
>
> I like the Python language a lot better than php. but I just really like
> Python.
>

I like PHP much better than Python. To each their own.

> php mixes html and code out-of-the-box (sort of.. i guess it's more like a
> reversal of which one is explicit)... if you use Python you should look into
> a 'templating engine' like mako. i use cheetah, but mako is supposed to be
> better.
>

PHP can do that. There are also a number of templating engines
available. The nice thing about PHP is you have a choice.

> i think Python is the easiest language to learn, with the possible exception
> of qbasic (just because making multidimensional arrays in python isnt that
> obvious, although maybe it is using numpy, i've never tried it). Python
> isn't as easy as basic if you use/have to read the more advanced features,
> but those aren't even available in basic. so I find it a comfortable
> learning curve.
>
>

I found PHP easier to learn than Python. But that may be because I
already have a strong C/C++ background.

There isn't anything wrong with Python. I just prefer PHP.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

inhahe

unread,
May 23, 2008, 12:40:50 AM5/23/08
to

> PHP can do that. There are also a number of templating engines
> available. The nice thing about PHP is you have a choice.

i just meant that php is sort of invented to combine html and code, so if
you use python instead you should use a templating engine. but i suppose
it's useful for php too.


Michael Fesser

unread,
May 23, 2008, 3:29:42 AM5/23/08
to
.oO(Nick Craig-Wood)

>Damon Getsman <dget...@amirehab.net> wrote:
>> PHP has great support for accessing a MySQL database,
>
>Actually I'd say PHP's mysql support is lacking a very important
>feature. mysql_query() doesn't support parameters (or placeholders,
>usually '?')

Where were you the last couple of years? It's lacking a lot more
features, but that's not the fault of the MySQL extension, which is
quite old. Meanwhile we have the improved MySQL extension and PDO.

>It is not a big deal, but I've had it drummed into me to always use
>parameters for user input and I was really suprised PHP didn't have
>them.

PHP supports them since _years_, you just have to choose the right
database interface.

Micha

Andrew Lee

unread,
May 23, 2008, 5:53:22 AM5/23/08
to

Personally, I believe PHP would get you more productive more quickly for
a blog, but it is a potentially brain damaging language in terms of
really getting your juices flowing with programming. It is not a
general purpose language and suffers from all the limitations of of a
tool designed for one job. If you are interested in programming and the
blog is your path to that, stick with Python! In particular, immerse
yourself in mod_python or look at a framework like Django or Pylons --
the learning curve is steep for any of these technologies but they are a
full meal compared to saltine cracker and water of PHP.

Erwin Moller

unread,
May 23, 2008, 7:37:38 AM5/23/08
to
Andrew Lee schreef:

Some statement Andrew.
Care to clarify that a little?
I don't know much Python (aside from a little in ZOPE), but I did a lot
of Java, Perl, VB/ASP (juck), and a little C before I learned PHP.
I stopped using all in favor of PHP.

If your statement says PHP is abused a lot, yes. Because it is
relatively easy to learn for new programmers, a lot of bad PHP coders
exist.
But I saw them too in Java/Perl/etc.
And I am sure you can find them too coding Python.

It is perfectly possible to write clean good code in PHP.

Why do you say it 'tastes less' then Python?
I don't want to start a religious war, but am curious.
Who knows, maybe I'll dump PHP and start using Python after your
answer. ;-)

Regards,
Erwin Moller

Jerry Stuckle

unread,
May 23, 2008, 7:41:59 AM5/23/08
to

Not at all. With PHP, it's possible to do so, but not required. With
Python, OTOH, you pretty much have to use a templating engine.

Jerry Stuckle

unread,
May 23, 2008, 7:42:39 AM5/23/08
to

And what job is that? I have a lot of batch scripts written in PHP, for
instance.

Michael Fesser

unread,
May 23, 2008, 8:07:12 AM5/23/08
to
.oO(Andrew Lee)

>Personally, I believe PHP would get you more productive more quickly for
>a blog, but it is a potentially brain damaging language in terms of
>really getting your juices flowing with programming. It is not a
>general purpose language

Please elaborate.

>and suffers from all the limitations of of a
>tool designed for one job.

Please elaborate.

And what "one" job are you talking about? There are many things possible
with PHP: web apps, shell scripts, daemons, GUI apps ...

>If you are interested in programming and the
>blog is your path to that, stick with Python!

<flame>Where whitespace is more important than the code.</flame>

Seriously, it's just a question of personal taste and preferences. In
terms of capabilities there's absolutely no difference between PHP and
Python. You need a good understanding of programming in general for
both, the rest is just syntax and the available standard libraries.

>In particular, immerse
>yourself in mod_python or look at a framework like Django or Pylons --
>the learning curve is steep for any of these technologies but they are a
>full meal compared to saltine cracker and water of PHP.

If you don't like PHP, that's perfectly OK. But you should accept that
it's only a tool and just as good as the one who uses it. For me and
many others it's a quite good language, we're able to write clean and
efficient code with it in a rather short time.

PHP is much more than just crackers and water. Of course you should know
how to cook.

Micha

Duncan Booth

unread,
May 23, 2008, 8:18:43 AM5/23/08
to
Erwin Moller
<Since_humans_read_this...@spamyourself.com> wrote:

> Why do you say it 'tastes less' then Python?
> I don't want to start a religious war, but am curious.
> Who knows, maybe I'll dump PHP and start using Python after your
> answer. ;-)

I may not be a good person to answer this since I don't know PHP: I don't
have any religious objection to it, but I just never found it intuitive in
the way I found Python fits my mindset.

On those rare occasions when I've helped someone who wanted advice I've
found that my Python oriented viewpoint can be quite hard to translate to
PHP. For example I'd suggest 'oh you just encode that as utf8' only to be
told that there's no easy way to do that (have just Google'd it looks like
there is now a way to do that but with a big red warning about it being
EXPERIMENTAL and only use at your own risk).

(Looking at the example given for unicode_encode it appears to depend for
its working on a global setting which isn't included in the example. I may
have misunderstood the example but if I read that correctly its a good
example of why PHP doesn't fit my brain.)

Anyway Google should find you plenty of articles comparing the languages.
I'd say you use whichever feels right to you. I would also suggest you
should try Python at least a bit (but since I don't intend to do the same
for PHP you may not count my advice for much).

I found these pretty quickly:

http://python.about.com/od/gettingstarted/ss/whatispython_4.htm
http://wiki.w4py.org/python-vs-php.html


--
Duncan Booth http://kupuguy.blogspot.com

Michael Fesser

unread,
May 23, 2008, 8:29:34 AM5/23/08
to
.oO(Duncan Booth)

>On those rare occasions when I've helped someone who wanted advice I've
>found that my Python oriented viewpoint can be quite hard to translate to
>PHP. For example I'd suggest 'oh you just encode that as utf8' only to be
>told that there's no easy way to do that (have just Google'd it looks like
>there is now a way to do that but with a big red warning about it being
>EXPERIMENTAL and only use at your own risk).
>
>(Looking at the example given for unicode_encode it appears to depend for
>its working on a global setting which isn't included in the example. I may
>have misunderstood the example but if I read that correctly its a good
>example of why PHP doesn't fit my brain.)

The only little problem is that PHP doesn't have native Unicode support
yet, which will change with PHP 6. But of course you can still use UTF-8
without any trouble, I do it all the time. You just have to keep in mind
that many string functions still work on bytes, not on characters, but
this can almost always be solved with the Multibyte extension. Apart
from that there's no problem with PHP and UTF-8. It's also easily
possible to convert between various encodings using the iconv extension.

Micha

Duncan Booth

unread,
May 23, 2008, 10:15:55 AM5/23/08
to
Michael Fesser <net...@gmx.de> wrote:

As I remember it the problem was that the data was stored in a database
in latin-1 but the HTML page had to be in utf-8 (because the rest of the
server and therefore all the page skins were already in utf-8). In
python that would be a trivial conversion but I was told that in PHP it
wasn't.

Also it was PHP4 and as I understand it updating to a more recent
version was non-trivial. Of course sometimes updating Python code to a
newer version is also non-trivial: Zope in particular is very version
specific but in most cases anything written in pure Python will be
compatible with more recent versions.

But one small example isn't really the point. It's that the whole way
Python works seems *to me* to make sense and (mostly) fits together
cleanly and consistently. YMMV

Michael Fesser

unread,
May 23, 2008, 10:59:17 AM5/23/08
to
.oO(Duncan Booth)

>Michael Fesser <net...@gmx.de> wrote:
>
>> The only little problem is that PHP doesn't have native Unicode
>> support yet, which will change with PHP 6. But of course you can still
>> use UTF-8 without any trouble, I do it all the time. You just have to
>> keep in mind that many string functions still work on bytes, not on
>> characters, but this can almost always be solved with the Multibyte
>> extension. Apart from that there's no problem with PHP and UTF-8. It's
>> also easily possible to convert between various encodings using the
>> iconv extension.
>>
>As I remember it the problem was that the data was stored in a database
>in latin-1 but the HTML page had to be in utf-8 (because the rest of the
>server and therefore all the page skins were already in utf-8). In
>python that would be a trivial conversion but I was told that in PHP it
>wasn't.

It would have been trivial in PHP as well, assuming the DB was MySQL,
which could have done this conversion automatically when sending the
data to the script.



>But one small example isn't really the point. It's that the whole way
>Python works seems *to me* to make sense and (mostly) fits together
>cleanly and consistently. YMMV

Fair enough. The nature of PHP as being a grown language has its
advantages, but also a lot of drawbacks, which are hard to solve.

Micha

Arnaud Delobelle

unread,
May 24, 2008, 7:44:43 AM5/24/08
to
Michael Fesser <net...@gmx.de> writes:
> you don't like PHP, that's perfectly OK. But you should accept that
> it's only a tool and just as good as the one who uses it. For me and
> many others it's a quite good language, we're able to write clean and
> efficient code with it in a rather short time.

I'm sure that anyone who is competent enough can write clean code in
any language (in the case of PHP, I am only familiar with one
significant example: I use and have written a few simple extensions
for mediawiki, and I find it quite easy to understand and navigate the
code).

However, while I feel that most languages are quite neutral about
this, I find that Python *encourages* me to write better code. In
other words, Python is not only a tool, it's also a lovely language.

Languages are a bit like shoes. You probably wouldn't want to wear the pair
I'm most comfortable in!

--
Arnaud

Lie

unread,
May 25, 2008, 1:37:01 PM5/25/08
to
On May 22, 12:28 pm, NC <n...@iname.com> wrote:
> On May 21, 1:10 pm, notbob <not...@nothome.com> wrote:
>
>
>
> > So, here's my delimna: I want to start a blog.  Yeah, who doesn't.
> > Yet, I want learn the guts of it instead of just booting up some
> > wordwank or whatever.
>
> Here's a simple computation to consider...  WordPress' codebase is
> approximately a megabyte of PHP code and megabyte of JavaScript code.
> Assuming that the average line of that code is 50 characters long, you
> are looking at 20,000 lines of code in PHP and as many in JavaScript.
> Based on the notion that the average developer out there writes 100
> lines a day, either you're in for a two-year project or your product
> is going to have seriously reduced functionality compared to something
> that's been freely available for years.  What's your choice?

Nope, the core functionality of a blogging software could be
replicated in just a few lines of PHP codes, in the range of tens to
hundreds of lines. If you're creating your own blogging software, you
wouldn't seriously think you'd recreate all those things such as
pingbacks, commenting system, etc, etc, etc. No, you'd start with some
basic core functionalities: a few simple server side includes only.

Lie

unread,
May 25, 2008, 1:49:54 PM5/25/08
to

You should see Basic's file operation syntax, ugly and hackish. All
those #1, #2, etc is ugly and unintuitive. That's why I've always
avoided anything related to file in Basic (no hard feelings to Basic
programmers, my first language is Basic and I'm pretty good at it
except for anything related with files). In python, file read is as
simple as open('path', 'mode'), and the for-loop can easily loop the
file object.

Lie

unread,
May 25, 2008, 2:09:28 PM5/25/08
to
On May 22, 3:10 am, notbob <not...@nothome.com> wrote:
> I'm not posting this just to initiate some religious flame war, though it's
> the perfect subject to do so.  No, I actaully want some serious advice about
> these two languages and since I think usenet is the best arena to find it,
> here ya' go.
>
> So, here's my delimna: I want to start a blog.  Yeah, who doesn't.  Yet, I
> want learn the guts of it instead of just booting up some wordwank or
> whatever.  I started to learn python, but heard php was easier or faster or
> more like shell scripting or... fill in the blank.  Anyway, so I change over
> to learning php.  Then I run across that blog, Coding Horror, and start
> reading articles like this:
>
> http://www.codinghorror.com/blog/archives/001119.html
>
> Now what?  Go back to python.  Soldier on with php?  What do I know?  Not
> much.  I can setup mysql and apache,, but don't know how to use 'em, really.
> I use emacs and run slackware and can fumble my way through bash scripts,
> but I can't really write them or do lisp.  I've taken basic basic and basic
> C, but am barely literate in html.  Sometimes it seems overwhelming, but I
> persevere because it's more fun/challenging than video games, which bore me
> to tears.  
>
> Well, that's my actual question, then.  Is php really so bad I'm just
> wasting my time?  Or is it really the quickest way to blog functionality?
> Would I be better served in the long run learning python, which claims to be
> easy as pie to learn/program (still looks hard to me).  I admit I'm no code
> geek.  But, I'm not completely brain dead, either, and I need something to
> keep my geezer brain sparking.  What say ye?
>
> nb

My advice? Mix a bit of both. PHP's pros is it's tight integration
with HTML, it's really easy to slip small, short PHP snippets here and
there. Server side includes for example, is a short one-liner, in
python it would involve reading the original file, finding where and
what to slip, then reading the include file then concatenates the
files then send it to the requester, or you could setup an engine for
you which might take some time and patience.

On the other hand, python is a general-purpose language, and is a
better designed language. Writing the blog back-end in Python is
probably easier than in PHP while writing the interface-related codes
is probably easier in PHP. You might also consider calling python code
from the PHP.

Jerry Stuckle

unread,
May 25, 2008, 2:15:57 PM5/25/08
to

As he said - it's either a two man-year project or your product is going
to have seriously reduced functionality. It looks like you are opting
for the latter.

Also, you still need to write the server-side includes. But they won't
do nearly enough for everything WordPress does.

Ivan Illarionov

unread,
May 25, 2008, 2:46:32 PM5/25/08
to

If the OP wants to learn the guts of the blog or to implement the blog
from scratch, Python/Django would be a better choice than PHP. The
reason is that he can reuse and customize existing high quality
components for all these auth/auth, admin, comments, etc, etc, etc.
Another reason is that Python and Django encourage very clean design
while PHP is too often ends up in "spaghetti SQL wrapped in spaghetti
PHP wrapped in spaghetti HTML". 2 man/year in PHP == 2 man/week in
Python/Django.

And there are Python/Django blog applications that already do almost
everything (and maybe more) that WordPress does. http://byteflow.su/
is one of them (IMHO the most promising).

Ivan

Jerry Stuckle

unread,
May 25, 2008, 3:07:09 PM5/25/08
to

You can do the same in PHP. And PHP doesn't create spaghetti code -
programmers do. Good programmers write good code in any language. Poor
programmers write lousy code - in any language.

And I'd love to see you write WordPress in 2 weeks in Python. That's
about 2K LOC. Can't be done with the same functionality - unless you
have some 50K lines.

It's going to be very close to the same 2 man years that PHP takes.

> And there are Python/Django blog applications that already do almost
> everything (and maybe more) that WordPress does. http://byteflow.su/
> is one of them (IMHO the most promising).
>
> Ivan
>

And there are many CMS's written in PHP which do much more than
WordPress does. Drupal, Joomla and Mambo come to mind.

NC

unread,
May 25, 2008, 4:28:25 PM5/25/08
to
On May 25, 11:46 am, Ivan Illarionov <ivan.illario...@gmail.com>
wrote:

>
> If the OP wants to learn the guts of the blog or to implement
> the blog from scratch, Python/Django would be a better choice
> than PHP. The reason is that he can reuse and customize existing
> high quality components for all these auth/auth, admin, comments,
> etc, etc, etc.

You are comparing apples to oranges... There are application
frameworks
for PHP as well (CakePHP and Symfony come to mind). CakePHP, if
memory
serves, actually has a development of a blog described in its
tutorial...

> Another reason is that Python and Django encourage very clean design
> while PHP is too often ends up in "spaghetti SQL wrapped in spaghetti
> PHP wrapped in spaghetti HTML".

It's absolutely the same thing with PHP frameworks...

> 2 man/year in PHP == 2 man/week in Python/Django.

This, I daresay, is an exaggeration... Let's take your own example:

> And there are Python/Django blog applications that already do almost

> everything (and maybe more) that WordPress does.http://byteflow.su/


> is one of them (IMHO the most promising).

A quick look at the revision log:

http://byteflow.su/log/

reveals that the initial commit of 60 or so files has been done on
08/14/07
(10 months ago), a second developer came on board 12/01/07 (seven+
months ago),
a third one, on 01/04/08 (six+ months ago), a fourth one, on 01/16/08
(also
six+ months ago). There are at least nine discernible contributors
overall.
Say what you will, but it still looks an awful lot like like two man-
years,
Django or no Django...

Cheers,
NC

Ivan Illarionov

unread,
May 25, 2008, 4:55:07 PM5/25/08
to
On Sun, 25 May 2008 13:28:25 -0700, NC wrote:
[...]

> A quick look at the revision log:
>
> http://byteflow.su/log/
>
> reveals that the initial commit of 60 or so files has been done on
> 08/14/07
> (10 months ago), a second developer came on board 12/01/07 (seven+
> months ago),
> a third one, on 01/04/08 (six+ months ago), a fourth one, on 01/16/08
> (also
> six+ months ago). There are at least nine discernible contributors
> overall.
> Say what you will, but it still looks an awful lot like like two man-
> years,
> Django or no Django...

I bet that if they did this with PHP framework they where far from where
they are now.

I didn't say that it's not possible to write good code in PHP, I said
that Python and Django encourage cleaner code more than PHP and PHP
frameworks do.

IMHO Python language is better designed and this influences everything
written in it.

Yes, it's possible to write something clean in PHP but it would require a
lot more work.

Ivan


Jerry Stuckle

unread,
May 25, 2008, 5:09:43 PM5/25/08
to
Ivan Illarionov wrote:
> On Sun, 25 May 2008 13:28:25 -0700, NC wrote:
> [...]
>> A quick look at the revision log:
>>
>> http://byteflow.su/log/
>>
>> reveals that the initial commit of 60 or so files has been done on
>> 08/14/07
>> (10 months ago), a second developer came on board 12/01/07 (seven+
>> months ago),
>> a third one, on 01/04/08 (six+ months ago), a fourth one, on 01/16/08
>> (also
>> six+ months ago). There are at least nine discernible contributors
>> overall.
>> Say what you will, but it still looks an awful lot like like two man-
>> years,
>> Django or no Django...
>
> I bet that if they did this with PHP framework they where far from where
> they are now.
>

Yep, I'd bet they would be much further along.

> I didn't say that it's not possible to write good code in PHP, I said
> that Python and Django encourage cleaner code more than PHP and PHP
> frameworks do.
>

I repeat. The language has nothing to do with it. Good programmers
write good code. Lousy programmers write bad code.

> IMHO Python language is better designed and this influences everything
> written in it.
>

A lot of people don't share the opinion that it is "better designed".

> Yes, it's possible to write something clean in PHP but it would require a
> lot more work.
>

Not at all. I do it every day.

And BTW - yes, I write Python, also. But I find I can write better,
faster code in PHP.

Do you write PHP?

> Ivan

Ivan Illarionov

unread,
May 25, 2008, 5:30:19 PM5/25/08
to
On Sun, 25 May 2008 17:09:43 -0400, Jerry Stuckle wrote:
> Not at all. I do it every day.
>
> And BTW - yes, I write Python, also. But I find I can write better,
> faster code in PHP.

I find I can write better code in Python. Maybe it's just a matter of
personal preference?

> Do you write PHP?
I did. And I hated it very much. I hated it so much that even I had few
Python scripts that generated PHP for me when it was possible.

NC

unread,
May 25, 2008, 7:23:12 PM5/25/08
to
On May 25, 1:55 pm, Ivan Illarionov <ivan.illario...@gmail.com> wrote:
> On Sun, 25 May 2008 13:28:25 -0700, NC wrote:
>
> > A quick look at the revision log:
>
> > http://byteflow.su/log/
>
> > reveals that the initial commit of 60 or so files has been done
> > on 08/14/07 (10 months ago), a second developer came on board
> > 12/01/07 (seven+ months ago), a third one, on 01/04/08 (six+
> > months ago), a fourth one, on 01/16/08 (also six+ months ago).
> > There are at least nine discernible contributors overall. Say
> > what you will, but it still looks an awful lot like like two
> > man-years, Django or no Django...

>
> I bet that if they did this with PHP framework they where far
> from where they are now.

The question is, which way? :) Jerry Stuckle, with whom I
wholeheartedly argue about half the time we post to the same threads
and argue bitterly the other half of the time, thinks they would be
ahead of where they are now... :)

> I didn't say that it's not possible to write good code in PHP,

Indeed you didn't. You did, however, say that development in Python/
Django is inherently faster than development in PHP (your exact words
were, "2 man/year in PHP == 2 man/week in Python/Django", implying a
50-fold difference). This claim has just been obliterated using the
example you (not I) provided; my estimate of two man-years for
developing WordPress turns out to be fairly close to what has actually
gone into the development of Byteflow. In other words, so far we have
discovered no evidence of Python's (or PHP's, to be fair) superiority
in terms of developer's productivity.

> IMHO Python language is better designed

That is indeed a matter of opinion. You like (among other things)
immutable strings, the off-side rule, the idea that everything is an
object, and the fine distinction between mutable lists and immutable
tuples, and I have no problem with you liking these features, as long
as you agree that other people may have reasons to like the
alternatives better.

> Yes, it's possible to write something clean in PHP but it
> would require a lot more work.

In my opinion, it wouldn't, and in my experience, it doesn't. All you
need is to actually put a designer in charge of design. Additionally,
there are situations (rapid prototyping, for example) when
maintainability (the requirement behind the "clean code") is simply
not a concern.

Cheers,
NC

Ivan Illarionov

unread,
May 25, 2008, 8:07:16 PM5/25/08
to
On Sun, 25 May 2008 16:23:12 -0700, NC wrote:

>> I didn't say that it's not possible to write good code in PHP,
>
> Indeed you didn't. You did, however, say that development in Python/
> Django is inherently faster than development in PHP (your exact words
> were, "2 man/year in PHP == 2 man/week in Python/Django", implying a
> 50-fold difference). This claim has just been obliterated using the
> example you (not I) provided; my estimate of two man-years for
> developing WordPress turns out to be fairly close to what has actually
> gone into the development of Byteflow. In other words, so far we have
> discovered no evidence of Python's (or PHP's, to be fair) superiority in
> terms of developer's productivity.

In this case (excellent blogging tool), yes, I agree.

>> IMHO Python language is better designed
>
> That is indeed a matter of opinion. You like (among other things)
> immutable strings, the off-side rule, the idea that everything is an
> object, and the fine distinction between mutable lists and immutable
> tuples, and I have no problem with you liking these features, as long as
> you agree that other people may have reasons to like the alternatives
> better.

I agree. We like different things and it's good.

>> Yes, it's possible to write something clean in PHP but it would require
>> a lot more work.
>
> In my opinion, it wouldn't, and in my experience, it doesn't. All you
> need is to actually put a designer in charge of design. Additionally,
> there are situations (rapid prototyping, for example) when
> maintainability (the requirement behind the "clean code") is simply not
> a concern.

It's hard to me to write good PHP. I feel happy programming in Python and
I felt very unhappy when I had to program in PHP. I'm glad that you have
a different experience.

Ivan

Jerry Stuckle

unread,
May 25, 2008, 8:12:32 PM5/25/08
to

So you really don't write PHP. Enough said.

Jerry Stuckle

unread,
May 25, 2008, 8:15:40 PM5/25/08
to

It's very easy for me to write good code in PHP. I can say the same for
a number of other good programmers I know.

As I've said before - good programmers can write good code in any language.

Ivan Illarionov

unread,
May 25, 2008, 8:47:00 PM5/25/08
to
Jerry Stuckle wrote:

> As I've said before - good programmers can write good code in any
> language.

Yes, they can. But it may be harder to do for them in one language and
easier in another.

Ivan

Jerry Stuckle

unread,
May 25, 2008, 8:53:28 PM5/25/08
to

Not for a good programmer it isn't. I've known a few good programmers
in my 40+ years of programming. I've known a lot more poor programmers
who think they're good.

Ivan Illarionov

unread,
May 25, 2008, 9:27:12 PM5/25/08
to
On Sun, 25 May 2008 20:53:28 -0400, Jerry Stuckle wrote:

> Ivan Illarionov wrote:
>> Jerry Stuckle wrote:
>>
>>> As I've said before - good programmers can write good code in any
>>> language.
>>
>> Yes, they can. But it may be harder to do for them in one language and
>> easier in another.
>>
>> Ivan
>
> Not for a good programmer it isn't. I've known a few good programmers
> in my 40+ years of programming. I've known a lot more poor programmers
> who think they're good.

I can't argue with your experience. I don't think that I'm good
programmer. I want to be better. And I hope that when I'll have 48+ years
experience I won't have to use it as argumentum ad hominem.

Jerry Stuckle

unread,
May 25, 2008, 9:41:09 PM5/25/08
to

No ad hominems on my part. I said nothing about you or your abilities.
I spoke only of programmers I have known, both good and poor.

The the good programmers are able to adapt to the language and make the
most of whatever language they're using. The result is good code.
OTOH, poor programmers I have known have found all kinds of excuses -
from the language itself to lack of requirements, to anything else they
can blame, except the real root of the problem.

If you take exception to that, then I'm sorry for you.

I V

unread,
May 25, 2008, 10:51:15 PM5/25/08
to
On Sun, 25 May 2008 21:41:09 -0400, Jerry Stuckle wrote:
> The the good programmers are able to adapt to the language and make the
> most of whatever language they're using. The result is good code. OTOH,
> poor programmers I have known have found all kinds of excuses - from the
> language itself to lack of requirements, to anything else they can
> blame, except the real root of the problem.

That's true - but I wonder if there might not be differences at the
margins. Some languages (and, which is not quite the same but not easy to
fully distinguish either, the communities around some languages) may
encourage mediocre programmers to produce slightly more or less mediocre
programs.

Some features of Python (the one that really stands out for me is not
default-initializing variables on first use; the comparatively clean
standard library might be another), and some features of the Python
community (which, IME, has more members more explicitly committed to
writing clean code) I think do make Python a better environment for us
mediocre programmers.

But maybe I'm wrong - I've never been paid to write Python programs,
whereas I have been paid to write PHP, so I might just be projecting my
frustrations with work onto the language. I've also not used PHP5 much in
anger, which does look to be a lot nicer than earlier versions.

Michael Fesser

unread,
May 26, 2008, 6:30:45 AM5/26/08
to
.oO(Ivan Illarionov)

>On Sun, 25 May 2008 17:09:43 -0400, Jerry Stuckle wrote:
>> Not at all. I do it every day.
>>
>> And BTW - yes, I write Python, also. But I find I can write better,
>> faster code in PHP.
>
>I find I can write better code in Python. Maybe it's just a matter of
>personal preference?

Exactly.

>> Do you write PHP?
>I did. And I hated it very much.

See, for me it's the other way round. I really hate Python syntax.
I only touch it for scripting Paint Shop Pro or if some third-party
Python script lacks proper documentation and I have to wade through
the sources to find the informations I need.

So where does this leave us? Nowhere. A language is just a tool and a
tool is just as good as the one who uses it. This was said often enough.

If you hate PHP, that's OK, but it doesn't make PHP a bad or even
inferior language.

Micha

Diez B. Roggisch

unread,
May 26, 2008, 8:25:16 AM5/26/08
to
> If you hate PHP, that's OK, but it doesn't make PHP a bad or even
> inferior language.

No. That is PHP on it's own that makes it an inferior language. It is suited
(and surprisingly well) for the task of creating webapps. But the language
core? Plain ugly. Examples include (in arbitrary order and not complete)

- bolted-on Object-system
- lack of binary extension API
- ONE collection type to rule them all!!
- stateful collection iteration (come *on*, calling reset on an array!)
- no namespaces (according to
http://www.php.net/manual/en/language.namespaces.php they are planned -
good)
- copy-by-value semantics with a crude reference-mechanism to mitigate that
- inconsistent APIs all over (DB-connectivity for example). Yes, I know
about PEAR::DB. But somebody "designed" the real DB apis. Or actually
didn't. Which
- no concept of higher order functions - you pass around function-*names*.
Which of course works because of one flat namespace. Wonder how it will
work if NS get real

Oh, and one of my real favorits: NO SUB-EXPRESSIONS. You can't write

$foo = $array1[$key1][$key2][$key3]

I'm wondering how to write a language that *doesn't* allow for that...

And before you ask: yes, I've written PHP, more than enough and larger
systems in it with a few K-loc. I even encountered weird bugs (PHP 4.0.x,
has been a while) that made PHP forget function definitions! You could
re-load a page if a function was missing, and it magically appeared. and
you could *fix* this turning off some warn/log-level. Again - I don't even
*know* how to program something like a language that behaves that way. And
it certainly puts the language into the worst light imaginable. buggy
libraries and extensions? No deal, can happen. But core features like
that - should work.

having said all this - I see the benefits of PHP. It is easy to start for
non-programmers, you can get it for virtually no cost at all for
web-development tasks, you don't need to bother with stuff you have to deal
in python web-frameworks like setting up mod_wsgi, mod_python or mod_proxy.

But it is a hack. Don't pretend otherwise.

Diez

Jerry Stuckle

unread,
May 26, 2008, 9:04:36 AM5/26/08
to
Diez B. Roggisch wrote:
>> If you hate PHP, that's OK, but it doesn't make PHP a bad or even
>> inferior language.
>
> No. That is PHP on it's own that makes it an inferior language. It is suited
> (and surprisingly well) for the task of creating webapps. But the language
> core? Plain ugly. Examples include (in arbitrary order and not complete)
>

That is completely your opinion. I happen to have a similar opinion of
Python.

> - bolted-on Object-system

Integrated into the language.

> - lack of binary extension API

One of the things I hate about Python - it creates non-portable code.

> - ONE collection type to rule them all!!

Wrong. I have several collection classes.

> - stateful collection iteration (come *on*, calling reset on an array!)

Which does exactly what it says it does. Arrays can have states also
(i.e. the current position in the array). Nice shortcut.

> - no namespaces (according to
> http://www.php.net/manual/en/language.namespaces.php they are planned -
> good)

A minor inconvenience, only.

> - copy-by-value semantics with a crude reference-mechanism to mitigate that

References have been available in PHP for several versions. It gives
you the option of copy by value or reference. Python doesn't - which is
a real PITA.

> - inconsistent APIs all over (DB-connectivity for example). Yes, I know
> about PEAR::DB. But somebody "designed" the real DB apis. Or actually
> didn't. Which

The DB apis were based on the apis for the original databases - MySQL,
PostGresSQL, etc. And PEAR:DB does a fine job.

> - no concept of higher order functions - you pass around function-*names*.
> Which of course works because of one flat namespace. Wonder how it will
> work if NS get real
>

What's wrong with passing around function names? It is an interpreted
language, after all.

> Oh, and one of my real favorits: NO SUB-EXPRESSIONS. You can't write
>
> $foo = $array1[$key1][$key2][$key3]
>

Bullshit. You've been able to do that since the first releases of PHP.

> I'm wondering how to write a language that *doesn't* allow for that...
>
> And before you ask: yes, I've written PHP, more than enough and larger
> systems in it with a few K-loc. I even encountered weird bugs (PHP 4.0.x,
> has been a while) that made PHP forget function definitions! You could
> re-load a page if a function was missing, and it magically appeared. and
> you could *fix* this turning off some warn/log-level. Again - I don't even
> *know* how to program something like a language that behaves that way. And
> it certainly puts the language into the worst light imaginable. buggy
> libraries and extensions? No deal, can happen. But core features like
> that - should work.
>

It's obvious you have not written any serious PHP, if you don't even
know how to access multi-dimensional arrays. And I've never seen the
errors you have. What did you do in your code to create them?

> having said all this - I see the benefits of PHP. It is easy to start for
> non-programmers, you can get it for virtually no cost at all for
> web-development tasks, you don't need to bother with stuff you have to deal
> in python web-frameworks like setting up mod_wsgi, mod_python or mod_proxy.
>
> But it is a hack. Don't pretend otherwise.
>
> Diez

No, it's a great language.

But the think I hate about Python are the "holier-than-thou" programmers
who think Python is the greatest thing since sliced bread. Let me clue
you - it isn't. It's just a language. But I do admit - it makes it
easier for half-assed programmers to write code that works.

Michael Fesser

unread,
May 26, 2008, 12:05:03 PM5/26/08
to
.oO(Diez B. Roggisch)

>> If you hate PHP, that's OK, but it doesn't make PHP a bad or even
>> inferior language.
>
>No. That is PHP on it's own that makes it an inferior language. It is suited
>(and surprisingly well) for the task of creating webapps. But the language
>core? Plain ugly. Examples include (in arbitrary order and not complete)
>
> - bolted-on Object-system

Remember where PHP came from. Hint: It was not a drawing board. But the
OOP support in PHP 5 is quite good and works very well even in big
applications.

> - lack of binary extension API

You can write binary extensions.

> - ONE collection type to rule them all!!

Doesn't hurt and can be changed with your own classes.

> - stateful collection iteration (come *on*, calling reset on an array!)

You don't have to reset arrays, there are various iteration methods
available which do that automatically. On the other hand this internal
pointer allows very efficient subsequent access to the array items if
you should need that. So it's a feature, not a bug.

> - no namespaces (according to
>http://www.php.net/manual/en/language.namespaces.php they are planned -
>good)

The typical troll argument. Yes, namespaces have their use, but they're
no killer feature that separates the good languages from the bad ones.

> - copy-by-value semantics with a crude reference-mechanism to mitigate that

RTFM about PHP references and copy-on-write.

> - inconsistent APIs all over (DB-connectivity for example).

man PDO

> - no concept of higher order functions - you pass around function-*names*.
>Which of course works because of one flat namespace. Wonder how it will
>work if NS get real

And where's the problem with that? PHP is not a functional language. But
if you need it, you can use Lambda functions and variable function names
to emulate some aspects of your "higher order functions".

>Oh, and one of my real favorits: NO SUB-EXPRESSIONS. You can't write
>
>$foo = $array1[$key1][$key2][$key3]

$foo = $array1[1 == 1][$bar][rand(1, 42)];

Where's your problem?

>I'm wondering how to write a language that *doesn't* allow for that...
>
>And before you ask: yes, I've written PHP, more than enough and larger
>systems in it with a few K-loc. I even encountered weird bugs (PHP 4.0.x,
>has been a while) that made PHP forget function definitions! You could
>re-load a page if a function was missing, and it magically appeared.

I doubt that this was a PHP bug. In such a complex system like a web
server there are many things that may cause such problems.

>and
>you could *fix* this turning off some warn/log-level.

Too strange to be true. Anyway, PHP 4 is dead.

>Again - I don't even
>*know* how to program something like a language that behaves that way.

Obviously you just don't know how to use PHP properly.

>And
>it certainly puts the language into the worst light imaginable. buggy
>libraries and extensions? No deal, can happen. But core features like
>that - should work.

Over the years I only encountered one bug that really annoyed me, the
rest simply worked well as described and intended. Reliable and stable.

>having said all this - I see the benefits of PHP.

No, you don't. You're just a trolling Python fanboy. Almost none of your
arguments holds true.

>It is easy to start for
>non-programmers, you can get it for virtually no cost at all for
>web-development tasks, you don't need to bother with stuff you have to deal
>in python web-frameworks like setting up mod_wsgi, mod_python or mod_proxy.
>
>But it is a hack. Don't pretend otherwise.

You have no clue.

Micha

Curtis

unread,
May 26, 2008, 7:28:01 PM5/26/08
to
Paul Rubin wrote:

> notbob <not...@nothome.com> writes:
>> Well, that's my actual question, then. Is php really so bad I'm just
>> wasting my time? Or is it really the quickest way to blog functionality?
>
> php is very easy to get started with and some big sites have been
> written in it. There is lots of low cost php hosting available. It
> is not as good a language as Python. However, Python's advantages are
> strongest in more complex projects. For simple stuff, php is frankly
> less hassle just because of its wide deployment and that extensive
> function library that the blog post your quoted described as a bad
> thing. Python's libraries are not bad, but php's are more intensely
> focused on web apps and includes what you need as part of the standard
> build. With Python, if you want a database adapter or web template
> framework, you have to choose between a bunch of different ones and
> download and configure it which often involves head scratching when
> the auto-install stuff hits some quirk of your system. With php, it's
> all right there when you flip the switch.
>
> Knowing lots of languages is good for you. php is probably your
> quickest route to getting a rudimentary web app running. Python
> is a longer term project. Do both.

PHP is more than capable for handling large projects, not just small
scripting jobs. However, Paul's right about PHP being more driven
toward web development, where as Python may be better for different
types of apps.

Even then, I think your first reply was best, it just comes down to
what you have more fun writing. Both languages are equally capable of
getting the job done.

--
Curtis

Jerry Stuckle

unread,
May 26, 2008, 7:42:20 PM5/26/08
to

Not true. PHP is quite capable of writing large, non-web based
projects. While it's non-browser based display capabilities are
somewhat lacking (although there are third party libraries which help a
lot), I've written some pretty complicated batch scripts in the past.

Curtis

unread,
May 26, 2008, 8:05:44 PM5/26/08
to
I V wrote:
> On Sun, 25 May 2008 21:41:09 -0400, Jerry Stuckle wrote:
>> The the good programmers are able to adapt to the language and make the
>> most of whatever language they're using. The result is good code. OTOH,
>> poor programmers I have known have found all kinds of excuses - from the
>> language itself to lack of requirements, to anything else they can
>> blame, except the real root of the problem.
>
> That's true - but I wonder if there might not be differences at the
> margins. Some languages (and, which is not quite the same but not easy to
> fully distinguish either, the communities around some languages) may
> encourage mediocre programmers to produce slightly more or less mediocre
> programs.
>
> Some features of Python (the one that really stands out for me is not
> default-initializing variables on first use; the comparatively clean
> standard library might be another), and some features of the Python
> community (which, IME, has more members more explicitly committed to
> writing clean code) I think do make Python a better environment for us
> mediocre programmers.

If you set PHP to show notices, it will tell you of such cases.
However, the way I learned good programming practice was talking with
other programmers, and trying different languages. I think if you have
a real desire to write good code, and work at it, you can accomplish
your task, regardless of the language.

However, there is definitely a prevalent amount of poorly written PHP
on the Web, so it can be easy for a newcomer to pick up some bad
practices. This isn't a fault of the design of the language, though.

> But maybe I'm wrong - I've never been paid to write Python programs,
> whereas I have been paid to write PHP, so I might just be projecting my
> frustrations with work onto the language. I've also not used PHP5 much in
> anger, which does look to be a lot nicer than earlier versions.

Yeah, PHP5 is awesome, and PHP4 is dead/dying.

--
Curtis

Curtis

unread,
May 26, 2008, 8:49:45 PM5/26/08
to

Yeah, I see I may have spoken too soon. When I think about it, the PHP
extensions available do cover a lot of ground. I've played around with
php-gtk in the past, but nothing major.

To clarify: what I meant to say is that php is especially well suited
for web development, I didn't mean that it wasn't capable of doing
non-web based development.

--
Curtis

NC

unread,
May 27, 2008, 1:39:51 AM5/27/08
to
On May 26, 5:25 am, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
>
> That is PHP on it's own that makes it an inferior language. It is
> suited (and surprisingly well) for the task of creating webapps.
> But the language core? Plain ugly.

Exactly. Ugliness (just like beauty) is in the eye of the beholder.
What is ugly to you might as well be beautiful to me... :)

> Examples include (in arbitrary order and not complete)
>
> - bolted-on Object-system

Which is beautiful, since you can get by quite nicely without using it
at all. :) In PHP, there is no assumption that everything is an
object. If anything, there's an implicit assumption that anything
scalar can be rendered as a string. So you actually have a choice
between procedural and object-oriented programming.

> - lack of binary extension API

This is where I have to agree with you. Python's ability to integrate
with arbitrary native DLLs is very impressive indeed.

> - ONE collection type to rule them all!!

Which, again, is beautiful, because you don't have to worry about
(im)mutability and can use one base type to imitate both C arrays and
C structures. Speaking of collections, what's the reasoning, if any,
behind the list/tuple dichotomy in Python? I am genuinely interested;
could you please enlighten me?

> - stateful collection iteration (come *on*, calling reset on an array!)

Aesthetics... You don't like stateful collection iteration, I don't
like immutable strings...

> - no namespaces

Theoretically, a problem. Practically, a rather easily solvable
one...

> - inconsistent APIs all over (DB-connectivity for example). Yes, I know
> about PEAR::DB. But somebody "designed" the real DB apis.

Er, the DB developers did... PHP's DB extensions are simple wraps of
native APIs. And there is a good case to be made for keeping it that
way; DB engines are not functionally identical, so abstracting them on
the language level is not necessarily a good idea, especially if you
want to develop a high-performance application...

> Oh, and one of my real favorits: NO SUB-EXPRESSIONS. You can't write
>
> $foo = $array1[$key1][$key2][$key3]

But of course you can!!! :)

> And before you ask: yes, I've written PHP

Given the above statement on $foo = $array1[$key1][$key2][$key3],
allow me to have my doubts...

> But it is a hack. Don't pretend otherwise.

But OF COURSE it's a hack!!! And it's a beautiful hack in that it
does what it purports to do. :)

Cheers,
NC

Peter H. Coffin

unread,
May 27, 2008, 11:22:44 AM5/27/08
to
On Mon, 26 May 2008 14:25:16 +0200, Diez B. Roggisch wrote:
>> If you hate PHP, that's OK, but it doesn't make PHP a bad or even
>> inferior language.
>
> No. That is PHP on it's own that makes it an inferior language. It is suited
> (and surprisingly well) for the task of creating webapps. But the language
> core? Plain ugly. Examples include (in arbitrary order and not complete)
>
> - bolted-on Object-system
> - lack of binary extension API
> - ONE collection type to rule them all!!
> - stateful collection iteration (come *on*, calling reset on an array!)
> - no namespaces (according to
> http://www.php.net/manual/en/language.namespaces.php they are planned -
> good)
> - copy-by-value semantics with a crude reference-mechanism to mitigate that
> - inconsistent APIs all over (DB-connectivity for example). Yes, I know
> about PEAR::DB. But somebody "designed" the real DB apis. Or actually
> didn't. Which
> - no concept of higher order functions - you pass around function-*names*.
> Which of course works because of one flat namespace. Wonder how it will
> work if NS get real
>
> Oh, and one of my real favorits: NO SUB-EXPRESSIONS. You can't write
>
> $foo = $array1[$key1][$key2][$key3]
>
> I'm wondering how to write a language that *doesn't* allow for that...

What? You mean this doesn't work?

$ cat foo.php
<?php

for ( $key1 = 1; $key1 <= 4; $key1++ ) {
for ( $key2 = 1; $key2 <= 4; $key2++ ) {
for ( $key3 = 1; $key3 <= 4; $key3++ ) {
$array1[$key1][$key2][$key3] = $key1 + $key2 + $key3;
}
}
}


$key1 = 3;
$key2 = 3;
$key3 = 3;

$foo = $array1[$key1][$key2][$key3]; //Magic phrase
echo "[$key1][$key2][$key3] : $foo\n";

?>
$ php foo.php
[3][3][3] : 9
$

Gee...

> And before you ask: yes, I've written PHP, more than enough and larger
> systems in it with a few K-loc. I even encountered weird bugs (PHP 4.0.x,
> has been a while) that made PHP forget function definitions! You could
> re-load a page if a function was missing, and it magically appeared. and
> you could *fix* this turning off some warn/log-level. Again - I don't even
> *know* how to program something like a language that behaves that way. And
> it certainly puts the language into the worst light imaginable. buggy
> libraries and extensions? No deal, can happen. But core features like
> that - should work.
>
> having said all this - I see the benefits of PHP. It is easy to start for
> non-programmers, you can get it for virtually no cost at all for
> web-development tasks, you don't need to bother with stuff you have to deal
> in python web-frameworks like setting up mod_wsgi, mod_python or mod_proxy.
>
> But it is a hack. Don't pretend otherwise.

The way you describe the problem you're encountering sounds an awful lot
like someone that really doesn't know how to program at all. You give
examples of things as not working that do, in fact, work fine, and you
attempt to fix things by turning off warnings and loggings instead of
figuring out what the behavior actually is, and checking whether it
works as documented.

--
63. Bulk trash will be disposed of in incinerators, not compactors. And they
will be kept hot, with none of that nonsense about flames going through
accessible tunnels at predictable intervals.
--Peter Anspach's list of things to do as an Evil Overlord

AnrDaemon

unread,
May 27, 2008, 9:10:20 PM5/27/08
to
Greetings, Ivan Illarionov.
In reply to Your message dated Monday, May 26, 2008, 04:47:00,

>> As I've said before - good programmers can write good code in any
>> language.

> Yes, they can. But it may be harder to do for them in one language and
> easier in another.

It's obvious lie. If you have clear mind and you know language you're using,
there are absolutely NOTHING can deny you to write clear code.
Even using forth postfix notation, I have no problem writing good code, it's
as easy as writing bad code. And yes, I do see the difference.


--
Sincerely Yours, AnrDaemon <anrd...@freemail.ru>

Ivan Illarionov

unread,
May 27, 2008, 9:32:24 PM5/27/08
to

No. Language does matter.

Ivan Illarionov

unread,
May 27, 2008, 9:42:50 PM5/27/08