Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tomf87

macrumors 65816
Original poster
Sep 10, 2003
1,052
0
I've just started reading "Learning Perl, 3rd Edition" recently, mainly because I can do system scripts and some web pages with it.

I started reading about PHP today as well, and I'm curious to know what your experience with each language has been. Is there a certain time you would use one over the other? Is there certain capabilities in each language?
 

Westside guy

macrumors 603
Oct 15, 2003
6,340
4,158
The soggy side of the Pacific NW
I know perl better than php, so understand that I'm biased here.

Perl is a more mature language, and is significantly less vulnerable to exploits. It's more powerful as well. BUT it is harder to learn for sure. php makes scripting on Unix pretty much like writing ASP pages for a Microsoft server. But the bottom line is you can do stuff with perl that you can't with php - the converse isn't true.

I'm responsible for a Webserver that perhaps a hundred people have write access to, and everyone in the department (maybe 1000 people) can at least log in. Since the skill level of our users varies quite a bit, we limit what they're allowed to do. On our server we have php disabled simply because it's less mature and therefore more exploitable. php exploits still come out every month or two, and they tend to be "severe" bugs. BTW we don't allow unrestricted CGI access either; I have to vet most scripts before they're made live (except for a few users whose skill levels are good).

Edit: I should probably point out that in many production environments you can set all scripts to run under the specific user's permissions - so at worst they can only compromise they're own files. But in our particular setup that's not practical (except for a few virtual hosts that are on our system - in those cases we do that).
 

Rower_CPU

Moderator emeritus
Oct 5, 2001
11,219
2
San Diego, CA
Interesting points, Westside Guy...

A couple questions:
Isn't PHP designed explicitly for web dev, whereas Perl is scripting applied to web dev?
Also, how does database access work with Perl?
 

ExoticFish

macrumors 6502a
i write perl but know little php. perl is a language that is used for most anything and everything while php seems to be used for mainly web stuff although it can be used as a laguage like perl as well... it's just that no one does. if this post doesn't make sense it's because i'm half asleep.
 

Westside guy

macrumors 603
Oct 15, 2003
6,340
4,158
The soggy side of the Pacific NW
Originally posted by Rower_CPU
Interesting points, Westside Guy...

A couple questions:
Isn't PHP designed explicitly for web dev, whereas Perl is scripting applied to web dev?
Also, how does database access work with Perl?

1) I believe you're right, although I don't know about PHP's origins. Perl pre-dates the Web. It's just such a useful scripting language that a lot of modules have sprung up specifically for Web work (such as cgi.pm).

2) For SQL access the standard module is DBI. It works quite well - I've used it a lot of late.

A lot of people who do SQL work rave about another language called Python. It apparently has a really well-thought-out database interface.

Actually looking at my previous post, I guess I sounded anti-PHP. I don't mean to be - it's just for our particular situation I don't think PHP is a good fit. Personally I'd like to learn it better; mainly to pad my resume. :D
 

tomf87

macrumors 65816
Original poster
Sep 10, 2003
1,052
0
I used to work for a company that hosted sites that used only Perl. They had custom Perl functions that used DBI to connect to Oracle7 and Oracle8 and it ran fine.

I just don't know if by reading up on Perl, I'm missing something on PHP, or Python as Westside pointed out.
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
I think its funny that PHP is capitalized, even though it no longer stands for "Personal Home Page" and Perl is mixed case, while it still stands for "Practical Extraction and Report Language"

PHP is far easier to use and learn, but Perl will give you more flexibility and power. mod_perl will give you the best performance, while PHP is fairly straightforward to code and has a huge function library built in.
 

D0ct0rteeth

macrumors 65816
Mar 11, 2002
1,239
7
Franklin, TN
Westside Guy knows his stuff.

Yeah.. I use PHP and Perl hand in hand on almost every project.. PHP wandles all the routine web stuff while Perl does the heavy lifting.

Both are valuable tools, and whenever I have to play with another language XML builds a nice bridge.

I cant say learn one over the other but the best summary is what WG said "Perl is a more mature language, and is significantly less vulnerable to exploits. It's more powerful as well. BUT it is harder to learn for sure. php makes scripting on Unix pretty much like writing ASP pages for a Microsoft server. But the bottom line is you can do stuff with perl that you can't with php - the converse isn't true."

- Doc
 

tomf87

macrumors 65816
Original poster
Sep 10, 2003
1,052
0
Originally posted by kingjr3
I think its funny that PHP is capitalized, even though it no longer stands for "Personal Home Page" and Perl is mixed case, while it still stands for "Practical Extraction and Report Language"...

Evidentally, there's a reason for that. According to my book, it says:

"It's actually a retronym, not an acronym. That is, Larry came up with the name first, and the expansion later. That's why "Perl" isn't in all caps." Learning Perl, 3rd Edition, page 4

I had never heard of a retronym until now.. :)
 

radhak

macrumors regular
Aug 28, 2003
218
0
NJ, USA
Originally posted by tomf87

I had never heard of a retronym until now.. :)

'News' is supposed to be a retronym (not widely used or accepted, of course ) : North, East, West, South.


back to the thread : Perl has given birth to various other languages, the more prevalent today being PHP, Python and Ruby. Of these, PHP is the most interesting one. Not nearly as good as Perl, but its fun to work in.

Python could have been good, but they have many weird practices, like 'white spaces have significance in the code' (like COBOL) or some such garbage.

Ruby's raison raison d aitre seems to be the older Perl's not-so-good (supposedly) OO handling. But with the latest versions I am guessing that does not hold water much.

Gist : if you want a really powerful language, nothing beats Perl. If you still want to have an alternative fun thing to look at, check out PHP.
 

Westside guy

macrumors 603
Oct 15, 2003
6,340
4,158
The soggy side of the Pacific NW
mod_php question

Could anyone point me towards the mod_php documentation? I searched apache.org, php.net, and did a quick google search; but I didn't find anything that was at all thorough.

What I'd like to find out is what limitations and/or control statements it recognizes, if I actually were to enable it on an Apache server. I've got a testbed box I can use to try things out on - comes in handy on occasion.
 

tomf87

macrumors 65816
Original poster
Sep 10, 2003
1,052
0
I can't find the mod_php docs anywhere. Isn't mod_php just a module for Apache that let's you run PHP code inside the web server? If so, wouldn't the PHP docs work?

I guess the same question would go for Perl as well. What's the difference between Perl and mod_perl?
 

Westside guy

macrumors 603
Oct 15, 2003
6,340
4,158
The soggy side of the Pacific NW
I guess I didn't phrase my question well; sorry.

Most modules that can be run with Apache will have some set of parameters that can be set to control how it runs. You might be able to control which directories they're enabled in, for instance - in that case if you support a lot of users, and want to test their knowledge before giving them access to that particular tool, you could do it. Or perhaps you could enable only a subset of the functionality, etc.

But it all would depend on what options the person(s) who build the module decided to leave accessible. So with mod_php, perhaps there are no options - you can only turn it on or off, in other words. Or perhaps there are tons of customizable options available. Without the documentation it's hard to know.

Mod_perl has tons of on-line documentation. I'm looking for the same sort of information about mod_php.
 

arson

macrumors member
Jan 12, 2004
84
2
Minnesota
Originally posted by kingjr3
I think its funny that PHP is capitalized, even though it no longer stands for "Personal Home Page" and Perl is mixed case, while it still stands for "Practical Extraction and Report Language"

It stands for PHP: Hypertext Preprocessor now. It's a recursive acronym.
 

mrjamin

macrumors 65816
Feb 6, 2003
1,161
1
Strongbadia
Originally posted by radhak
Python could have been good, but they have many weird practices, like 'white spaces have significance in the code' (like COBOL) or some such garbage.

thats arguable - the significance of whitespace and indentation forces good programming practice - it makes your code much easier to revisit, and for others to look at. Many people have different coding styles when it comes to indentation and whitespace etc which can make it difficult to read other peoples' work. In python, non-standard whitespace usage and indentation solves this

Many of my friends started on perl, explored PHP, then ditched both in favour of Python - i'm toying with doing the same.

I still stick with PHP for webdev stuff, and the odd bit of non-webdev stuff as you can execute PHP scripts in the same way you would a perl script. While I appreciate the benefits of perl, i still prefer PHP for most of the work I do. Also, in my experience, PHP scripts tend to execute significantly faster than most perl scripts.

edit: FWIW python is much better than PHP as far as OO (object orientated) coding is concerned. Its XML parsing is also miles ahead of perl 5 and PHP. Having said that, PHP5 and Perl 6 are supposed to "meet the bar" on both areas once they're released (infact, wasn't perl 6 finalised earlier this week?)
 

bousozoku

Moderator emeritus
Jun 25, 2002
15,718
1,891
Lard
Originally posted by radhak

...
Python could have been good, but they have many weird practices, like 'white spaces have significance in the code' (like COBOL) or some such garbage.
...

Python is good because it forces indentation. If you've had to port 100,000 poorly-written, undocumented C code, I would think that you would instantly realise the benefit of being able to read strictly structured code.

On the other hand, COBOL's Area-A, Area-B are more arbitrary but force categorisation--DIVISION vs. its subordinates SECTIONs. It was mainly used to aid the compiler in quickly identifying problems with the code. If you think that's bad, take a look at RPG II or RPG/III. :D

Perl always seemed odd to me but I have found the familiarity of PHP's syntax to be comforting.
 

Nermal

Moderator
Staff member
Dec 7, 2002
20,638
4,036
New Zealand
Interesting, I'm learning PHP this year (haven't started yet). I have some ASP.net experience, but I don't really like it because it's so Windows-centric. It'll be good to learn something open like PHP :)

We're also using MySQL. Something I don't understand though is that we're using MySQL for our Web App Development class, but for our Windows Programming class, taught by the same teacher, we're using Firebird :rolleyes:
 

Versello

macrumors regular
Nov 13, 2003
180
0
Originally posted by Nermal
We're also using MySQL. Something I don't understand though is that we're using MySQL for our Web App Development class, but for our Windows Programming class, taught by the same teacher, we're using Firebird :rolleyes:

I *********love********** MySQL :D
 

Nermal

Moderator
Staff member
Dec 7, 2002
20,638
4,036
New Zealand
Well I haven't had any experience with it yet, but I will have by the end of the course. Our teacher is one of the Firebird developers, so he told us all about the Firebird/Firefox fight :D
 

bousozoku

Moderator emeritus
Jun 25, 2002
15,718
1,891
Lard
Originally posted by Nermal
Well I haven't had any experience with it yet, but I will have by the end of the course. Our teacher is one of the Firebird developers, so he told us all about the Firebird/Firefox fight :D

Firebird is based on Borland's InterBase, which was quite a good database engine. I'm happy to see that there is even a Mac OS X version.

I was quite surprised to find that the thing was originally written in C. The Firebird team is re-working it for C++, so it should be more flexible. Then again, the Borland Database Engine only had C bindings...
 

iJed

macrumors 6502
Sep 4, 2001
264
10
West Sussex, UK
Originally posted by Versello
I *********love********** MySQL :D

I just wish MySQL had support for nested queries. I know it is coming in version 4.1 but it should have been there long ago. I often find times where I would like to use a subquerie and MySQL just can't do it so I have to code around it. Not difficult but incredibly annoying.

I also remember reading that transactions were not supported until MySQL 4. I'm not sure if that is correct or not but it may be.

Another thing I remember reading was that MySQL does not enforce referential integrity on foreign keys. Again I'm not sure if its true (and it doesn't really bother me) but surely this is something it should do.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.