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

php, eh?

by dlink (Novice)
on Oct 18, 2002 at 17:14 UTC ( #206366=perlquestion: print w/replies, xml ) Need Help??

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

What is the monastery's position on all this PHP taking over the world?

Should I learn it? The fact that it is embedded code (inside HTML) turns me off. One of my favorite perl mods is HTML::Table which allows you to work more with objects. We write some complex, content rich websites.

Maybe, however, there is something to gain by migrating from perl cgi to php. Anybody here have experience with that?


Replies are listed 'Best First'.
•Re: php, eh?
by merlyn (Sage) on Oct 18, 2002 at 17:44 UTC
    Wrong comparison!
    Maybe, however, there is something to gain by migrating from perl cgi to php.
    Yes, you can gain a lot going from Perl-CGI to PHP.

    But I think you'll gain a lot more by going from Perl-CGI to mod_perl/$templating_solution (one of Template Toolkit, Mason, HTML::Template, and so on).

    I wish people would stop comparing Apples and Pineapples. CGI is CGI. It forks for each call. Embedded processors (like ASP, JSP, PHP, and mod_perl) work within the server. No forking. Faster. Cooler.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: php, eh?
by fruiture (Curate) on Oct 18, 2002 at 17:43 UTC

    First, it is dangerous to ask something like that on the web. You're lucky this is PerlMonks, here people are rather diplomatic, fair and use Perl for good reasons.

    My opinion about PHP: It is usefull, in certain situations: It must be a standard-task. The usual stuff, like "fetching something from a database and putting it into a website", maybe even "editing the database via the website". Nothing more. If you want to write a fast, easy and dirty solution to a rather popular problem, PHP is a good tool. You'll need to use it to set up a danymic webpage on a server without mod_perl, if you want a fast solution, for CGI might be not fast enough.

    But that's all. If you want to write a "big software", PHP is ugly, especially if you know Perl. It is way too explicit and has no "syntactic shugar" and very seldom you have MTOWTDI. I usually start to see only chaos as soon as there are more then 100 lines of PHP. PHP is not as good as Perl in terms of "scalabilitiy": You don't have namespaces, the OOP forces you to keep a class in a file. PHP doesn't have real function-references, it is impossible to have something like Template::Toolkit in PHP, you must compute all stuff before. I've just written a Framework where most database queries happen only on demand from the template, nothing more is fetched than neccessary...

    I don't like PHP, though i use it sometimes (I also don't like windows, but i use it sometimes). You can probably write good things in it, but there's no fun. Why should i use an interpreted language if it's as ugly to use it as C, especially when i have Perl available?

    There's no need to "migrate from Perl to PHP", but it's not bad to know PHP. It is also not bad to know Ada,Delphi or other "bondage and discipline languages". It is good to know a lot.

Re: php, eh?
by perrin (Chancellor) on Oct 18, 2002 at 17:58 UTC
    Maybe, however, there is something to gain by migrating from perl cgi to php.

    From CGI? Yes. But not from mod_perl or FastCGI or PerlEx or SpeedyCGI. However, given a choice between ColdFusion, ASP, and PHP, I would take PHP every time.

      > I would take PHP every time.

      Most definitely.

Re: php, eh?
by neilwatson (Priest) on Oct 18, 2002 at 17:35 UTC
    PHP is certainly powerful. It has much of the functionality of Perl. While both languages overlap somewhat, I think PHP has more of a niche in web applications.

    PHP is good for dynamic websites that need to be deployed quickly. With a little regex work and perl script or two you can even convert existing sites to PHP. Howerver, I think on larger deployments PHP pages can become harder to manage (templating may help this).

    Perl is still the swiss army knife of scripting languages. Whether your site is big or small Perl will easily handle you requirements.

    Neil Watson

      With a little regex work and perl script or two you can even convert existing sites to PHP.
      That alone speaks volumes, in my opinion.. You can just as easily convert to TT2 templates and stick with the language you're familiar with. Add Apache::Template on a mod_perl enabled server to the mix and you can do anything PHP can and then some in the same fashion - or any other fashion you choose to.

      Makeshifts last the longest.

Re: php, eh?
by revdiablo (Prior) on Oct 18, 2002 at 17:34 UTC

    I think PHP has its place, just like everything else. It's nice for quick stuff. It has a lot of handy builtin functions that make certain web tasks simple and clean. But for anything big or complicated, it starts to get a bit tedious.

    Also, for what it's worth, you don't need to embed PHP inside HTML... that's just what most people seem to do.

      > But for anything big or complicated, it starts to get a bit tedious.

      I believe the programmers over at VA Software could attest to that.

Re: php, eh?
by ignatz (Vicar) on Oct 18, 2002 at 17:53 UTC
    The main benefit that you will get from migrating to PHP from Perl cgi is the same benefit that you would get migrating to mod_perl: speed. I've noticed a certain painful shock that Perl programmers go through when they first have to use other languages such as Java or PHP. Usually it's accompanied by occasional exclamations such as "G___ d___ it, why the f____ is this so f___ing complicated. I could f___ing do this in one mother-f___ing line of Perl. Why the f___ do they have to write this piece of s___ in <INSERT LANAGUAGE HERE> anyway?" etc etc... In calmer moments around the watercooler they attempt to make up for their past public rudeness by extolling to everyone tales of the wonderful things that they did with Perl in the past.

    PHP is a lot better compared to my days when they paid me to program in PHP2. It's does, however, still have a long way to go to catch up with the CPAN.

Re: php, eh?
by Steve_p (Priest) on Oct 18, 2002 at 20:36 UTC

    PHP does definately have a place and I have suggested it as an alternative before on this site. I would just make a suggestion you usually won't hear from many PHP programers.

    Use error_reporting(E_ALL)! Just like the usual mantra you'll hear on PerlMonks of use strict; use warnings;, error_reporting(E_ALL) turns on all warnings and error messages on you scripts and pages. It should find a prominent place in each script you write, unless, of course, you enjoy crackers destroying your site. If you are shopping for a book on PHP, take a quick check of the index. If you can't find a mention of error_reporting() or the author downplays its usefullness, put the book down and walk away.

    The PHP community is still very young, and with the pummeling they have gotten, they are starting to smarten up. I would still be very cautious with suggestions and PHP code you run across. Remeber, WWPMD!

Good for beginners
by FamousLongAgo (Friar) on Oct 19, 2002 at 01:20 UTC
    One nice thing about PHP in relation to Perl is that it offers novice programmers an easy bridge from writing web pages in HTML, to writing web pages that draw from a database, to creating actual web applications. I taught a web programming class this summer with PHP as the language of choice and really appreciated the gentler learning curve. Given good coding conventions, you can create readable, modular, extensible projects in PHP.

    The real bonus ( for me as a teacher ) is that the Perlish syntax made it possible to boost some of the more advanced students into using Perl. Regular expressions, for example, are identical and provide a nice bridge.
Re: php, eh?
by Parham (Friar) on Oct 19, 2002 at 12:24 UTC
    What a lot of people don't know (or don't care to know) about PHP is that it originated as a perl script. Yes, it started off as a perl script which allowed people to embed html in code and it parsed forms for you. So this comparison of perl vs PHP is rather ridiculous since PHP was originally made off of perl.

    I'd like to add that I've migrated from perl to php. And although I use both languages regularly, when it comes to the more complex things, I always come back to perl to solve problems. PHP is great cuz it's all bundled for you, but you can the exact same results with perl by installing mod_perl, and having the DBI module all set up.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://206366]
Approved by tye
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-11-27 03:50 GMT
Find Nodes?
    Voting Booth?

    No recent polls found