[PerlChina] Zend已经不允许免费下载Zend Optimizer™

Yonghua (Jeff) yonghua.peng at gmail.com
Sat May 27 07:13:03 PDT 2006


正好beginners-lists上也在讨论Perl与PHP这个话题,我把它转一下。

>
> What are the differences between Perl and PHP?

The differences are far too many to list here.  However, I'll list a
few:

  Perl tends to run slightly faster.  Your site's visitors probably
  won't notice any lag, though.

  PHP has a more anemic syntax.  For instance, variable types are not
  really differentiated in syntax at all, which can lead to some ugly
  hacks every now and then.  On the other hand, a simpler syntax can
  make it easier to do some simple things.

  PHP has more core functions (about ten times as many, give or take).
  This is part of the reason it's slower than Perl, in fact.  This can
  make the language more accessible to beginners, since "programming"
  with PHP often involves nothing more than looking up the function you
  need to do your job.  On the other hand, while there are an ungodly
  number of functions for doing the same tasks in very slightly
  different ways in some cases, in others the functions needed to do
  some very common and simple things are strangely absent, which can be
  frustrating.

  The ability to embed PHP directly in code and have the server parse it
  is more commonly available on cheap webhosts than the ability to do
  the same with Perl, though SSI does make up some of the difference.
  Since SSI is even more anemic than PHP, and doesn't really have "core
  functions", this can lead to some juggling to handle insertion of Perl
  output into the page that isn't necessary with PHP -- but if you need
  more than SSI to do it, you probably need to do it in the Perl scripts
  anyway for the sake of good programming practice.

  PHP tends to suffer more security issues than Perl.  I'm pretty sure
  the function-heavy design of the language contributes to that, but I
  don't know for sure.  Good, security-conscious programming techniques
  should allow you to work around such security issues without too much
  trouble, however, so unless you know of specific issues that are not
  acceptable to you, this probably shouldn't make your decision for you.

  There are more beginner-level quick-start scripts out there in PHP
  that are easily modified in trivial ways than there are in Perl, from
  what I've seen.

  PHP has the potential to teach you a lot of bad habits as a programmer
  if it's the first language you learn -- but it also has the potential
  to be a very easy introduction to programming, perhaps easier than
  Perl if you're going to use either only for web programming to begin
  with.

  Perl has some of the most informative programming communities filled
  with some of the most knowledgeable programmers you're likely to find
  on the Internet.  I speak of people on this list such as Tom Phoenix
  and Randal Schwartz, and of a pretty big percentage of the population
  at perlmonks.org (I'm constantly surprised by the density of
  programming wisdom there).

  Maybe I'm looking in the wrong places, but I just haven't seen as much
  quality of PHP books as Perl books.

  Perl is far more fun.  Okay, so I'm biased.

  Perl regular expressions are much much MUCH better than PHP regular
  expressions.  Seriously, working with PHP regular expressions is a bit
  like trying to sort M&Ms with staples in my fingertips.  It's not fun.

  Despite my bias, I end up using PHP more for web development than PHP.
  This is in large part because for the very simplest tasks, it's just
  easier.  I could probably just use SSI and no PHP to do the very
  simple stuff that leads me to use PHP more often than Perl, but
  somehow SSI never occurs to me except when working with Perl.

  Perl is useful for a lot more than PHP, generally.  If you want to
  learn a language that will prove useful outside of web development,
  you're probably better of with Perl.  On the other hand, learning both
  eventually might be a good idea too.

Is this list too long yet?  I could go on forever.


>
> Which one is the best to build up a website?

That depends on what you're going to do with the website.  Some website
development is more easily accomplished in PHP, some in Perl.  Sometimes
factors other than ease of development come into play, too.  There's no
simple answer to that question as you asked it.  Regardless of which you
decide to use, though, you're going to need to know some XHTML, and
should know some CSS too.  Perhaps you should start there, if you don't
already know these things.  There's a reasonably good reference website
on those topics and more at http://www.w3schools.com that you can use to
get up to speed.  I occasionally refer to it myself, though I know XHTML
and CSS better than almost anyone I know.


>
> There are more and more PHP-based websites. Except the fact that ISP
> provide most of the time PHP/MySQL web hosting, why do people prefer
> using PHP instead of Perl?

It's really really easy to get started writing code in PHP and deploying
it on a web server.  Of course, this is also probably why there's more
really awful PHP in use on simple websites than really awful Perl: the
barrier to entry is lower, which means greater accessibility to people
who don't really know what they're doing.  Don't let that stop you,
though.  We all have to start somewhere.


>
> I would like to create one only using Perl. Consequently, what are the
> most used modules for this purpose?

Woah, nellie.  There's no way to give a meaningful answer to this,
really.  I guess you might say CGI is the most-used module for web
programming, and that may even be accurate, but it probably won't help
you much unless it just happens to be the right answer for you by some
kind of coincidence.  It's typically better to come up with a site
architecture and a plan for how you're going to implement it, then start
looking for modules to fulfill your needs, rather than to get a list of
commonly used modules and look for ways to develop your site using them.

As much as it pains me to say it, I think you might be best served to
start out with PHP, and come back to Perl when you have a bit more of a
grasp of what you're doing with web programming.  I've personally found
that it seems to work better to start learning Perl for reasons other
than web programming and to come back to web programming once some more
general understanding of Perl is gleaned.  I ended up learning PHP
mostly to cover the web programming side of things while using Perl for
simple system administration tasks and so on, until I got to a point
where I knew Perl well enough to be able to apply it intelligently to
web development.  Some of this, I'm sure, has to do with the fact that
the really good resources for Perl tend to be focused on tasks more
related to systems administration and glue code, while web development
resources for Perl are often written by people trying to make a fast
buck who aren't necessarily experts.  PHP resources aren't any better,
but as I pointed out before it's easier to get started with PHP for web
development if you're coming to it from knowing nothing at all.

Of course, if I wasn't simultaneously learning Perl while learning PHP
for web development, I'm pretty sure my PHP skills would have
consistently sucked all along, too.  Learning Perl taught me good habits
that I've been able to apply to PHP.  When learning PHP, I recommend you
also learn another language pretty much at the same time, for some other
purpose than web programming -- a language with a rich syntax and a very
good community with very good free resources like PerlMonks.  It'll make
you a better PHP programmer.  Perl is particularly suited to this, since
before PHP was its own programming language, it was just a toolkit for
web development built using Perl.

That's my take on it.  Someone else is sure to have a take that
completely disagrees.




在06-5-27,黄叶 <hylinux at gmail.com> 写道:
>
> 呵呵。
> 什么未必呢?
>
> 只是说可能嘛。
> 既然是有可能就是未必了。
>
> 但是不清楚你说未必指的是什么哦。
> 呵呵
>
> 不过认真学习和使用Perl,好像不是未必哦。
>
> *^-^*
>
>
> _______________________________________________
> China-pm mailing list
> China-pm at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/china-pm/attachments/20060527/369190fd/attachment-0001.html 


More information about the China-pm mailing list