Call for TPF volunteers: I know PHP, why should I use Perl?

petdance on 2005-10-20T03:56:23

I went to the Chicago PHP User Group today, and I talked about project tracking. Afterwards, I chatted a bit about TPF, and I was asked "I already know PHP, why should I use Perl?"



That's a question that I want us as TPF to be able to answer, in ready form for people to refer to. I want one of you, out in the Perl community, to work with me to write the set of pages that answer that question.



If you would like to work on this project, please email at andy at perl.org and let me know. This will be a writing project, not an HTML project, so don't worry about web chops.



I welcome your comments here in this entry, too. They may give us ideas that we can use in the final pages. Note that the question is not "Why is Perl better than PHP", but rather "Why should I use it?" The former question is purely a mental exercise, and the latter is a pragmatic one.


Why should I use it?"

Adrian on 2005-10-20T07:46:47

Note that the question is not "Why is Perl better than PHP", but rather "Why should I use it?"

Off the top of my head:

  1. Perl is used in places that PHP isn't. You'll find Perl applications everywhere from unix system administration to car parking. Learning Perl gives you the opportunity to work in more places doing different things.
  2. In many cases somebody else has written most of your application for you. CPAN is a stupidly useful resource.
  3. All languages make some things easier and some things harder. Learning another language broadens the mind. Learning Perl well will open you to some new techniques, some of which you can take with you to other languages - including PHP.

Everything else I can think of is just support for point (3).

Devil's Advocate

ziggy on 2005-10-20T16:41:00

(Attempting to channel a recalcitrant, skeptical PHP programmer....)

Perl is used in places that PHP isn't. You'll find Perl applications everywhere from unix system administration to car parking. Learning Perl gives you the opportunity to work in more places doing different things.

That's fine, but why should I care? I'm never going to use a Sequent, port my application to AIX 4 or DYNIX. It's nice that sysadmins can use Perl, but if I don't care about writing sysadmin scripts, what's the point?

If the web is the dominant development platform, and PHP makes it easy to develop cross platform web apps, what does Perl provide that PHP lacks that I care about? Of the features that are really, truly different, which are actually meaningful? I mean, it's nice that Perl has BEGIN blocks and __DATA__ sections, but if I never use them, where's the benefit?

Finally, any interesting new applications are going to be on the web. If there is some radical cool car parking application that Perl does today that isn't web-based, the next one will be web-based, and may as well be written in PHP.

All languages make some things easier and some things harder. Learning another language broadens the mind. Learning Perl well will open you to some new techniques, some of which you can take with you to other languages - including PHP.

Forget the platitudes -- what does Perl provide here? If I'm going to bother learning a language different from PHP to broaden my horizons, why start with something so similar to PHP? Why not just go full bore and dive into Scheme, Lisp, Erlang, Forth, Smalltalk or Haskell?

Also, if there are any benefits from Perl (or any other language), why should I be the one who wastes my time learning Perl with the explicit purpose of not using it? Why not just wait for other Perl programmers to bring those ideas with them into PHP? If those are really killer techniques, they'll come to PHP eventually, or else they really can't be killer techniques, can they?

Re:Devil's Advocate

petdance on 2005-10-20T16:51:33

Yes, exactly. These questions are the ones that we need to anticipate in writing this. We need to explain the tangible benefits, not the soft fuzzy ones.

Re:Devil's Advocate

jdavidb on 2005-10-20T19:43:13

I noticed you addressed points 1 and 3, but not point 2. I notice also that point 2 has the best chance of achieving the ">33% increase in productivity" someone else mentioned.

Also, if there are any benefits from Perl (or any other language), why should I be the one who wastes my time learning Perl with the explicit purpose of not using it?

Not answering the question of why, but the idea of learning things you won't use doesn't exist (much) since you can learn a minimal subset of Perl easily and in general won't ever have to learn something unless you are interested in using it, right now.

Re:Devil's Advocate

ziggy on 2005-10-20T20:07:43

I noticed you addressed points 1 and 3, but not point 2. I notice also that point 2 has the best chance of achieving the ">33% increase in productivity" someone else mentioned.

The benefits and drawbacks of CPAN are well known. And, as a devil's advocate, my point isn't to be Mr. Internet Politics Debater and natter on with "you're wrong and here's why", but to highlight some flaws in your argument that need to be addressed.

Not answering the question of why, but the idea of learning things you won't use doesn't exist (much) since you can learn a minimal subset of Perl easily and in general won't ever have to learn something unless you are interested in using it, right now.

Um, the point of learning a new language is to learn how to think differently. The point of learning a minimal subset is to use your existing skills with a new syntax, and forego the effort to learn how to think differently. So if your approach is to do as little work as possible learning Perl, you're going to go through a lot of effort with practically nothing to show for it.

The parts of Perl that are going to be truly labor saving devices aren't the kinds of things that are found on page 7 of Learning Perl. And if you're going to take the slacker's path to learning Perl, you're probably not going to find and/or understand them, either.

Re:Devil's Advocate

jdavidb on 2005-10-23T02:49:20

It was Adrian's argument, not mine, and I was just trying to point out that CPAN was definitely a selling point that couldn't be spoken against.

Re:Devil's Advocate

Adrian on 2005-10-21T08:27:18

Responding to the recalcitrant, sceptical PHP programmer rather than ziggy :-)

That's fine, but why should I care? I'm never going to use a Sequent, port my application to AIX 4 or DYNIX. It's nice that sysadmins can use Perl, but if I don't care about writing sysadmin scripts, what's the point?

None.

Let me be clear. I'm not trying to say "you should drop PHP and use Perl". I'm saying "here are some reasons you should consider learning Perl as well".

If none of them apply, then don't learn Perl. Doesn't bother me at all :-)

If you want to stick to the domains that PHP handles well more power to your elbow. However it's been my experience that restricting yourself to a single programming language and a single problem domain is a really bad career move.

Learning more programming languages can only make you more employable. If your concentrating on web development targeting the other primary language used for web development would seem sensible.

If the web is the dominant development platform, and PHP makes it easy to develop cross platform web apps, what does Perl provide that PHP lacks that I care about? Of the features that are really, truly different, which are actually meaningful? I mean, it's nice that Perl has BEGIN blocks and __DATA__ sections, but if I never use them, where's the benefit?

To pick one - anonymous subroutines and the way you can use them in more functional style development. Most of techniques in MJD's Higher Order Perl just can't be done in PHP.

However this kind of answer will always get the immediate answer of "I doing need to do Foo - I can just do Bar instead". And there isn't really any answer to this that doesn't involve effort by both parties.

Finally, any interesting new applications are going to be on the web. If there is some radical cool car parking application that Perl does today that isn't web-based, the next one will be web-based, and may as well be written in PHP.

Yes everything that needs a public interface will likely soon have some kind of web based interface. But that's only the interface - the tip of the iceberg. The munging of data behind the scenes is the meat. The difficult bit. The bit you get paid more for. Perl has been lord and master of that domain in many organisations for some time. Nobody is going to port everything over to PHP just because it's your favourite language.

Let me put it another way. I don't care about the recalcitrant, sceptical PHP programmer. I don't care about recalcitrant, sceptical programmers in any language. Including Perl.

I don't care because there is absolutely nothing you can do about them. As this recent perlmonks conversation shows there is nothing you can do with people who do not listen.

It's like arguing with the kind of C developer who doesn't see any advantage in object orientation - after all they can do it all in C. They're right and oh so wrong all at the same time.

So, if it were me, I wouldn't be aiming content at the sceptics because I don't think it's a battle that can be won. I'd be aiming material at the people who are thinking "there must be a little bit more to software development than this".

I'm noticing a lot of PHP developers moving over to Ruby because they've hit walls in PHP and have started seeing areas where it's just a little bit more work than they think it should be. These are the kind of users I'd be aiming advice at.

Anybody who thinks learning another language is a waste of time isn't going to be convinced whatever you say.

Re:Devil's Advocate

ziggy on 2005-10-26T14:34:20

(still channelling the recalcitrant, sceptical PHP programmer...)
Learning more programming languages can only make you more employable. If your concentrating on web development targeting the other primary language used for web development would seem sensible.

Your defending the argument with still more platitudes. Specifically, you're making a generalized argument that PHP programmers should learn more languages, but you're not saying anything specific about why PHP programmers should learn Perl. (To be fair, HOP is a pretty compelling and specific answer, but only one answer; learning Perl just to read HOP isn't entirely necessary. In fact, it really highlights that you should just skip Perl/HOP and jump straight into Scheme/SICP/SICM and just read those a couple of times.)

Also, if you follow your line of reasoning to its logical conclusion, learning a language not primarily used for web development would be more of a benefit. Any language can be used for web development (have you seen the web server written in PostScript?), so all the better to learn a language that extends your grasp, instead of just introducing you to another corner of your current sandbox.

Yes everything that needs a public interface will likely soon have some kind of web based interface. But that's only the interface - the tip of the iceberg. The munging of data behind the scenes is the meat. The difficult bit. The bit you get paid more for. Perl has been lord and master of that domain in many organisations for some time. Nobody is going to port everything over to PHP just because it's your favourite language.

True, but data munging can be done in any language, which is why it's mostly done in Java or C#. Or PHP. If Perl were really used in "many organizations" for the heavy stuff, that would be reflected in lots of correlating data: book titles, book sales, magazines, conferences, job ads, tools, etc. pretty much uniformly distributed across the technical world.

The one thing that Perl has shown beyond a reasonable doubt is that you really need a good regex library in your toolkit, which every language pretty much has now. All of which just puts Perl on par with pretty much every other language out there. Where's the real benefit to Perl qua Perl?

So, if it were me, I wouldn't be aiming content at the sceptics because I don't think it's a battle that can be won. I'd be aiming material at the people who are thinking "there must be a little bit more to software development than this".

True, but if you're hoping to change anyone's mind, you need to be able to answer the skeptic. Offering shallow reasoning to support your argument doesn't really convince anyone in the long run. It just sets up high expectations and mostly fails to deliver them.

Re:Devil's Advocate

Adrian on 2005-10-30T11:18:57

(still responding to the recalcitrant, sceptical PHP programmer...)

Your defending the argument with still more platitudes. Specifically, you're making a generalized argument that PHP programmers should learn more languages, but you're not saying anything specific about why PHP programmers should learn Perl

I thought the "targeting the other primary language used for web development" was fairly specific :-)

In fact, it really highlights that you should just skip Perl/HOP and jump straight into Scheme/SICP [mit.edu]/SICM [mit.edu] and just read those a couple of times.

You say that as if it would be a bad thing!

True, but data munging can be done in any language, which is why it's mostly done in Java or C#. Or PHP. If Perl were really used in "many organizations" for the heavy stuff, that would be reflected in lots of correlating data: book titles, book sales, magazines, conferences, job ads, tools, etc. pretty much uniformly distributed across the technical world.

Outside of front-end web development I've never seen PHP mentioned in a job advert. I've never been involved with, or known anybody involved with, writing back end code in PHP. Ruby, Perl, Python, Java and half a dozen others yes. PHP never.

Now I'm not saying that it's impossible to write back end code in PHP. Just that you're very unlikely to ever get work doing it. Go look at the job adverts for banks. Perl (and Python) pops up all of the time. PHP doesn't.

Where's the real benefit to Perl qua Perl?

CPAN - because it will save you a stupid amount of time writing code that somebody else has already written. Existing client infrastructure - because there are a lot of existing clients out there with large chunks of Perl that they don't want to throw away.

Outside that nothing that is going to give you a massive increase in productivity. Lots of little things that will give you little advantages (like anonymous subroutines and other HOP/Lisp-ish things), but nothing earth shattering.

Offering shallow reasoning to support your argument doesn't really convince anyone in the long run. It just sets up high expectations and mostly fails to deliver them.

I don't think the reasoning is shallow (but I would say that :-). It's just not the sort of argument that says "You should drop PHP now and learn Perl. You'll be a lot better off".

You won't be better off if you drop PHP and learn Perl.

Don't do that.

You will be better off if you learn Perl (or some other language) as well. Perl is used in lots of places that PHP isn't. You will have more job opportunities in different domains. If this doesn't interest you don't learn Perl, or indeed any other language.

You know...

Purdy on 2005-10-20T13:03:44

I like to point to my experience with PHP as why I shy away from it. But that's simply not good enough - I mean, anyone can write insecure code with any language.

I'm not sure this is a worthy project. IMO, we need to get programmers good at what they do. KISS (Keep It Secure, Stupid!). Converting them to a new language resets their capabilities instead of getting them closer to writing that killer app.

Peace,

Jason

Re:You know...

petdance on 2005-10-20T13:11:25

I mean, anyone can write insecure code with any language.

Although Perl makes it very easy to NOT write insecure code by using taint mode. That's a huge bonus over PHP.

We'll be sure to put taint mode on the list.

Re:You know...

Purdy on 2005-10-20T13:35:07

Yeah, that was my initial thought, too, but put yourself in the shoes of a PHP programmer. They just want to hack something quick to get the job done. Taint mode adds complexity to the task at hand.

And I'm sure there's something similiar that can be done in PHP (register_globals, etc).

IMHO, the clincher is CPAN (though PHP has PEAR -- odd their latest news is >1y old, though -- maybe PHP uses something else?). With CPAN, a Perl Web programmer can design/code from a high level and look for CPAN modules to do the dirty work.

- Jason

Re:You know...

petdance on 2005-10-20T14:27:16

put yourself in the shoes of a PHP programmer. They just want to hack something quick to get the job done.

That's far too broad of a brush. Just in the room of a dozen PHP folks last night, there were two camps. There were the people in the "I just want something quick to get it done" group, as you suspect, and there was the "PHP was what I learned years ago, and I've never seen a reason to change" group. It's this latter group that I'm most concerned with.

Re:You know...

mkirank on 2005-10-20T15:12:15

Though I have not used this and dont know much , using Php::Interpretor php folks get access to CPAN modules so that is a good reason

Re:You know...

ziggy on 2005-10-20T17:18:10

... there was the "PHP was what I learned years ago, and I've never seen a reason to change" group. It's this group that I'm most concerned with.

Should they change because we want more people at our dinner party, or because they can get more stuff done? Every argument I've heard over the years has been on the dinner party side -- whether the targeted hacker uses Java, PHP, Python, Ruby, Tcl, or C++.

Paraphrasing one of my favorite Twilight Zone episodes from the 1980s, the one thing that will get any programmer to switch languages is the realization that his current languages paints him in a corner with "a question I cannot answer, or a task I cannot perform."[*] Everything else is just too Turing-equivalent to be bothered with. Sure, PHP has annoying little quirks, but so do Perl and Befunge. And, if the time comes, that the PHP programmer needs to do a little Perl, he'll limp along doing the smallest amount possible until he comes across a task that's easier for him to do in PHP, at which point he switches back.

Even a minor 5%-25% increase in productivity isn't really worth bothering with, especially when you consider that Perl is a very rich language which takes years to master all of the nuances. So if I were a PHP programmer who wanted a compelling reason to change, I'd be looking for something that allowed me to do things that are simply impossible in PHP, or make me >33% more productive.

*: This includes the ever-present "getting a job" task.

Re:You know...

petdance on 2005-10-20T18:03:35

So if I were a PHP programmer who wanted a compelling reason to change, I'd be looking for something that allowed me to do things that are simply impossible in PHP, or make me >33% more productive.

Yes, I agree. That's exactly what I'm aiming for on this.

Re:You know...

jdavidb on 2005-10-20T19:44:06

Yeah, that was my initial thought, too, but put yourself in the shoes of a PHP programmer. They just want to hack something quick to get the job done. Taint mode adds complexity to the task at hand.

Ick. I would never want anyone working for me to have the idea that taint mode adds too much complexity to a web app.

host availability

da on 2005-10-21T17:05:43

Many web service providers do not allow user perl scripts in a shared-user environment. Any argument for using perl over PHP has to address the tools people have available from the companies they are comforable working with...

Why Perl? - GAVollink's impression

GAVollink on 2005-10-24T18:21:19

There are plenty of successful VisualBasic programmers who do a great job creating applications for use on the Web and Desktop. They may know that C++ is more powerful, but most of them never need the low-level abilities that C++ allows. As a whole (especially given a Windows environment), VisualBasic is good enough for almost any job.

I look at it this way:
Perl is to C++ as PHP is to VisualBasic.

PHP is probably the hardest group, as a whole, to convince. PHP is more specialized, which makes it easier for new users to learn, and it has many, powerful high-level features that make web tasks easy to do.

Which brings the other difficulty you face is that someone asking that question probably does want to learn another language. However, they are probably thinking Java or VB, as the next step, instead of another utility language, as Perl is.

On the whole, I would say - once you are fairly comfortable with any specific language, it's not very difficult to learn Perl. Most of the concepts are the same between all popular* languages, it's just the C style semicolons, and parenthesis smattered about that make perl look foreign to a PHP programmer.

For me, if I were going in the other direction, I would look at Perl as gateway step toward Java, in which case, I'd probably just skip Perl entirely, and go straight for Java. Generally, I would have never gotten into Perl if it weren't for it's command line and scripting abilities. So, the next step, from a Utility CGI language, like Perl or PHP is Java... Client-Server applet computing at it's best.

Until Parrot...

Once Parrot really gets off the ground, full-blown client server computing for Perl - web delivered - will not be far off. If I'm not mistaken, that's one of the goals of Parrot, right? LWP will make it easy, in any case. Parrot may end up supporting PHP, but PHP isn't necessarily well suited to dealing with the client side. Is PHP working on something like this? Google points me to "PHP Flash Remoting", which is cool, but not really what I think of when I think client-server.

So, my interpretation of why? Because Perl v 6 and the Parrot engine are coming to a web server near you.

All that said... To MANY developers, Perl's current Linux Centric view (being few modules are tested on Windows) and a large chunk are not available without VisualStudio 6+ in any case, the CPAN argument flies right out the window. I hope Parrot can make some strides towards fixing that issue. It will do Perl good overall.

--

Oh, and Andy, Thanks for reading this. I appreciate the opportunity to talk directly to the "leadership" on these important issues.

Re:Why Perl? - GAVollink's impression

petdance on 2005-10-24T19:07:07

So would you like to work on this project, getting these pages together?

Re:Why Perl? - GAVollink's impression

GAVollink on 2005-10-24T19:48:17

What's the expected timing? I need to get a book review out within the next week and a half, and I've read about half of the book. And that's (also) outside of my day job, but otherwise, yes.