Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

php vs python

瀏覽次數:5 次
跳到第一則未讀訊息

notbob

未讀,
2008年5月21日 下午4:10:412008/5/21
收件者:
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

未讀,
2008年5月21日 下午4:55:402008/5/21
收件者:
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

訊息已遭刪除

Carl Banks

未讀,
2008年5月21日 下午5:13:152008/5/21
收件者:
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

未讀,
2008年5月21日 下午5:19:562008/5/21
收件者:
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

未讀,
2008年5月21日 下午5:26:432008/5/21
收件者:
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

未讀,
2008年5月21日 下午5:30:392008/5/21
收件者:
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

未讀,
2008年5月21日 下午5:57:002008/5/21
收件者:
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

未讀,
2008年5月21日 下午6:44:392008/5/21
收件者:
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

未讀,
2008年5月21日 晚上9:20:182008/5/21
收件者:

By the way anything goes to you..

alex23

未讀,
2008年5月21日 晚上9:47:282008/5/21
收件者:
On May 22, 6:10 am, notbob <not...@nothome.com> wrote:
> 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?

Python has 71 built in functions (in 2.5). Atwood's list of PHP built
ins beginning with 'a' is 124 functions long.

There's a clear reason why people say Python "fits your brain" :)

Larry Bates

未讀,
2008年5月21日 晚上9:48:442008/5/21
收件者:

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

未讀,
2008年5月22日 凌晨1:28:322008/5/22
收件者:
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

未讀,
2008年5月22日 上午11:30:072008/5/22
收件者:
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

未讀,
2008年5月22日 中午12:25:412008/5/22
收件者:
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

未讀,
2008年5月22日 中午12:29:372008/5/22
收件者:
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

Mike Driscoll

未讀,
2008年5月22日 下午2:34:552008/5/22
收件者:

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

Mike

inhahe

未讀,
2008年5月22日 下午6:14:532008/5/22
收件者:
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

未讀,
2008年5月22日 晚上11:09:342008/5/22
收件者:
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

未讀,
2008年5月23日 凌晨12:40:502008/5/23
收件者:

> 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

未讀,
2008年5月23日 凌晨3:29:422008/5/23
收件者:
.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

未讀,
2008年5月23日 清晨5:53:222008/5/23
收件者:

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

未讀,
2008年5月23日 清晨7:37:382008/5/23
收件者:
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

未讀,
2008年5月23日 清晨7:41:592008/5/23
收件者:

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

未讀,
2008年5月23日 清晨7:42:392008/5/23
收件者:

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

Michael Fesser

未讀,
2008年5月23日 上午8:07:122008/5/23
收件者:
.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

未讀,
2008年5月23日 上午8:18:432008/5/23
收件者:
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

未讀,
2008年5月23日 上午8:29:342008/5/23
收件者:
.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

未讀,
2008年5月23日 上午10:15:552008/5/23
收件者:
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

未讀,
2008年5月23日 上午10:59:172008/5/23
收件者:
.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

未讀,
2008年5月24日 清晨7:44:432008/5/24
收件者:
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

未讀,
2008年5月25日 下午1:37:012008/5/25
收件者:
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

未讀,
2008年5月25日 下午1:49:542008/5/25
收件者:

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

未讀,
2008年5月25日 下午2:09:282008/5/25
收件者:
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

未讀,
2008年5月25日 下午2:15:572008/5/25
收件者:

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

未讀,
2008年5月25日 下午2:46:322008/5/25
收件者:

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

未讀,
2008年5月25日 下午3:07:092008/5/25
收件者:

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

未讀,
2008年5月25日 下午4:28:252008/5/25
收件者:
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

未讀,
2008年5月25日 下午4:55:072008/5/25
收件者:
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

未讀,
2008年5月25日 下午5:09:432008/5/25
收件者:
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

未讀,
2008年5月25日 下午5:30:192008/5/25
收件者:
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

未讀,
2008年5月25日 晚上7:23:122008/5/25
收件者:
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

未讀,
2008年5月25日 晚上8:07:162008/5/25
收件者:
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

未讀,
2008年5月25日 晚上8:12:322008/5/25
收件者:

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

Jerry Stuckle

未讀,
2008年5月25日 晚上8:15:402008/5/25
收件者:

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

未讀,
2008年5月25日 晚上8:47:002008/5/25
收件者:
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

未讀,
2008年5月25日 晚上8:53:282008/5/25
收件者:

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

未讀,
2008年5月25日 晚上9:27:122008/5/25
收件者:
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

未讀,
2008年5月25日 晚上9:41:092008/5/25
收件者:

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

未讀,
2008年5月25日 晚上10:51:152008/5/25
收件者:
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.

Max M

未讀,
2008年5月26日 凌晨4:11:222008/5/26
收件者:pytho...@python.org
Jerry Stuckle skrev:
> Ivan Illarionov wrote:

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

That is simply not true!

The languag has a lot to do with what you can do in any given time.

You can write good code in a bad language. But it will take lot more
time. And so it will not be done.

Your argument, if it was true, would mean that I could just as well
write a blog in c or even assembler, and still write optimal code.


php is a terrible language and I cringe whenever I have to use it. In
fact I have turned down many jobs because they were written in php. It
is simply to frustrating.


--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science

Ivan Illarionov

未讀,
2008年5月26日 凌晨4:47:332008/5/26
收件者:

I want to cite Paul Graham on this topic:

"it's all based on one unspoken assumption, and that assumption turns out
to be false. The pointy-haired boss believes that all programming
languages are pretty much equivalent. If that were true, he would be
right on target. If languages are all equivalent, sure, use whatever
language everyone else is using.

But all languages are not equivalent, and I think I can prove this to you
without even getting into the differences between them. If you asked the
pointy-haired boss in 1992 what language software should be written in,
he would have answered with as little hesitation as he does today.
Software should be written in C++. But if languages are all equivalent,
why should the pointy-haired boss's opinion ever change? In fact, why
should the developers of Java have even bothered to create a new language?

Presumably, if you create a new language, it's because you think it's
better in some way than what people already had. And in fact, Gosling
makes it clear in the first Java white paper that Java was designed to
fix some problems with C++. So there you have it: languages are not all
equivalent. If you follow the trail through the pointy-haired boss's
brain to Java and then back through Java's history to its origins, you
end up holding an idea that contradicts the assumption you started with.

So, who's right? James Gosling, or the pointy-haired boss? Not
surprisingly, Gosling is right. Some languages are better, for certain
problems, than others. And you know, that raises some interesting
questions. Java was designed to be better, for certain problems, than C+
+. What problems? When is Java better and when is C++? Are there
situations where other languages are better than either of them?"
and so on at
http://www.paulgraham.com/icad.html

I tend to share PG's opinions on the subject (though I think that Python
is superior to Lisp :-).

The argument that "the language has nothing to do with it" is an old
pointy-haired boss argument. I doubt that a person who think this way can
be a really good programmer.

Ivan

Michael Fesser

未讀,
2008年5月26日 清晨6:30:452008/5/26
收件者:
.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

未讀,
2008年5月26日 上午8:25:162008/5/26
收件者:
> 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

Curtis

未讀,
2008年5月26日 晚上7:28:012008/5/26
收件者:
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

未讀,
2008年5月26日 晚上7:42:202008/5/26
收件者:

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

未讀,
2008年5月26日 晚上8:05:442008/5/26
收件者:
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

未讀,
2008年5月26日 晚上8:49:452008/5/26
收件者:

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

AnrDaemon

未讀,
2008年5月27日 晚上9:10:202008/5/27
收件者:
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

未讀,
2008年5月27日 晚上9:32:242008/5/27
收件者:

No. Language does matter.

Ivan Illarionov

未讀,
2008年5月27日 晚上9:42:502008/5/27
收件者:

I want to add
TROLL WARNING:
this message is cross-posted between comp.lang.python and comp.lang.php
Let's stop.

Jerry Stuckle

未讀,
2008年5月27日 晚上9:47:552008/5/27
收件者:

Not for a good programmer. Only for half-assed ones.

Ivan Illarionov

未讀,
2008年5月27日 晚上10:06:002008/5/27
收件者:
On Tue, 27 May 2008 21:47:55 -0400, Jerry Stuckle wrote:

> Ivan Illarionov wrote:
>> On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote:
>>
>>> 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.
>>
>> No. Language does matter.
>
> Not for a good programmer. Only for half-assed ones.

No. Language does matter

Jerry Stuckle

未讀,
2008年5月27日 晚上10:27:402008/5/27
收件者:

Only to half-assed programmers. Good programmers can write good code in
any language they know.

Ever seen good assembler? It can be done - really! Also fortran,
cobol, forth... the list goes on.

Ivan Illarionov

未讀,
2008年5月27日 晚上10:45:442008/5/27
收件者:
On Tue, 27 May 2008 22:27:40 -0400, Jerry Stuckle wrote:

> Ivan Illarionov wrote:
>> On Tue, 27 May 2008 21:47:55 -0400, Jerry Stuckle wrote:
>>
>>> Ivan Illarionov wrote:
>>>> On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote:
>>>>
>>>>> 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.
>>>> No. Language does matter.
>>> Not for a good programmer. Only for half-assed ones.
>>
>> No. Language does matter
>
> Only to half-assed programmers. Good programmers can write good code in
> any language they know.
>
> Ever seen good assembler? It can be done - really! Also fortran,
> cobol, forth... the list goes on.

Yeah,
mov eax, Jerry
mov killfile, eax

Jerry Stuckle

未讀,
2008年5月27日 晚上10:49:422008/5/27
收件者:

Stoopid troll. But we already know you can't write good code. No
surprise there.

Tim Roberts

未讀,
2008年5月28日 凌晨2:04:542008/5/28
收件者:
Ivan Illarionov <ivan.il...@gmail.com> wrote:
>On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote:
>> 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.
>...
>No. Language does matter.

A good programmer keeps many tools in his toolbox, and understands which
tools provide the best service for the problem at hand.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Michael Fesser

未讀,
2008年5月28日 清晨7:42:152008/5/28
收件者:
.oO(Ivan Illarionov)

>No. Language does matter.

And the weather.

If you know how to program, you can write good code in any language if
you're familiar enough with it. Many people write good code in PHP, and
many write total crap in C/C++. It's almost never about the language,
but about the programmer.

Micha

cokof...@gmail.com

未讀,
2008年5月28日 上午10:32:072008/5/28
收件者:

I'd like to see someone coming from an OO programming background write
good Haskell, Pure Functional Programming code even with a high level
of OO experience. Language matters.

Ivan Illarionov

未讀,
2008年5月28日 上午10:49:262008/5/28
收件者:
On Wed, 28 May 2008 06:04:54 +0000, Tim Roberts wrote:

> Ivan Illarionov <ivan.il...@gmail.com> wrote:
>>On Wed, 28 May 2008 05:10:20 +0400, AnrDaemon wrote:
>>> 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.
>>...
>>No. Language does matter.
>
> A good programmer keeps many tools in his toolbox, and understands which
> tools provide the best service for the problem at hand.

Agree, I keep Python, C and x86 assembly in my toolbox. And this toolbox
is perfect.

Actually, even PHP has its place in my toolbox, but, *only when I can't
use Python*, eg Sourceforge.net servers don't have good Python support
and PHP starts to make sense.

Language matters.

Ivan

Jerry Stuckle

未讀,
2008年5月28日 中午12:58:232008/5/28
收件者:

Actually, I think it would be easier than a functional programmer
converting to an OO paradigm.

And the caveat was *if you're familiar enough with it*.

A good OO programmer could easily write good functional code.

Paul Rubin

未讀,
2008年5月28日 下午3:51:222008/5/28
收件者:
Jerry Stuckle <jstu...@attglobal.net> writes:
> A good OO programmer could easily write good functional code.

Over on #haskell there's a general belief that learning Haskell is
easier for nonprogrammers than it is for OO programmers, since the OO
programmers first have to unlearn what they previously knew.

Eric Wertman

未讀,
2008年5月28日 下午5:00:442008/5/28
收件者:pytho...@python.org
Flaming Thunder is teh awesome! :P

Diez B. Roggisch

未讀,
2008年5月29日 清晨6:03:002008/5/29
收件者:
> A good OO programmer could easily write good functional code.

You are aware that functional programming is *not* procedural or imperative
programming?

http://en.wikipedia.org/wiki/Functional_programming

OO is *heavily* depending on state and state modification. I've seen OO
programmers weep over functional programming assignments. Which is not to
say that FP is in any sense bad - au contraire, knowing it is important
because it is a different school of thought that's very valuable to know
of. And Python allows for many of the FP concepts to be used. See map,
filter and other HOFs.

Diez

Ethan Furman

未讀,
2008年5月30日 下午4:46:522008/5/30
收件者:Jerry Stuckle、pytho...@python.org
Jerry Stuckle wrote:

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

So... an eloquent speaker of English is also an eloquent speaker of
Spanish/French/German?

I think your statement would be correct if worded: some programmers can
write good code in any language. There's a reason why computer coding
paradigms are called 'languages' -- because they are, and as such they
require different ways of thinking. Just because someone is good at
playing pianos doesn't mean they are also good at wood carving. Just
because someone is good (i.e. writes good code) in C / PHP / Python /
Perl / Assembly / whatever does not inherently mean that that same
person will be able to write good code in any other language. That's
one reason why there are so many to choose from: different people think
differently and most are only optimal in certain areas.

Or perhaps your definition of a good programmer means somebody who can
write good code in any language? What then is a programmer who can only
write good code in a handful of languages? Or maybe only two languages?
Or even only one?

My definition of a good programmer is someone who can write good code in
a computer language. I would use the word 'versatile' or even
'multi-lingual' to broaden the scope to more than one language.
--
Ethan

P.S.
My apologies, Jerry, for writing back to you directly -- I haven't yet
discovered how to post to newsgroups, and I do not know the php mailing
list address. I guess by both our definitions I am not a 'good
newsgroup poster.' ;-)

Joel Koltner

未讀,
2008年6月1日 晚上7:42:242008/6/1
收件者:
"Ethan Furman" <et...@stoneleaf.us> wrote in message
news:mailman.1782.1212179...@python.org...

> Jerry Stuckle wrote:
> > As I've said before - good programmers can write good code in any
> > language.
> So... an eloquent speaker of English is also an eloquent speaker of
> Spanish/French/German?

There's potentially a large difference between a "good" speaker of
English/German/etc. vs. "eloquent."

I'd tend to agree with Jerry that if you can write "good" code in one
language, you can in pretty much any other as well... but that doesn't imply
you're necessarily "eloquent" in any languages. :-) Eloquence is nice, but
eradicating "bad" code in this world is about a million times more important
than attempting to move people from "good" code to "eloquent" code.

To be Pythonic here, "eloquent" code would perhaps often have clear, clean
list comprehensions used when "good" code would use a "for" loop but still be
easy to follow as well and perfectly acceptable in the vast majority of cases.

Arnaud Delobelle

未讀,
2008年6月2日 凌晨12:36:022008/6/2
收件者:
"Joel Koltner" <zapwireD...@yahoo.com> writes:

> There's potentially a large difference between a "good" speaker of
> English/German/etc. vs. "eloquent."
>
> I'd tend to agree with Jerry that if you can write "good" code in
> one language, you can in pretty much any other as well... but that
> doesn't imply you're necessarily "eloquent" in any languages. :-)
> Eloquence is nice, but eradicating "bad" code in this world is about
> a million times more important than attempting to move people from
> "good" code to "eloquent" code.

This is wrong, because if you know well one language only, you tend to
think that the principles that underpin it are universal. So you will
try to shoehorn these principles into any other language you use.

It's only when you have become reasonably proficient in a number of
conceptually different languages that you start to build a picture of
what "a programming language" is.

I understand that there are some sane practices that are useful to
know when programming in any language, but it is wrong to say that the
skill of programming can be reduced to that, the rest being syntax.
There is (hopefully!) a design behind the syntax, you have to
understand it to use the language well.

You may be great at building Turing machines. That doesn't make you a
master of crafting lambda-expressions.

> To be Pythonic here, "eloquent" code would perhaps often have clear,
> clean list comprehensions used when "good" code would use a "for"
> loop but still be easy to follow as well and perfectly acceptable in
> the vast majority of cases.

I find that eloquent Python speakers often tend to write a for loop
when mere good ones will try to stick a list comprehension in!

Regards

--
Arnaud

Duncan Booth

未讀,
2008年6月2日 凌晨3:50:222008/6/2
收件者:
Arnaud Delobelle <arn...@googlemail.com> wrote:

> I find that eloquent Python speakers often tend to write a for loop
> when mere good ones will try to stick a list comprehension in!
>

+1 QOTW

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

Lou Pecora

未讀,
2008年6月2日 上午11:05:432008/6/2
收件者:
In article <mailman.1782.1212179...@python.org>,
Ethan Furman <et...@stoneleaf.us> wrote:

> Jerry Stuckle wrote:
>
> >
> > As I've said before - good programmers can write good code in any
> > language.
> >
>
> So... an eloquent speaker of English is also an eloquent speaker of
> Spanish/French/German?

Oh, Bull. Computer languages are so narrow they are more like dialects
of a single language. If you know English you can learn to speak to a
Brit, Scot, or Aussie. That's more like it...if you really want to
stretch the definition of a language. And it is a stretch. Anyone
speak C?

Sheeze.

--
-- Lou Pecora

Joel Koltner

未讀,
2008年6月2日 晚上9:21:262008/6/2
收件者:
"Arnaud Delobelle" <arn...@googlemail.com> wrote in message
news:m2y75oa...@googlemail.com...

> This is wrong, because if you know well one language only, you tend to
> think that the principles that underpin it are universal. So you will
> try to shoehorn these principles into any other language you use.

Fair point, although I guess I was assuming the language you were good in was
something that covers, say, 90% of contemporary programming practices, e.g.,
something like C++ : If you're truly good at C++ (and percentage-wise of all
programmers, relatively few are), there are not many things that I'm aware of
that are tremendously different in any other programming language. Function
decorators from Java and some of the function programming stuff from Lisp,
perhaps, but those are pretty small additions (well within the "10%").

Perhaps I should reduce my claim to those good at programming in any "first
class" language like C++ are generally going to write at least above-average
code in any other language. :-)

> You may be great at building Turing machines. That doesn't make you a
> master of crafting lambda-expressions.

Certainly the most important thing for any programmer to know is where his
skills lie and where he should purposely keep things "braindead simple"
because he's more likely to introduce bugs by trying to be "eloquent."

> I find that eloquent Python speakers often tend to write a for loop
> when mere good ones will try to stick a list comprehension in!

This is the trap I refer to above -- beginning programmers are far more likely
to mis-use more sophisticated language features than experienced programmers
are. Heck, you see entire languages like Java built around such premises,
that it's better to have a simpler language that's harder to mis-use than a
more sophisticated one that could be readily abused. C++ is perhaps the
ultimate "anything goes" langauge -- tons of power and sophistication, very
little nannying. Python has its own philosophy, of course, although at times
it's somewhat arbitrary, e.g., for "explicit is better than implicit" -- sure,
fine, but "of course" only applied to things that we haven't already decided
"should be" implicit! Something like Python iterators are not at all
explicit/obvious, for instance, to someone coming from, say, a Visual BASIC
background... although I suppose they're still a lot simpler than, e.g., C++
scoping rules for name resolution.

---Joel


Marc 'BlackJack' Rintsch

未讀,
2008年6月3日 凌晨1:05:552008/6/3
收件者:
On Mon, 02 Jun 2008 18:21:26 -0700, Joel Koltner wrote:

> "Arnaud Delobelle" <arn...@googlemail.com> wrote in message
> news:m2y75oa...@googlemail.com...
>> This is wrong, because if you know well one language only, you tend to
>> think that the principles that underpin it are universal. So you will
>> try to shoehorn these principles into any other language you use.
>
> Fair point, although I guess I was assuming the language you were good in was
> something that covers, say, 90% of contemporary programming practices, e.g.,
> something like C++ : If you're truly good at C++ (and percentage-wise of all
> programmers, relatively few are), there are not many things that I'm aware of
> that are tremendously different in any other programming language. Function
> decorators from Java and some of the function programming stuff from Lisp,
> perhaps, but those are pretty small additions (well within the "10%").

I think you are talking about something a little different than Arnaud.
You are talking about the 10% that's new in another language that has to
be learned additionally and Arnaud is talking about the stuff the
programmer already knows about the old language that somewhat works in the
new one but is all but optimal and thus has to be *unlearned*. From C++
to Python or Java this is RAII and deterministic destructors for instance.
Other old habits from people coming to Python are: using indexes where they
are not needed, trivial getters and setters, putting *everything* into
classes and every class into a module, and so on.

Another difference are internal versus external iterators. In Python you
write the loop outside the iterable and pull the items out of it. In
other languages (Ruby, Io, …) iterables do internal iteration and you give
them a function where all item are "pushed" into one at a time.

> Perhaps I should reduce my claim to those good at programming in any "first
> class" language like C++ are generally going to write at least above-average
> code in any other language. :-)

What makes C++ a "first class" language? And did you quote "first class"
for the same reason than I did? ;-)

Ciao,
Marc 'BlackJack' Rintsch

Joel Koltner

未讀,
2008年6月4日 下午4:20:162008/6/4
收件者:
"Marc 'BlackJack' Rintsch" <bj_...@gmx.net> wrote in message
news:6ak1pjF...@mid.uni-berlin.de...

> I think you are talking about something a little different than Arnaud.

Ah, OK.

> Other old habits from people coming to Python are: using indexes where they
> are not needed, trivial getters and setters, putting *everything* into
> classes and every class into a module, and so on.

Some of that is more political/policy than anything having to do with the
language. Python likes to make it blatantly obvious that a lot of it is
unnecessary, so it puts the "control freak" type of programmers on the
defensive when, e.g., class variables and methods aren't private by default.
(Guido's "we're all conesenting adults here" is of course a good response to
this!)

> Another difference are internal versus external iterators. In Python you
> write the loop outside the iterable and pull the items out of it. In

> other languages (Ruby, Io, .) iterables do internal iteration and you give


> them a function where all item are "pushed" into one at a time.

The Python method is -- IMO -- rather more powerful here, even if the whole
protocol is somewhat less explciti than the Ruby/Io/etc. approach.

> What makes C++ a "first class" language?

My somewhat arbitrary definition is something along the lines of a language
with most all of the "contemporary" features expected of languages (e.g., "old
school" procedural languages like C/Pascal/Fortran 77 don't count) that are
targeting at writing everything from small utilities to programs of various
sizes to full-blown operating systems.

> And did you quote "first class"
> for the same reason than I did? ;-)

Probably... C++ is kinda like the McMaster-Carr catalog, whereas Python is a
well-stocked hardware store with knowledgable salespeople.

---Joel


0 則新訊息