Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

(jeffa) Re: PHP vs Perl code compare

by jeffa (Bishop)
on Oct 28, 2002 at 00:32 UTC ( [id://208418]=note: print w/replies, xml ) Need Help??


in reply to PHP vs Perl code compare

I find comparing two languages with "toy scripts" to not be very exciting. You are not going to really see the strengths and weaknesses until you delve deeper. Consider how database and interface abstraction layers influence your decision. That's where the excitement begins. ;)

I have been coding in PHP for the past week and so far ... it's not so bad. I have been using the Smarty templating engine and have been having very good results.

Why am i using PHP? First, because the original site was written with it. Second, my client wants PHP. Personally, I would rather use mod_perl, but (for me so far) PHP has been more fun than JSP, ASP, and Cold Fusion combined. If you are serious about PHP, i recommend O'Reily's Programming PHP and Smarty. PEAR looks promising as well.

What have i found the differences/similarities between Perl and PHP to be so far?

  • like Perl, PHP has array and associative array support, anonymous subroutines, built-in session support, just about everything a serious web monkey needs
  • PHP has regex support, but it's not built in like Perl's.
  • PHP is easy - this is good and bad. Good because it allows novice programmers to code powerful stuff. Bad because it allows novice programmers to code powerful stuff.
  • PHP has PEAR, PEAR ain't no CPAN
All in all, i can't really knock PHP, but if i have a choice - mod_perl!

jeffa

Blessed is the PHP programmer who grokketh Perl.

Replies are listed 'Best First'.
Re: (jeffa) Re: PHP vs Perl code compare
by fruiture (Curate) on Oct 28, 2002 at 12:01 UTC

    Just one thing: You say PHP supports anonymous subroutines, but sadly it doesn't.

    --
    http://fruiture.de
      It doesn't quite have the same flexibility as perl's anonymous subs but there is an equivalent in PHP
      <?php $f = create_function('$s', 'echo "got: $s";'); $f("a string"); ?> __output__ got: a string
      So we have an anonymous function but unfortunately it is isn't totally orthogonal with normal functions in PHP.
      HTH

      _________
      broquaint

        Aha. Well, although i can only see this as quite ugly (especially compared to Perl), it is in fact an anonymous function. Thanks

        --
        http://fruiture.de
Re: (jeffa) Re: PHP vs Perl code compare
by Xaositect (Friar) on Oct 28, 2002 at 19:16 UTC
    I have no problems with PHP as a language, I learned it before I learned Perl, and it has its own strengths. (Readability, designed for web apps) However, when it comes to making use of existing code modules, nothing I've seen can touch CPAN. Frankly CPAN has spoiled me considerably, I find locating PHP modules to be an extremely irritating task now.

    Speaking of which, I spent quite a bit of time a few weeks ago looking for a good template module for PHP, and was finally delighted to find vLib Templates. I'm not sure how its caching speedup compares to Smarty's, but it had the impressive bonus of looking very familiar.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://208418]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found