[Za-pm] Re: Za-pm digest, Vol 1 #15 - PERL vs PHP

Dr Giancarlo Contrafatto contrafa at biology.und.ac.za
Tue May 27 03:45:01 CDT 2003


On Mon, 2003-05-26 at 11:21, Oskar Pearson wrote:

Hi folks;

Well, thank you to Orkar, Dallas, Rory and Nico for their "perl of
wisdom". Ouch ... sorry ... Dreadful!

Oh, yes. Bartho is asking for books. There is the one I used to get
myself started with PERL. I'll check at home to see if I have the CD and
then we can talk some more.

> 
> PHP is not really like javascript.
> Javascript runs in the browser itself: web pages with embedded source
> are served to the browser, which then runs the code in the pages.

Although, one can use Java to write servelets which, I suppose, can be
viewed as serverside, wealthy relatives of javascript. But this doesn't
seem to have been a very popular choice at all. There was much hype
about it in the mid- to late 90s but I haven't come across all that many
real-life examples.

> PHP runs in the server. It determines what is in the web pages it serves
> before it even gets sent to the client. It can, of course, serve javascript
> to the client, which can then run it.
> 
> It's akin to CGIs (not sure of your level..) - it's just faster than running
> a program from the ground up - the interpreter is always in ram.
> 
> PHP is akin to mod_perl in this way: it's in the server, and serves the
> data without having to load the interpreter each time.

OK gorrit! Same as PERL except that the availability of the interpreter
is neat but, probably, not crucial in a relatively low traffic
environment and efficient server hardware. 

> > >2) php programmers generally have a poor idea of the seperation between
> > >code and interface. They put db queries straight into their table
> > >layout code and other such things.
> > i have seen many programmers do this, even perl programmers
> 
> Oh absolutely - I agree with that. The difference is, however, that
> almost all the reference material I've seen and read for php seems
> to have examples like this:
> 
>  print "<table>\n";
>     while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
>         print "\t<tr>\n";
>         foreach ($line as $col_value) {
>             print "\t\t<td>$col_value</td>\n";
>         }
>         print "\t</tr>\n";
>     }
> 
> (that's from the php manual at
http://www.php.net/manual/en/ref.mysql.php)

Hehehe! Yea, I know the feeling. From bitter experience, I've figured it
is best for me to place the html code into subroutines and leave the
logic at the top of my scripts. At least I know the variables are there
when the HTML interface needs them.

Of course, I understand what Nico is saying: even if you know both
languages, you would tend to do the heavy duty stuff using the one you
have more experience with. So, in conclusion, I may have a look at PHP
and may even like it but I may end up carrying on using Perl because
I've already aquired some familiarity with it. Certainly, one of the
things I like about it is the debugger: always been very useful to me.

ciao

 
-- 
there is no road to freedom, freedom is the road. Mahatma Gandhi
                   \|/
                  (o o)
--------------ooO0-(_)-0Ooo----------------------------------------------
G. Contrafatto - School of Life and Environmental Science
University of Natal Durban - Ph. +270312603336
##########################################################################
Visit Darwin at http://contra.biology.und.ac.za




More information about the Za-pm mailing list