Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl vs PHP

         

Brett_Tabke

9:18 am on Mar 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I was surprised by some of the comments in this thread: [webmasterworld.com...]

I've always respected PHP, but never taken the time to learn it. The surprising thing to me is the number of perl folks switching to php.

What are some of the things people are finding attractive about php over perl?

For me, I like perl's stand alone and portable nature.

digitalghost

9:55 am on Mar 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHP has a small core language that reduces the learning curve. PHP is fast.

NO CGI libraries.

Easier separation of your code from your data.
Forget all the PRINT statements. Did I mention that it is fast?

Better variable treatment. PHP also seems to handle XML integration much better than Perl including accessing web services with RPC. All of this, faster.

DG

gethan

2:39 pm on Mar 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm both a PHP and Perl programmer.

I love both - but to be honest PHP has the advantage for cgi applications.

In terms of performance PHP is quicker on the average hosting package. It's usually in Apache as a DSO whereas Perl is available in the traditional manner. With the use of mod_perl you will have more control over the optimisation and therefore probably get to the stage where an equivalent application is quicker in perl. But for those of us not lucky enough to have a dedicated server mod_perl isn't going to be there. (The webserver needs to be restarted for every code change - debugging is sooo much fun ;))

In terms of learning - the major difference is this:

Perl cgi - a perl program that produces HTML as its output.
PHP cgi - an html based page that has programming statements embedded in it.

For a newbie with HTML experience PHP is much easier to learn as it's closer to what they already know.

Database usage:

PHP - (I've only used with mysql) - the array brought back by the fetch_row statement allows me to access columns by name - $row[column_name] - brilliant. The same could be done with perl hashes - but requires extra work on my part so usually I resort to counting cols.

Perl - DBI - great advantage is that all the calls are DB independent. In theory just by changing the DBD module used an app could be run on anything from Sybase to Informix. Obviously the sql being passed would have to be compatible accross all DB's but with PHP a global replace on the functions that interact with the DB would be required. A bit more work to migrate.

Well I've only just touched on the surface of this debate. As a general alround programming tool I'll never want to be with out perl. But for getting new cgi applications up for clients quickly with the minimum of work php is the way to go.

circuitjump

3:10 pm on Mar 6, 2002 (gmt 0)

10+ Year Member



That's not cool. We shouldn't be choosing. This is like a mother having to choose between which she loves the most. The father or son/daughter.

PHP, Perl and C are a family :) PHP being the prodigy

circuitjump

3:30 pm on Mar 6, 2002 (gmt 0)

10+ Year Member



Can anyone pass me a good online source to help in learning some Perl?

Thanks

digitalghost

3:32 pm on Mar 6, 2002 (gmt 0)

hasbeen

3:41 pm on Mar 6, 2002 (gmt 0)

10+ Year Member



circuitjump -

I just purchased 'Perl for Web Site Management' (I know it's not online per se). It's an O'Reilly and seems to be pretty well documented.

Nothing like jumping in feet first, eh?!

I also found this link for syntax/reference and whatnot:

[squirrel.nl...]

mjs7231

8:17 pm on Mar 8, 2002 (gmt 0)



Circuit Jump

I dunno if its any use but, going with the quote by uhh... everyone.. :)

"If you allready know one programming language you know them all." ..it may be easier to just look at other peoples code first and just take what ya need out of it.

I learned perl in a matter of about a week just grabbing scripts of Matts script archive on the net. If I needed to learn how to do somthing, I would just grab a script, see how they did it and then write my own.. maybe borrow a few lines.

Check it out...
[cgi.resourceindex.com...]

Lisa_Lia

7:26 am on Mar 9, 2002 (gmt 0)



When it comes to webpages I use PHP. When it comes to backend and data processing I use Perl. When it comes to processing large amounts of data and code that I don't plan on changing then I use C.

The advantages I have with PHP is the quick coding. I can write 1000+ lines of code in PHP in a few hours. HTML intergation is super easy. Dropping in and out of PHP parsing is great! And the speed is Fast!

Brett_Tabke

8:21 am on Mar 9, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thanks for the comments everyone.

Lisa, why is php coding faster for you? Is it a personal knowledge thing, or is it something inhirent in php? I'd think it would be _slower_.