Go Back   SitePoint Forums > Forum Index > Program Your Site > General Development Issues
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Closed Thread
 
Thread Tools Display Modes
Old Mar 17, 2001, 03:16   #1
zhchua
SitePoint Enthusiast
 
Join Date: Jan 2001
Posts: 63
Yes, I'm sure you have saw the comparison thingy (esp, ASP vs PHP). But I'm just curious, is there anything that Perl can do that PHP can't and vice versa?

Which is a better choice
zhchua is offline  
Old Mar 17, 2001, 04:36   #2
M. Johansson
Wanna-be Apple nut
silver trophy
 
M. Johansson's Avatar
 
Join Date: Sep 2000
Location: Halmstad, Sweden
Posts: 7,434
Oooh - the epic battle between Perl and PHP

Oooh - flame throwers coming this way...

Anyway - now I'm a super rookie to server side programming, but the major difference between the two languages is that perl can do a heck of a lot more, since it is a complete programming language, like C or Java. PHP is much much more focused on server-side programming, and cant do anything else.

There has been an endless debate going on about wheter if Perl or PHP is faster - but the margins are really too small to notice either way. I'd reckon PHP is the fastest if you start using things like the Zend optimizer.

I'll try to get a few advantages/disadvantages:

PHP advantages
Easy to learn - VERY easy to learn.
A true server-side language.

PHP disadvantages
Very forgiving - thus a lot of sloppy code is written.
Limited if you want the server to do a little bit more than serving web pages.

Perl advantages
You can write a CSS descrambler with 7 lines of code
Full blown language
Cool name

Perl disadvantages
Can't think of any, really. Slower, perhaps? Naw. Only if competing with a server optimized for PHP.
Oh yeah - it's much harder to learn, simply because it is more complicated. Perl IS the ultimate geek language. Check out this piece of Perl code:

Code:
$_='while(read+STDIN,$_,2048){$a=29;$b=73;$c=142;$t=255;@t=map{$_%16or$t^=$c^=(
$m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;$t^=(72,@z=(64,72,$a^=12*($_%16
-2?0:$m&17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271);if((@a=unx"C*",$_)[20]&48){$h
=5;$_=unxb24,join"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$
d=unxV,xb25,$_;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=$t&($d>>12^$d>>4^
$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*8^$q<<6))<<9,$_=$t[$_]^
(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;eval
__________________
Mattias Johansson
Short, Swedish, Web Developer

Buttons and Dog Tags with your custom design:
FatStatement.com

Last edited by M. Johansson; Mar 17, 2001 at 04:59..
M. Johansson is offline  
Old Mar 17, 2001, 06:18   #3
boredboi
Bored One
 
boredboi's Avatar
 
Join Date: Jul 2000
Posts: 239
i must be seeing a freddy opposite

is it true that php scripts, when run using cron, would cause the web server to slow, and thus make rendering / loading of webpages slower, while perl does not?
boredboi is offline  
Old Mar 17, 2001, 07:00   #4
M. Johansson
Wanna-be Apple nut
silver trophy
 
M. Johansson's Avatar
 
Join Date: Sep 2000
Location: Halmstad, Sweden
Posts: 7,434
Dear Boredboi,

I have no idea.

Does it matter, since it is a cron job?
__________________
Mattias Johansson
Short, Swedish, Web Developer

Buttons and Dog Tags with your custom design:
FatStatement.com
M. Johansson is offline  
Old Mar 17, 2001, 07:08   #5
boredboi
Bored One
 
boredboi's Avatar
 
Join Date: Jul 2000
Posts: 239
its a cron job, but it would take a few hours to run
and people would still visit the site meanwhile...
i "recall" someone saying that using php would slow the web server, but i'm not sure if its true...
boredboi is offline  
Old Mar 17, 2001, 07:59   #6
westmich
SitePoint Wizard
 
westmich's Avatar
 
Join Date: Mar 2000
Location: Muskegon, MI
Posts: 2,328
Quote:
perl can do a heck of a lot more, since it is a complete programming language, like C or Java.
I am a little out of my element here, but I thought Perl was a scripted language. Can it be compiled? Does support objects? Can you directly access the hardware level of your computer with it?
__________________
Westmich
Smart Web Solutions for Smart Clients
http://www.mindscapecreative.com
westmich is offline  
Old Mar 17, 2001, 08:18   #7
M. Johansson
Wanna-be Apple nut
silver trophy
 
M. Johansson's Avatar
 
Join Date: Sep 2000
Location: Halmstad, Sweden
Posts: 7,434
Uhm - I may have lied there... In fact I did. The phrase should be "since it is MORE LIKE a complete programming language".

Anyway, I quote from "MySQL" by Paul DuBois:

"Like Perl, PHP is a scripting language. Unlike Perl, PHP is designed less as a general-purpose language than a language for writing web applications." ....

"Perl, like C, is suitable for writing standalone programs. However, it also happens that Perl is quite useful for Web Site development."
__________________
Mattias Johansson
Short, Swedish, Web Developer

Buttons and Dog Tags with your custom design:
FatStatement.com

Last edited by M. Johansson; Mar 17, 2001 at 08:24..
M. Johansson is offline  
Old Mar 17, 2001, 08:31   #8
Hartmann
chown linux:users\ /world
SitePoint Award Recipient
 
Hartmann's Avatar
 
Join Date: Aug 2000
Location: Houston, TX, USA
Posts: 6,333
Perl was never meant for the web.... It kind of fell into it. However, it is great for performing certain tasks. Perl's syntax is a little harder to read and has a lot of ins and outs that you might need to learn to get the effect you are looking for. I find Perl a perfectly suitable language for small form processing or something of the sort.

PHP's syntax like truelight said is very forgiving. There are a ton of functions that you can use to manipulate text, files, databases, etc. Perl also has these features but sometimes it does perform poorly.
Hartmann is offline  
Old Mar 17, 2001, 09:28   #9
Son Nguyen
AdSpeed.com
 
Son Nguyen's Avatar
 
Join Date: Aug 2000
Location: Silicon Valley
Posts: 2,242
Perl: There Is More Than One Way To Do It!

As shown in my class the other day, a complete assembler and interpreter (bring assembly language to machine code) written in Perl is only 2 slides long.
__________________
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Son Nguyen is offline  
Old Mar 17, 2001, 15:04   #10
Owen
Hi there!
 
Owen's Avatar
 
Join Date: Jan 2000
Location: CA
Posts: 1,165
Perl is more powerful but harder as everyone else is saying. I like perl, though i'm starting to use PHP for simpler programs. I think something like headers/footers/time/form processing is better in PHP, but a complete program (game, interactive stuff, complicated processing) is better in Perl. Basically in 75% of your code deals with HTML or form processing or output right to the user then go w/ PHP, otherwise Perl might be better.

Owen
__________________
OP-DESIGN
Owen is offline  
Old Mar 17, 2001, 21:54   #11
zhchua
SitePoint Enthusiast
 
Join Date: Jan 2001
Posts: 63
With PHP-GTK released a few days ago, does anyone forsee PHP taking over Perl ?

Can someone tell me more about GTK in simple english

I seen all the docs avaliable on the net.
zhchua is offline  
Old Mar 20, 2001, 06:43   #12
Mr.Natural
SitePoint Enthusiast
 
Join Date: Jan 2001
Posts: 18
i got a question-

im getting a server in a couple days here.i dont have enoufe to have them install php.i know perl somewhat only through copy and pasting and hacking (newspro)

i plan on having files seperated by name.for example one persons files are stored on one folder another persons on a differant folder than called by way of ssi to differant pages.

question is would php be good for this? (for a database that is) worst case plan is i make a ssi database but i have the feeling itl be slow.
how hard is php to install on a remote server over the web?

i am looking to do something with perl anyway but have never really ever done anything with php.also i want something a little easier to learn than perl.

does php offer anything good in the form of databases,forms and polls?

thank you
Mr.Natural is offline  
Old Mar 20, 2001, 07:17   #13
zhchua
SitePoint Enthusiast
 
Join Date: Jan 2001
Posts: 63
PHP is more suited for the Web environment.

Nuff said. Of course if you are using mySQL as your database, it will fit seamlessly into the PHP environment

What you are doing is suited more for PHP than Perl
zhchua is offline  
Old Mar 20, 2001, 07:59   #14
creole
SitePoint Wizard
 
creole's Avatar
 
Join Date: Oct 2000
Location: Nashvegas Baby!
Posts: 7,847
Quote:
Originally posted by westmich
I am a little out of my element here, but I thought Perl was a scripted language. Can it be compiled? Does support objects? Can you directly access the hardware level of your computer with it? [/B]
Westmich...I am not a programmer, but the programmers at my last job used Perl exclusively. It cannot be compiled as an application, but it does "compile" before running so once the program starts, you will not get any errors (code-wise).

It does support OOP but only with extra hassle. They are working on that in the next version.

Don't know if it can access hardware level.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Like others here, I find PHP MUCH easier to read and interpret, although Perl code that is well written is understandable as well.

I like the fact that PHP has built in functions for many of the things that web designers/developers would want. I DO wish that in the next version of PHP that they build in things like ASP 3.0's ad-rotater, random objects and that sort of thing.
__________________
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
creole is offline  
Old Mar 20, 2001, 16:15   #15
freakysid
SitePoint Callithumpian
silver trophy
 
freakysid's Avatar
 
Join Date: Jun 2000
Location: Sydney, Australia
Posts: 3,801
Mr Natural, you don't happen to have a Raq at 4webspace.com do you? If so, there have been extensive and detailed discussions about installing PHP and mySQL onto those servers over at www.webhostingtalk.com You can do some searching over there to find the relevent threads.
__________________
Website design, development & SEO
Format your code when posting. Skunk's useful PHP and MySQL links
freakysid is offline  
Old Mar 20, 2001, 16:51   #16
Skunk
Grumpy Mole Man
 
Skunk's Avatar
 
Join Date: Jan 2001
Location: Lawrence, Kansas
Posts: 2,190
Anyone for python?
Skunk is offline  
Old Mar 20, 2001, 22:41   #17
Mr.Natural
SitePoint Enthusiast
 
Join Date: Jan 2001
Posts: 18
i couldnt find anything about this freakykid. so im assuming the problem was severe or ? lots of problems.

okay thanks.

whats python? lol
Mr.Natural is offline  
Old Mar 21, 2001, 05:42   #18
Skunk
Grumpy Mole Man
 
Skunk's Avatar
 
Join Date: Jan 2001
Location: Lawrence, Kansas
Posts: 2,190
Python is a very funky open source scripting language similar to PERL but with much better OOP support. Check this out for info:

http://noframes.linuxjournal.com/lj-...ue73/3882.html

Or just hit the official website:

www.python.org

The linuxjournal article is what got me interested though,
Skunk is offline  
Old Mar 22, 2001, 09:01   #19
braveheart
SitePoint Member
 
Join Date: Mar 2001
Location: bonnie scotland
Posts: 10
PHP has a lot more going for it just now, it's open source and it's progression is fast, another benifit is the Apache server.

I agree that it's easy to learn, hell a bairn can learn it!! If you know a bit about Javascript, then PHP will be a breeze. Actually, the 2 compliment each other.

Now, when is Macromedia going to jump in and support PHP I wonder? Cold Fusion isn't exactly a scripting language is it...
braveheart is offline  
Old Mar 22, 2001, 11:51   #20
Skunk
Grumpy Mole Man
 
Skunk's Avatar
 
Join Date: Jan 2001
Location: Lawrence, Kansas
Posts: 2,190
As far as I can tell ColdFusion's selling point is the fact that it isn't a scripting language. It seems to be a bit of a clever marketing ploy to me - the message is that if you can code in HTML, you can code in CF (since it uses HTML style tags for pretty much everything). People who are put off by the idea of a structured programming language such as PHP are drawn by ColdFusion as it lets them achieve the same kind of thing without having to mess around with curly braces, variables and semi colons...
Skunk is offline  
Old Mar 22, 2001, 13:27   #21
Hartmann
chown linux:users\ /world
SitePoint Award Recipient
 
Hartmann's Avatar
 
Join Date: Aug 2000
Location: Houston, TX, USA
Posts: 6,333
PHP-GtK allows you to create programs for GNOME (Linux Window Environment). I believe you will be able to pretty soon create programs for Windows through it.
Hartmann is offline  
Old Mar 22, 2001, 14:28   #22
Skunk
Grumpy Mole Man
 
Skunk's Avatar
 
Join Date: Jan 2001
Location: Lawrence, Kansas
Posts: 2,190
I'm currently not too convinced by the PHP / GtK idea. What's getting me is that PHP is designed in every respect as a "run once very fast" language. PHP scripts are meant to be executed in a split second before returning the full output of the script to a browser. Using PHP for application development means writing PHP scripts that continue to execute for an extended period of time.

I don't see how a language designed for one off semi-instantaneous bouts of activity is going to fair well in the world of applications that need to keep running using a limited set of memory and resources in tandem with other processes running on a server. Surely the memory management techniques used by a script designed to run once and then shut up are diffrent from those used by a script that sits in the background churning over indefinitely...

That said, I have recnelty been experimenting with using PHP to connect to an IRC network via the socket functions. There is an excellent function library for doing just this available on www.phpwizard.net and it allows one to quickly and easily set up an IRC bot running as a PHP script on a web server, with no extra software needed other than standard PHP. You call the script which powers the bot in your browser, and it literally runs until you issue the bot a quit command in IRC (or the bot gets flooded off the system, which is more than likely). I left a bot running for half an hour powered only by my lousy windows laptop and didn't spot any ill effects, and the IRC function library documentaiton suggests that the author has managed to keep the same PHP script / process running a bot for upwards of two days!

This would seem to pove my initial fears unfounded, but I'm still highly skeptical that an ongoing background processs written in PHP will be half as efficient as a similar process written in a language designed for such purposes such as PERL or Python.
Skunk is offline  
Old Mar 22, 2001, 16:23   #23
Hartmann
chown linux:users\ /world
SitePoint Award Recipient
 
Hartmann's Avatar
 
Join Date: Aug 2000
Location: Houston, TX, USA
Posts: 6,333
I listened to an interview with Rasmus Lerdorf and he stated that he wanted PHP to stick with the web aspect of things. However, the PHP Group makes the decisions, they have not fully integrated PHP/GtK and probably won't for some time. They want to focus on PHP development as a scripting language for the net.

I see PHP doing the exact opposite of what Perl did. PHP is going from the web to the desktop while Perl went from the desktop to the web.
Hartmann is offline  
Old Mar 22, 2001, 19:43   #24
TWTCommish
SitePoint Wizard
 
TWTCommish's Avatar
 
Join Date: Aug 1999
Location: Pittsburgh, PA, USA
Posts: 3,900
Argh!

It's this simple: PHP is perfect for web applications, Perl is more useful for getting down and doing the dirty work - shell scripting, and a bunch of UNIX junk that I know nothing about.

These language wars, so to speak, usually have no real winner, just strengths and weaknesses.
TWTCommish is offline  
Old Mar 23, 2001, 15:16   #25
big_al
The Flying Code Monkey
 
big_al's Avatar
 
Join Date: May 2000
Location: New South Wales, Australia
Posts: 1,640
Quote:
Originally posted by westmich


I am a little out of my element here, but I thought Perl was a scripted language. Can it be compiled? Does support objects? Can you directly access the hardware level of your computer with it?
Hi,

I am currently working on a community portal written in perl (not by me) and have spoken to the guys that wrote the system about perl and it's pros and cons.

Perl is mainly written in C, hence you can access many of the C libaries, which everyone will admit makes it very powerful, it isn't a compiled language, as for speed, like a C program you need to optimize the code before it getts really fast, but of what I've seen of it, it's quick!

Now for the learning side of things (only speaking of what I've been told by these guys) it's fairly simple to pick up and do that basics...but....do do complex things and do them well, there is a very large learning curve. Just as an example two of these guys that wrote the system, for fun they calculated how big a sail would have to be in space in order for them to travel 250,000km in one year, being pushed by light hitting the sail propelling them forward.....Took them 20mins in their HEAD! but they both got the same answers..hehehe
__________________
.NET Code Monkey
big_al is offline  
Closed Thread

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

 
Forum Jump


All times are GMT -7. The time now is 21:18.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved