Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

perl vs. php

by Anonymous Monk
on Nov 15, 2005 at 15:37 UTC ( [id://508637]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've been programming perl for 10 years now and I'm set to start a major project for the company I work for.

I'd like to do it in perl, but my boss would like php. Ideally, I'd like to choose the language that would be best for the project. If I really want to do it in perl, he'll let me.

Obviously, this site is geared toward the perl gurus -- but seriously, are there advantages over doing it in php over perl? Which is more secure?

Will I have a difficult time since I've done almost no php?

The project is a simple web-iterface that takes in data, stores it in a mysql database. There is also an bidding/auction section to the site.

Replies are listed 'Best First'.
Re: perl vs. php
by friedo (Prior) on Nov 15, 2005 at 15:48 UTC
    Dynamic websites are pretty easy in both Perl and PHP, so I don't know if there's any clear winner there. Perl does have several frameworks for making web application development easier, like Catalyst and CGI::Application. As well as sophisticated templating systems like Template. From what I understand, similar things are available in PHP as well, although PHP does not have the breadth of coverage that CPAN does.

    The main reason I avoid PHP though is the myriad security problems, lack of a consistent database interface, the habit of having a million functions in the main namespace with no particular naming convention or consistency, and the rather strange nature of PHP data types which allow you to mix hashes and ordered lists in a single structure.

    I understand PHP is making a lot of progress in these areas, though, so my concerns may be out-of-date.

      Caveat: I'm a PHP developer for Zend, and a lead author on several PHP open source projects. I'm also a perl developer. I use both languages regularly, though PHP more often than perl in recent years, due to the nature of my places of employment. I'm going to refute some points about PHP below, based on my experience with the language.

      From what I understand, similar things are available in PHP as well

      Yes, they are, including a PHP port of Cgiapp (that's a shameless plug), the Smarty templating language, the Savant templating language, and many others. In fact, regarding templating languages, PHP, in Rasmus Lerdorf's own words, was meant to be a templating language (Savant takes that approach, actually).

      There are number of frameworks similar in nature to Catalyst and CGI::Application out there for PHP as well -- Solar, Symfony, Cerebral Cortex, and Seagull, to name a few.

      PHP does not have the breadth of coverage that CPAN does

      This is debatable. The difference between PHP and Perl is that Perl has CPAN as a common repository. PHP has PEAR, but PEAR doesn't have quite the extensive library CPAN does. However, it does have some pretty rigid guidelines for contribution, one of which is that it (in recent years) allows duplication of packages only when the approach significantly differs, leading to what is hoped as 'best-in-breed' packages. Additionally, there are a number of other sites that are aggregating packages out there, including phpclasses. I'm betting that the number of PHP libraries out there is similar to perl's -- if in fact it hasn't exceeded perl's at this point.

      However, a key difference to note is that PHP is primarily targeted at web development. So the breadth and scope of packages for PHP is going to be significantly different than that for Perl.

      The main reason I avoid PHP though is the myriad security problems, lack of a consistent database interface, the habit of having a million functions in the main namespace with no particular naming convention or consistency, and the rather strange nature of PHP data types which allow you to mix hashes and ordered lists in a single structure.

      To this I reply:

      • There are security problems in just about every language; perl is not immune to this. Most security problems seen recently have less to do with the language itself as with bad programming practices (e.g., phpBB).
      • PHP is addressing the "consistent database interface" issue with the PDO library, which is due for PHP 5.1 (and has been backported to the 5.0.x series).
      • I agree with the "million function in the main namespace" comment; this is very frustrating for a PHP developer. However, many of these functions are very narrow and targetted in scope -- and correct usage of them can greatly optimize a script.
      • I like the mixing of hashes and arrays. This actually makes many types of operations easier, to my thinking. It is merely different from perl, not necessarily a disadvantage.

      As for the OP, what it comes down to is: does it make good business sense for you to learn PHP at this time? If the project has a narrow deadline, and it's known that there will be Perl developers in your company for the forseeable future, it may not make sense; you're more familiar with perl and its libraries, and you'll be able to maintain the site more easily as you won't need to 'switch modes' between the two languages.

      However, your boss may have some particular ideas for why s/he wants PHP: cheaper, more plentiful developer base (though that may change); easier to find hosting should s/he decide to outsource the hosting (I see PHP on more shared hosts than perl); perhaps some business partnerships that would involve exchanging APIs and code.

      Do more research before you make your decision; but don't believe all FUD you hear about either language.

        Thanks for the informative update, weierophinney. It seems at least some of my PHP knowledge is old and crusty. Fortunately I have the luxury right now of continuing to be a Perl snob. ;-)
        There are security problems in just about every language; perl is not immune to this.
        I would nevertheless say that Perl is somewhat more immune to security problems than PHP since, as I've already said in another message, PHP doesn't have a taint mode (contrary to Perl.)

        (I've heard about an attempt to provide PHP with a taint mode (PHPrevent), but I think that's at present more a theoretical study than a working extension.)

        Most security problems seen recently have less to do with the language itself as with bad programming practices
        Taint mode is something that can help to detect and prevent such bad programming practices, and it is something that unfortunately PHP can't offer.

        Ciao
        Emanuele.

Re: perl vs. php
by sauoq (Abbot) on Nov 15, 2005 at 16:33 UTC
    are there advantages over doing it in php over perl?

    There is one big one that's probably more relevant from your boss's perspective than from yours. When you leave the project or the company, it'll be a lot easier (and probably cheaper) to find a competent PHP developer who can take it over.

    Will I have a difficult time since I've done almost no php?

    It depends on you, of course. I do think that Perl programmers have a tendency to think of PHP as dysfunctional Perl and that tendency makes their learning curve slightly steeper. There are annoying syntax similarities that sometimes disguise the fact that the languages are not at all alike below the surface. Still, it's an easy language to learn and you shouldn't have that much difficulty given that you already have substantial programming experience. If you do go that route, just try to keep in mind that PHP is not Perl. (Deja vu... I've said some of this before at Re: Perl is more intuitive.)

    The one thing that makes me pause is your description of this project as "major". I think Perl definitely has some (or, at least, can have some) advantages for a larger project, especially if you have more than a very small handful of people working on it.

    † More specifically, when you finally perish in a brief and tragic meeting with a runaway bus which is, as all management knows, the inevitable fate of anyone who becomes too familiar with the evil technical details of any project.

    ‡ Similarities that probably exist because PHP was originally a Perl program.

    -sauoq
    "My two cents aren't worth a dime.";
    

      it’ll be a lot easier (and probably cheaper) to find a competent PHP developer who can take it over.

      Et tu, sauoq?

      Makeshifts last the longest.

        Et tu, sauoq?

        Now, now... I don't feel like I'm betraying anyone by telling the truth. There are droves of PHP programmers and, more to the point, they all do web work because that's what PHP is really for. Even if there were just as many Perl programmers we are split among application, systems, and web development. Admittedly, there is lots of overlap... but that's part of what makes us more expensive.

        Yes, you can write standalone PHP scripts. No, no one does it. Not seriously anyway. I hope.

        -sauoq
        "My two cents aren't worth a dime.";
        
Re: perl vs. php
by benrwebb (Scribe) on Nov 15, 2005 at 16:54 UTC
    I'm going to make a broad generalization and guess that your boss wants you to do it in PHP because "nobody uses Perl for websites anymore". If that is indeed his objection you might point out that amazon.com, slashdot.org and about.com all run on Perl (amazon and about use Mason). As far as a direct comparison you would do better to compare one of the Perl frameworks vs. PHP rather than Perl itself. I don't know how much web programming experience you have or if you have a preffered way of developing web technology in Perl, but I think you would get more milage out of comparing Perl/Mason or Perl/HTML::Template vs. PHP.
Re: perl vs. php
by Perl Mouse (Chaplain) on Nov 15, 2005 at 15:47 UTC
    are there advantages over doing it in php over perl?
    Yes, it makes your boss happy. But that's not a question you should ask here. And you shouldn't ask it on a PHP forum either. Not that I don't think their answers would be biased - they aren't useful for you. You don't want to do it in PHP - your boss does. So, ask you boss what the advantages are. It doesn't matter whether what he thinks are advantages are really advantages, but as long as he thinks they are, those are the arguments you have to deal with.
    Which is more secure?
    Neither. It's an irrelevant question. Programs are secure or not. You can write secure programs in any language (and it's difficult in all of them), and you can write insecure programs in any language (and that's surprisingly easy).
    Will I have a difficult time since I've done almost no php?
    How can we know? Some people pick up new languages in a matter of hours. Others are stuck in the first language they've learned, and will never become good in any other.

    You're not asking the right question - and you're not asking them to the right people either.

    Perl --((8:>*
      Neither. It's an irrelevant question. Programs are secure or not. You can write secure programs in any language (and it's difficult in all of them), and you can write insecure programs in any language (and that's surprisingly easy).
      That's not entirely true. Look at PHPs track record for PHPs security itself, not programs built with PHP. There have been numerous web worms and other types of malicious programs which are only viable because of functions in PHP itself that are vulnerable. They generally patch PHP pretty fast, but upgrading your own installation can be a headache when you have to do it every other week.
      Neither. It's an irrelevant question. Programs are secure or not. You can write secure programs in any language (and it's difficult in all of them), and you can write insecure programs in any language (and that's surprisingly easy).
      That's not completely true (at least in this case.)
      Contrary to Perl, PHP doesn't have a taint mode, which is a deficiency of the language.
      Granted, you can still write secure programs without using the taint mode, but it can be much harder to detect the vulnerabilities of your code.

      Ciao,
      Emanuele.

        It's still very easy to write insecure programs that have tainting enabled. The fact that Perl has a tainting option doesn't make Perl secure. It just gives the programmer one more piece of rope (either to hang himself, or to use well).
        Perl --((8:>*
Re: perl vs. php
by duff (Parson) on Nov 15, 2005 at 16:51 UTC

    IMHO, once you know perl, it's easy to learn and use PHP proficiently. You'll need to keep php.net close at hand for all of the myriad functions you have at your disposal, but I think that's no big hardship.

    As far as which language is best for the project, it seems like your project would be just fine for PHP. Also, it seems small enough that it would give you a good opportunity to learn PHP and increase your "bankability" :-)

    If you have control over the systems where the application will be installed then it's a wash I think as to which language you should use. For a perl implementation you'll need to install some modules to interact with mysql. That's often a difficulty on systems where you have no control. For a PHP implementation, it usually comes with everything (including the kitchen sink) that you'll need so no extra installation.

    Oh, and as others have said as far as the languages go, perl and php are equally secure. It's all in how you write your code (and for php, in how you configure it).

Re: perl vs. php
by tphyahoo (Vicar) on Nov 15, 2005 at 16:30 UTC
    Honestly I can't see there's much of an advantage either way. But, since you already have strong perl, and the auction stuff sounds like it may be needing business logic and not just db, you might want to take a look at Catalyst. Demo Catalyst-based handel for your boss, and point out how much has been achieved by strategic code reuse. How many more times this amount of code would you need to achieve the same functionality with PHP? Why, with Catalyst you can build a wiki in 30 lines of code!

    A lot of that was surely drinking the kool-aid, but after waiting many weeks for the handel demo to come out I'm in a mood to do some flag waving :)

Re: perl vs. php
by nothingmuch (Priest) on Nov 15, 2005 at 16:45 UTC
    Catalyst::View::PHP let's you write PHPish templates (with an embedded php interpreter) for catalyst perl apps, but IMHO PHP is not much more than perl with an ugly builtin library, no CPAN, and a buitlin templating syntax.

    -nuffin
    zz zZ Z Z #!perl
Re: perl vs. php
by Moron (Curate) on Nov 15, 2005 at 17:53 UTC
    php is a specialised web-development language which therefore gets the beginner started faster within the narrow remit of webpage development. Perl is a more general and flexible language that can be used in conjunction with existing specialised CPAN modules for the specialised work.

    Although the beginner can get started faster with php than perl, there is a fixed limit to productivity with php. Perl is slower getting started because it has a wider capability that isn't packaged into a web-focused language, but which offers wider functional coverage and much higher productivity over the longer term. I would say it therefore depends on how committed your role is to web development. The more committed over the longer term, the more payback from taking the time to use perl to build up a more productive and flexible shop than is possible with php and which would overtake the php capability within a few months. But for a one-off short project, php is likely to get results faster.

    -M

    Free your mind

Re: perl vs. php
by talexb (Chancellor) on Nov 15, 2005 at 18:05 UTC
      I'd like to do it in perl, but my boss would like php. Ideally, I'd like to choose the language that would be best for the project. If I really want to do it in perl, he'll let me.

    To me, this sounds less like a question about technology and more a question about psychology. So, why does your boss prefer PHP?

    It could be that it's a comfort zone thing .. the boss has looked at PHP examples and looked at Perl examples, and the PHP ones looked much clearer.

    Either language will be easy to maintain -- you can use Perl with a page templating system (like Template::Toolkit, the one I use) and make the source code look very PHP-ish.

    Frankly, it sounds like this is a simple enough project that you could do it in PHP no problems. If you've managed to learn Perl with any level of proficiency, I'm fairly sure PHP won't be much of a challenge.

    And, of course, once finished you could try doing the same project in Perl and see how much better it is. ;)

    Let us know how it all turns out.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: perl vs. php
by RicardoPortilho (Novice) on Nov 15, 2005 at 19:05 UTC
    At least here in Brasil there is one reason: php programmers are much more cheaper and easier to hire than Perl hackers. Of course I prefer Perl, and if you have 10 years on it, probably you´ve worked with CGI, HTML, etc., so won´t have any problems learning php. I think that you boss like php beacuse it is a fashion language nowadays, he read about it on the papers and think it´s a good thing. Managers...
Re: perl vs. php
by nikos (Scribe) on Nov 16, 2005 at 02:32 UTC
    Perl vs. PHP - this thread was started by me when I had a similar questions but I do wanted to compare them in fact and get reasons. BTW, it's very close to what you are asking for. You might have a look on it. I hope it helps. Cheers
Re: perl vs. php
by Cap'n Steve (Friar) on Nov 16, 2005 at 04:52 UTC
    Regarding the transition from Perl to PHP: It'll most likely be extremely easy, since the only real syntax differences in the average program would be references and arrays. Some things to keep in mind, though:
    • Be prepared to spend some time on php.net. You'll need to look up functions. A lot of functions.
    • Variable scoping is completely backwards compared to Perl. This continues to bother me.
    • Regular expressions in PHP will annoy the hell out of you. I recommend you stay with Perl if you need to do a lot of text processing.
Re: perl vs. php
by kiat (Vicar) on Nov 16, 2005 at 03:00 UTC
    I would go for PHP in your situation for a number of reasons. Firstly, you already have 10 years of perl and that knowledge isn't going to disappear just because you choose PHP this time round.

    Secondly, precisely because you already know Perl so well, you should consider PHP so you've an additional skill to market.

    Thirdly, it's always good to see things from the other side.

    Finally, choosing Perl over PHP goes against your boss' wishes, which may give the impression you aren't adaptive.

    Sidenote: I've coded a fairly extensive site in Perl. Recently, I did another site of a smaller scale in PHP. Because I was already familiar with some aspects of web logic, so it wasn't that difficult overall. I plan to try Python for a hobbyist site that I've been thinking of doing, just for the fun of it.

Re: perl vs. php
by kulls (Hermit) on Nov 16, 2005 at 08:20 UTC
    Hi,
    As you comment
    >> The project is a simple web-iterface that takes in data, stores it in a mysql database. There is also an bidding/auction section to the site.
    my suggestion is php.comparing with money,project timelines,resources and maintenance you can prefer php and most likely its well suited for mysql too. Regards
    kulls.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://508637]
Approved by monkfan
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-16 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found