Jump to content


Photo

is Perl worth it?


  • This topic is locked This topic is locked
32 replies to this topic

#1 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 September 2006 - 06:03 PM

okay i've looked into Perl in the past. I learned the hello world program and that's about it.  So I really don't know anything about Perl.  So out of curiosity or boredom or both, I decided to ask if Perl is worth learning if i'm already on the PHP path? I would never give up PHP! But Is there something that Perl does that you can't really do with PHP? Does it just boil down to a matter of preference/beefing up your general server side scripting knowledge, in case a site was done in Perl?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 06 September 2006 - 07:16 PM

eh... with the little bit of Perl work I've done, it's waaay better at handling text manipulation, but other than that, PHP can handle a lot.

Perl is a nice tool to have in your box, but not a necessity.

Info: PHP Manual


#3 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 06 September 2006 - 07:20 PM

But Is there something that Perl does that you can't really do with PHP?


Yes. This may be helpful. (The image was causing a slow load time for me, so stop the document manually if need be.)

I've been doing Perl for about a year and a half now, and suprisingly enough, I haven't used it for the web yet. Although my command line usage of PHP has been minimal, I think Perl has the upper hand here.

I see PHP as a language that has a lot to offer in terms of broad, high-level libraries. Perl offers this as well via CPAN, which is an awesome resource. I guess this would be the equivalence of PHP's PEAR, which I am not familiar with.

I see Perl as a down-and-dirty language. It offers advanced regular expressions which are built into the syntax of the language, flexible data structures, symbol table manipulations, namespaces, etc.

I would say that the implementation of OPP in PHP is better than Perl. Perl uses a lot of reference trickery, and although it works well, it's not always "official." (For giggles, Perl's OPP is known as POOP.)

Perl also offers testing (I don't know if PHP does). In Perl, you could write a series of tests, team them up with a browsing object, and it would run through your entire site and tell you what broke. I have yet to venture into this aspect; I'm still learning a lot elsewhere.

If you're digging through data or writing a lot of system tools, Perl is the way to go. If you're creating templates and working with a database... I can't say--I'm not familiar with Perl's web tools.

Personally, I still like PHP because it's where I first started and I have more experience and existing code to maintain. Once I find time to dig into Perl's web capabilities, things may change. I really appreciate Perl's short-cuts, clever syntax implementations, context handling, and control. They have an awesome community as well.

Working with PHP taught me a lot about the workings of the web; working with Perl taught me a lot about programming.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 06 September 2006 - 08:09 PM

I am a self-taught Perl guy, so I can't really speak to PHP's advantages/disadvantages, other than what I've seen here in the forums. 

First, I tend to like namespaces, and I don't see PHP with those. 
Second, PHP was designed to be "embedded" in HTML, and I don't like that either. 
Third, PHP has far too many different functions to match strings, which all take parameters in random order. 
Fourth, I couldn't live without hashrefs for everything, and I don't see that as native in PHP, though I might have missed it.
Fifth, Perl has been around for decades, isn't going anywhere, and CPAN is the best resource on the planet, if you don't feel like "rolling-your-own", which is what we Perl ppl do best anyway.

The list goes on and on... I couldn't ever abandon Perl.  Feel free to correct me if need be.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 07 September 2006 - 09:12 PM

i'd like to try and clear something up here. plenty of recent posts say along the lines of "i looked at xxxxx language. Is there anything that xxxxx can do that yyyyy can't do?"

would it be fair to say there are two answers to ANY question like this, depending on the person asking, who might be:

1. the coder that wants to know what the limitations of their final site would be.
2, the coder that wants to know what little tricks the language can show off from a developer point of view.

in terms of the first point, i'd say there are no limitations as HTML is very basic in comparison to serverside languages so its unlikely there's anything HTML the server side lang couldnt tackle with ease.

as for the second, surely it's a matter of taste and preference.

obviously, i've based both my points on the fact of using perl/PHP for Web stuff. But i'm quite adament on the point that when I hit a wall with PHP as far as web design goes, then i may look elsewhere. otherwise, what's the point?
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 08 September 2006 - 02:01 PM

Well, that's exactly the point -- there is no "wall" with Perl.  There's nothing to can't do... Perl is just about manipulating a bunch of strings, and guess what, that's what you spit out the browser anyway.  Consequently, I find Perl to be ideally suited for the task.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 20 October 2006 - 05:13 AM

Fourth, I couldn't live without hashrefs for everything, and I don't see that as native in PHP, though I might have missed it.

The list goes on and on... I couldn't ever abandon Perl.  Feel free to correct me if need be.


Since you made the invitation..

PHP references use C syntax, eg "$hashref = &$assoc_array".  However, variables are copy on write, including function arguments, so in most cases you don't need references.

For multilevel hashes, you can just write $assoc_array['level1']['level2'] = 'bleh';  It's not much different to perl really.  Is there a use for hashrefs which doesn't come under one of the above?  (that is, sharing data and multilevel structures)

I haven't hit a wall with PHP.. I think it is equal in power to Perl.  Just that perl is geared toward text processing, and php is geared toward web applications.  At my workplace we use perl for backend scripts, and php for the frontend.

#8 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 20 October 2006 - 04:30 PM

Well, AFAIK, Perl doesn't do copy on write, so if you want the reference, you need it.  I'm sure the syntax is similar -- but does PHP auto-vivify hashes?  I don't find anything about PHP particularly "geared" toward web apps, at least not as far as the core language, though I've only seen code examples.  But that's just me.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#9 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 31 October 2006 - 06:24 AM

Does autovivify mean to create automatically?  The default in PHP is to create all variables (including levels in multi-level arrays) automatically.  Like:

$var['count'] = 2;
$var['values'][0] = 0.1;
$var['values'][1] = 0.2;

I'm not sure if that's what you're talking about though..

If you then say "$values = $var['values']", you will get a copy-on-write copy of that part of the array.  "$values = &$var['values']" will give you a reference to that part of the array.

As far as usage goes, it's virtually the same as perl.  I found it easy to switch over.

Regarding "gearedness", it's the little things.. in perl you can write "while (<>) { s/..$// }", which is great for processing a text file.  In PHP, you can write "session_start(); $_SESSION['var'] = $_GET['var'];", which is great for a website.  $_SESSION is part of the language specification itself, as is $_GET and $_POST.

Once you've got enough skill in either language you can do anything though.  It's just the little things that are handled for you already which make up the gearedness.

#10 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 01 November 2006 - 08:50 PM

Agreed... and yes, that's what I mean by auto-vivify.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#11 c4onastick

c4onastick
  • Members
  • PipPipPip
  • Advanced Member
  • 216 posts

Posted 22 November 2006 - 11:29 PM

I'd like to reopen discussion on this topic if I may. I've been using PHP for web coding for about a year now (nothing professional, just for fun). I'd like to expand a little to other programming languages, I'm considering Perl since its superficially similar to PHP. I not a programmer by trade (I'm a scientist/engineer), but I like to automate tasks (hence my little hobby of programming). Is Perl a good tool for this? I love working with PHP, but it seems that it really was built for HyperText pre-processing, and I'd like something that might be a little more powerful on the desktop (shell). Most of the little annoyances I end up automating are things at work, and unfortunately (like the rest of the world) we're stuck with Windows. Is Perl for me? If not, what other language(s) should I look into? (I've read the links posted earlier, they essentially were Perl guys ragging on PHP) What are the Pros/Cons of each?

Thanks!
Regex Tester::Unicode Regex::PHP Function List::MySQL 5.1
"Sorry sweetheart... but this all day sucker is down to the soggy white stick." -- Topper Harley

#12 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 November 2006 - 12:17 AM

Perl is great for automation, though it's more native to *nix boxes -- however, I've had good experience working under windows as well.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#13 c4onastick

c4onastick
  • Members
  • PipPipPip
  • Advanced Member
  • 216 posts

Posted 24 November 2006 - 02:50 AM

Perl is great for automation, though it's more native to *nix boxes -- however, I've had good experience working under windows as well.

Any advice on a good book to start learning from? I've looked at the camel book and the llama book. I've done a fair amount of programming in VB and PHP, is the llama book a little too introductory? (Of course it couldn't hurt to review a little)
Regex Tester::Unicode Regex::PHP Function List::MySQL 5.1
"Sorry sweetheart... but this all day sucker is down to the soggy white stick." -- Topper Harley

#14 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 November 2006 - 05:08 AM

Actually, I've never used a book, so I can't suggest any in particular.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#15 c4onastick

c4onastick
  • Members
  • PipPipPip
  • Advanced Member
  • 216 posts

Posted 28 November 2006 - 07:02 PM

I talked to a programmer friend of mine, he suggested I look into Python (as an alternative to Perl). I've been scowering the internet looking for a good comparison of the two. Except almost all articles written on this topic turn into monster flames between to heated camps. I thought I'd post the few articles/blogs/forums posts that actually draw meaningful comparison between the two.

Best Article:
http://www.linuxjour...om/article/3882

Good article if you look past the author's cynicism:
http://lists.canonic...ary/000660.html

Short differences:
http://www.wellho.ne...-or-Python.html

Python vs. PHP
http://wiki.python.o...oin/PythonVsPhp

Detailed comparison of almost all languages (code examples too)
http://people.mandri...-languages.html

I'm trying to decide which language to pick up next. Hopefully this will help other people trying to make a similar decision.
Regex Tester::Unicode Regex::PHP Function List::MySQL 5.1
"Sorry sweetheart... but this all day sucker is down to the soggy white stick." -- Topper Harley

#16 Nameless12

Nameless12
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts

Posted 21 January 2007 - 01:42 PM

Python is better than both php and perl.

#17 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 21 January 2007 - 02:59 PM

Python is better than both php and perl.


That statement is just plain rediculous. Each language has its place. I personally love Python and use it allot more than I do PHP, though I dont do much web dev anymore. When I do, I usually op for PHP because that is exactly what it was made for. Though I have been finding the django framework alot of fun lately.

Anyway, my whole point is that any language has its place. Its a bit of a falsity to say any language is better then another.

#18 Nameless12

Nameless12
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts

Posted 24 January 2007 - 08:53 AM

I never said they didn't have their place but in the context of this conversation and on a technical level python is better than both is better than these languages. I am aware each language has its place, if I wasn't I would not use php. 

#19 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 24 January 2007 - 02:42 PM

"Better" must be used in context; otherwise, it's just subjective--an opinion. This conversation started with the question "Is Perl worth it?" and thus the answers have been "Well, it depends on what you're using it for...."
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#20 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 January 2007 - 03:10 PM

Well, necessarily so... just like with any tool, hammer or otherwise.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users