Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
We don't bite newbies here... much
 
PerlMonks  

The REAL reason for why they choose PHP over Perl.

by Spidy (Chaplain)
on Jun 10, 2006 at 19:50 UTC ( #554630=perlmeditation: print w/ replies, xml ) Need Help??

Recently, I participated in a student-for-a-day thing at a local college. The basic idea behind this is that you find the course you're thinking of taking, and sit in the back of the classes for the day, to see if it's really what you were hoping it was, and what you still want to take.

I happened to be sitting in on a web design course, and managed to get a bit of question time with the instructor. Obviously, I asked him whether they focused on Perl or PHP in regards to languages taught during the course(they also taught stuff like (x)HTML, JavaScript, Coldfusion, and on and on...but that's not important). The discussion went something like this:
Spidy: So, which language do you focus on here at
<learning institution>? Perl or PHP?
Instructor: Oh, we focus on PHP.
Spidy: Why?
Instructor: Well...Perl is sort of old. And outmoded,
and it's being phased out.
As you can see, not exactly the informative answer that I was hoping for. Not really an answer, come to think of it.

So I'm wondering, and I'll ask you, the Perl community: why does everyone seem to prefer PHP nowadays? Is it because the creator of PHP's first name isn't Larry? Is it because the word 'PHP' is shorter than the word 'Perl'?

It's something that's been bothering me for a while; I figure that someone here will be able to anwer this with far more clarity than that instructor.

Spidy

Comment on The REAL reason for why they choose PHP over Perl.
Re: The REAL reason for why they choose PHP over Perl.
by adrianh (Chancellor) on Jun 10, 2006 at 20:21 UTC
    So I'm wondering, and I'll ask you, the Perl community: why does everyone seem to prefer PHP nowadays? Is it because the creator of PHP's first name isn't Larry? Is it because the word 'PHP' is shorter than the word 'Perl'?

    Because almost every web host on the planet has mod_php installed. Which means that people who want to mess around with interactive web applications have a very low barrier to entry with PHP. Upload the files to the web server. Done.

    Compared to separate-process-CGI-scripts mod_php is a lot faster/simpler. Compared to mod_perl + templating library of your choice it's a lot more common.

    And also, since PHP 5 (with 6 around the corner) it's a considerably less hateful language from a purely technical perspective.

    (update: less hateful than previous PHP versions anyway)

      Shared hosts that use mod_php end up (in my experience) switching to the CGI version so that it can execute as the script's owner. This is usually done because of problems with outgoing spam. I wonder how big a draw "in process" really is for PHP.

Re: The REAL reason for why they choose PHP over Perl.
by marto (Chancellor) on Jun 10, 2006 at 20:54 UTC
    Hi Spidy,

    <rant>
    "The reports of my death have been greatly exaggerated." Mark Twain.

    Did the instructor say anything along the lines of "C is a dead languague, its even older than Perl"? Or who will be doing the phasing out?
    </rant>

    This does not answer your question "why does everyone seem to prefer PHP nowadays?", but it is something to keep in mind. When I transferred from college to Uni our C++ teacher had written a book on the subject which we "Had to buy, if you want to stand a chance of passing this course". This was the same man who had no idea that you could compile C++ code using "Borland C++", nor could he explain the code he had 'written' for a linked list tutorial. In fact, I had to explain to that code to the class. What I am basically trying to point out is, just because someone is a boss, manager or 'educator' does not necessarily mean that they are right.

    Cheers

    Martin
      Yeah, I've noticed that. However, even talking to people who are employed in the industry, they say they choose PHP "just 'cause", essentially. There are no real specific comments made as to why or why not PHP over Perl.
        Hi Spidy,

        I know people who earn their living using PHP/MySQL to build websites, and they too have the 'just because' reasoning behind their choice of languages. This is something I don't understand. I would like to think that when I make these sort of decisions, I am able to backup my decision based on facts and technical requirements, rather than just because I feel like implementing something using a particular language/technology. In my experience "the right tool for the right job" applys here, often various factors constrain the tools you can use in the work place. For example, some employers will stick to a tool/product set, be it ASP/MS SQL Server or PHP/MySQL, because their employees are skilled in these areas, or they have a lot of existing/legacy code in these languages which needs to be maintained.

        Martin
        That's fine by me. If they're making that sort of decision "just because" then I can expect them to be equally sloppy and slapdash in the other decisions they make and in the code they write. I don't want to work with such people. I'd be happy to be paid to clean up their mess afterwards though.

        And you never know, I might clean up their mess using Java or C or PHP instead of perl, if I think that that is the right choice.

Re: The REAL reason for why they choose PHP over Perl.
by jhourcle (Prior) on Jun 11, 2006 at 00:00 UTC

    I've been doing web development for a decade now, and I can quite easily say that there are a few different types of web developers out there.

    For those that come from a programming background, we know how much extra power there is from a real programming language, as opposed to these text-preprocessing language.

    But for the person who's just looking at cranking out a quick prototype, that doesn't requlre some of those special features, stuff like ColdFusion and PHP can be more productive. There's the issue with keeping style and content seperate, that we've been doing with templating for years -- but I can do the same thing with text-preprocessors -- I've done pages where it's almost exclusively Apache SSI calls, save for a call to a CGI (include virtual), where I deal with the features that I can't do in a given language.

    Why do I do this? Well, part of it's what's tool for the right job, but most of it is what group I'm working with, and what the common language is -- I don't want to be the only person who can maintain something, as we all know that changes are going to be needed in the future, and I don't scale all that well.

    Now, when I'm dealing with programmers, even for application (not necessarily web-based), Perl seems to be a good language that we can standardized on. If I'm dealing with designers, they might know the HTML, but they don't know a real programming language, and need the best bang for their buck -- if all they need is stuff that's been done before (feedback forms, search engines, guestbooks, weblogs, etc.) They're not pushing the edge of the text-preprocessing language -- they might push the design edge, but that's it.

    If I were a teacher, trying to teach a class of 20-30 students, with heterogeneous backgrounds, I'd probably go the PHP route, too. I'd have to get them up to speed on design, HTML, database, and HTTP concepts -- I might have enough time to teach them bad Perl programming, but I'd rather teach bad PHP. (well, I'd try to teach them good PHP, but how much can you really expect to be learned in a single semester class? They're not going to be some HTML/SQL/programming prodigy after an introductory class)

Re: The REAL reason for why they choose PHP over Perl.
by ww (Bishop) on Jun 11, 2006 at 03:06 UTC

    Ignoring the inaccuracy (I think) of the instructor's answer and of your supposition (embedded in your question "why does everyone seem to prefer PHP nowadays") that that answer is factually correct, one might focus on your identification of what you call "not important" topics... "(x)HTML, JavaScript, Coldfusion...."

    That sounds to me (my own possible snobbery acknowledged) like a survey course, or a course appropriate to a vocational school. If that's the charter for the institution you visited, all well and good.

    Clearly, there's a market for web workers who can fit into a production line operation and a little JavaScript is a great adjunct.

    and then we come to ColdFusion, Dreamweaver and the other aps that let those with little knowledge of html turn out workaday pages -- the headline page of your local newspaper that's updated manually several times an hour; the auto dealer who has one of the salesmen or mechanics periodicly update the stock list and so on. There's a demand out there for folk who know just enough to do those jobs with aps like CF or DW. And that means, there's a demand for schools that teach them.

    On the other hand, teaching folks how to program -- whether in ASM, C#, perl or Ada (God forbid!) -- doesn't lend itself to a survey course, nor is it likely to be accomplished in a semester or two, unless the student is already proficient in something... and it requires more preptime and expertise from the teacher, than does a survey course.

    And, IMO, even training the average college student as an html coder (no snobbery here: I can proudly say, 'I am one"), is going to take more than a mere survey course, unless the student is exceptionally diligent and motivated to learn more than mere basics.

Re: The REAL reason for why they choose PHP over Perl.
by spiritway (Vicar) on Jun 11, 2006 at 06:36 UTC

    Hi, Spidy. I always wonder who "they" are when "they say" or "they choose PHP over Perl" ;-)

    I agree that PHP is popular, and it may be getting increasingly so. I'm not all that familiar with PHP - I've written a few things in it, but find it's not really something I care to use. I might use it for a guestbook, I suppose...

    I think maybe some people are using PHP because it makes certain Web tasks easier; but from what I've seen, PHP isn't nearly as versatile as Perl. IOW, PHP may do well in its niche, but as an all-round programming language, it doesn't compare favorably to Perl. It seems to me that there are lots more would-be Webmasters out there than programmers. These folks may not care to learn much of a language, beyond the minimum needed to get their Website going. The influx of non-programmer Webmasters might skew the numbers a bit, making PHP seem unrealistically popular. Just a thought...

Re: The REAL reason for why they choose PHP over Perl.
by chargrill (Parson) on Jun 11, 2006 at 07:16 UTC

    I had a remarkably similar conversation with someone just last night. She is slightly technical, I think she does something like "business strategy" or "marketing" or some other nonsense. Somehow we were talking about programming languages; naturally I mention Perl. And she says "Oh, it's old, does anyone actually use that anymore? I thought everyone used ASP, .NET, and...." (she may have listed some more, but I was pretty nonplussed at the time). I had to explain that it was alive and well, it's being used for some very advanced stuff (naturally it's automating a lot of the manual processes at my job, but I also recently attended a lightning talk about a guy doing real time trading applications(!) with Perl).

    I further told her that at the end of this very month, there's a North American conference exclusively for Perl (and I'm doing what I can to help out with it, as I am now call myself a Chicago Perl Monger.

    It's not just PHP, but all that other stuff. jsp, asp, etc. Perl is definitely (among some) given a very bad rep. And I really have no idea why.



    --chargrill
    $,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}
      Perl is definitely (among some) given a very bad rep. And I really have no idea why.

      I have an idea on why this happened, though it really isn't more than just an idea. Since the beginning of time humans liked to talk about stuff they don't know or understand. Someday someone said "Perl is just for text processing," and someone else said "Perl is ugly line-noise." And that just sticked. All over the world this urban legend is repeated, mostly by people that never have seen a Perl program or talked to a Perl developer.

      With such a biased view, it doesn't even matter if someone even ever happened to look at some Perl code. Because: of course it will look like line-noise to them. It has all those weird chars and doesn't seem at all like $random-language-they're-writing-guestbooks-in.

      And now, many years later, it's just fixed in peoples minds. I have even met "militant" perl-enemies, who can't accept that Perl might not be the way they're picturing it. I usually stop the conversation when the other side runs out of arguments and starts with ad-hominem or mocking attacks. One of the first arguments is often that there's too many ways in Perl. It's not that they have a simple problem and want a simple solution. It's not that they have a project on such a low level that it isn't needed to evaluate strategies and design decisions. According to those people, there are just too many ways. Period. If you don't accept that, you're wrong.

      But the most outstanding thing in all those discussion is that it is built to (estimated) 90% on prejudice. But it sticks and it will stick, because there are too many Perl experts out there that have never seen any line of Perl in their life.


      Ordinary morality is for ordinary people. -- Aleister Crowley
Re: The REAL reason for why they choose PHP over Perl.
by wfsp (Abbot) on Jun 11, 2006 at 08:11 UTC
    why does everyone seem to prefer PHP nowadays?
    I don't know but may I play devils advocate for a moment.

    I maintain a web site and am heavily committed to Perl. Both heavy duty HTML rewriting and a collection of CGI scripts (keyword search, site maps etc.). I have downloaded and have had a cursory look at PHP. My thinking at the moment is that if I wanted anything like that I'd go the SSI/Perl route but that is some way off.

    Yesterday, after seeing many recommendations, I decided to install Template::Toolkit to see if it really was that much better than HTML::Template which I use at the moment.

    As I use Activestate/Win I searched with ppm and found half a dozen or so of varying versions. Sadly all of them seem to be corrupted, an HTML page for laser printer ink catridges was displayed :-)

    I installed it from cpan. Slightly dismayed by the "if you haven't got a compiler you'll have to use the _really slow__ version" I persevered. There were only two tests and both failed. I don't have a background in programing and this is usually enough to have me skuttling away to look for something else.

    The point for me is that I was able to ask in the chatterbox. I was advised that this was almost certainly a command line quoting issue and given a pointer on what to do if I was worried about it. This was a great relief, it wasn't me being stupid.

    This sort of thing has happened many times although often it is because I can be a bit slow on the uptake :-)

    Of course it is impossible to say but I don't how long I would I would have stuck it out if it hadn't been for the monks patiently persevering with me. Combined with some excellent books (recommended here) I've managed to learn enough to do the tasks I need. I think Perl is great. But I do sympathise with anyone starting out and wondering which route to take. "There but for the grace of God...".

    In a weeks time I'll have been a monk for two years. I would like to take this opportunity to thank all the monks that helped me along the way. I've thoroughly enjoyed meeting you all.

    Again, many thanks!

      Well said ++
      My thoughts too
      I couldn't have put it better.
      Let me help you out some more.

      Firstly, there's no longer any excuse for not having a compiler one Windows.

      You should go have a look at Stennie's "Camelpack" which is an install of ActivePerl that pre-installs a proper make and a proper compiler along with Perl, so that you can install from CPAN normally.

      ActiveState's PPM server is dead and twitching, there are almost no major APIs that are available in relatively modern versions any more.

      If there's anybody using ActivePerl that isn't using the CamelPack yet so there can install from CPAN when needed, they damned well should be.

      And the guys working on Vanilla/Strawberry seem to have fixed a lot of the bugs now, that used to appear in things like Term::ReadLine::Perl and so on.
Re: The REAL reason for why they choose PHP over Perl.
by Polonius (Friar) on Jun 11, 2006 at 09:34 UTC

    I think the real reason lots of people take up PHP is that it is well known that you can just take a page of HTML, insert a line or two of PHP, and make your HTML do something more dynamic. It's well known that you can introduce PHP gradually, incrementally, into your HTML for a very easy learning experience. It is not well known that you can do the same with Perl.

    Polonius
Re: The REAL reason for why they choose PHP over Perl.
by zentara (Archbishop) on Jun 11, 2006 at 11:47 UTC
    why does everyone seem to prefer PHP nowadays

    Because PHP requires less brains than Perl, and the colleges are full of wannabes these days, who are passed on curves, for the tuition money. The colleges have to make it as easy as they can for the dimwits to pass.

    Ask the college admissions office how many of them get hired after graduation as web programmers.


    I'm not really a human, but I play one on earth. flash japh
      Because PHP requires less brains than Perl

      Do you really believe that? That Perl is difficult? That it doesn't make "easy things easy and hard things possible"? Part of the reason people choose not to use Perl is that they think it's difficult. Do you want to encourage that view?

      Polonius
        Do you really believe that?

        Yes, in the sense that Perl is "bigger in what it encompasses", and therefore requires a bit more background knowledge. Perl is a more complex tool. But maybe I was a bit too harsh, I hate full moons on Sundays......it brings out my biting nature. :-)


        I'm not really a human, but I play one on earth. flash japh
      Because PHP requires less brains than Perl,
      1. You think that's a bad thing?
      2. In my experience the opposite is true. It takes more understanding to write decent PHP than it does to write decent Perl - because the language makes some things harder than the equivalent perl.
        This page show the bigs diferences: PHP in contrast to Perl:
        • Arguments and return values are extremely inconsistent
        • PHP has separate functions for case insensitive operations
        • PHP has inconsistent function naming
        • PHP has no lexical scope
        • PHP has too many functions in the core
        • PHP lacks abstraction and takes TIMTOWTDI to bad extremes
        but PHP5 is more OOP.

        I suppose the best reason are these:
        • PHP is built from the ground-up with database functionality built in, particularly MySQL functionality. Perl is not.
        • PHP code gets embedded into HTML pages, unlike Perl. This makes it very fast to code web pages and fast to deploy a new site, thus speeding up Web development and lowering overall cost of ownership. An important code management technique for programmers is separating code from data. This allows us to make changes to the code or data without affecting the other. PHP uses the tags to indicate "code inside". In Perl, however, programmers are encouraged to use print statements to generate the HTML. True it is possible to implement templates in Perl (with more difficulty than in PHP) to separate code and HTML, but 90% of sample Perl code on the web doesn't do that.
        • PHP is secure. Perl scripts tend to have more security holes. This is because PHP has built-in a lot of the internal operations of dealing with web page requests and serving information.
        • PHP is easy to learn in comparison to Perl. It's easier to learn than C, Python, Java, and most other programming languages used in web development, for that matter. The Perl style of programming is unique, and thus not universally applicable to or from other programming languages. Accessing web form variables in PHP is straightforward, but in Perl requires either detailed knowledge of either HTTP header formats or one of many Perl CGI libraries.
        • PHP takes less "overhead" than Perl, meaning that PHP scripts will run faster than CGI scripts written in Perl, and you'll be able to handle more simultaneous users on your site. Benchmarking tests show time and again that PHP runs faster than other web programming languages. Check out these benchmarking analyses done by major computing magazines.
        • PHP code tends to be more consistent and modular than Perl.
        Humm... Some points are debatables, of course.

        Depends on the POV. If you're a programmer, sure Perl gives you better tools, if you're not biased. If you're just a wannawebpage newbie, things like lexical scoping with my, closures, map, grep, contexts and alike are things you can't imagine to be useful. You just want HTML escaping, mysql (and all other supported database drivers) all other tools you use stuffed right into the namespace of your mywebpage.php4.

        Sure PHP has bigger usages and *is* and *can* be professionally used. But in my view that's neither the majority nor the part that started this hype.


        Ordinary morality is for ordinary people. -- Aleister Crowley

        I don't know that it's a good or a bad thing; the point appears to be that if it's easier, more people will want to try it, regardless of whether it's better (or even acceptable). It's kind of like looking for your lost wallet under a streetlight (even though that's not where you lost it), because there's more light there. So, even though PHP may not be a good candidate for certain tasks, people may prefer it because it's easier to use for some purposes.

Re: The REAL reason for why they choose PHP over Perl.
by ForgotPasswordAgain (Deacon) on Jun 11, 2006 at 16:14 UTC
    If I were just starting out and wanting to just do webpage programming, I probably wouldn't start down the Perl path, either. Let's see, do I use a general programming language with a complex syntax, or a language tailor-made for making webpages..? Not really a hard decision, even.

    And why aren't you writing Apache C modules instead of using this lame interpreted language, anyway? Are you too lazy? Too dumb? :)

      We tried that. Too painful. :)

      Don Wilde
      "There's more than one level to any answer."
Re: The REAL reason for why they choose PHP over Perl.
by terryfunk (Sexton) on Jun 11, 2006 at 21:07 UTC
    I have been developing websites since 1995-1996. I used Perl in html page early on. It was great. In 2000, I tried PHP (it was all the buzz). I was excited at first, PHP let me slam together code in quick order. But not long after that, the new wore off as I noticed the lack of power PHP had and still does even at version 5. I still use Perl and it still amazes me with what I can do with it.
Re: The REAL reason for why they choose PHP over Perl.
by gunzip (Monk) on Jun 12, 2006 at 02:03 UTC
    The reason beginners choose PHP over Perl is due to Perl's dual blessing/curse, namely TIMTOWTDI and CPAN. The proliferation of Perl modules and umpteen choices at every juncture have resulted in very few focused books on Perl web development. Hell, many of the Perl community even distance themselves from the field of web development as if it somehow tarnishes Perl. Contrast that with PHP where the language is focused. Result: a plethora of PHP web development books aimed at all levels of ability. Perl never tried to compete with PHP as far as beginner mindshare is concerned. It was game over before it had begun.
Re: The REAL reason for why they choose PHP over Perl.
by xorl (Deacon) on Jun 12, 2006 at 16:36 UTC
    As someone who uses Perl, PHP, and ASP, I just want to say I agree with the learning institution's decision to focus on PHP, but not with the instructor's reasons.

    PHP is a tool for a very specific job, namely database connectivity with websites. This is the tool you can expect to use in the real world. Your other options are ASP or Perl. ASP is a MS solution and that's good enough reason for a lot of people to avoid it (it's also a good enough reason for a lot of people to use it). I find ASP to give me a headache, so I try to avoid it. Perl requires mod_perl and ePerl to get it to function similar to PHP. These are extra things that have to be installed and more places for something to go wrong and makes Perl not as well suited as PHP for this task.

    For a "web design" or "interactive websites" class, PHP is the correct language to focus on. For another class, say "programing for system administration" or anything without the word "web" in it, the Perl would be a much better choice.

    Perl is a jack-of-all-trades language, meaning it can do a lot of things at least mediocre or better. PHP is a specalized language, meaning it can do one thing really well, but not much else.

    Think of it this way...
    I'm a jack-of-all-trades. If given enough time, I can build a house from the foundation up to the roof and not have it fall down. However it will probably just barely pass the building codes. If I want the job right, I'll hire someone to lay the foundation, someone else to build the frame of the house, someone else to put the plumbing in, someone else to do the walls, someone else to put the shingles on, and someone to do the roof. All these people are specalists who do one job and one job extremely well. They however would be lost if they had to do another aspect of building the house.

    That's what PHP is. It does one job and does it extremely well, but it can't do anything else. Perl on the other hand can do a lot at least well enough to get it pass the inspectors.

    If you're going to be building websites, PHP is the tool you should use. If you're going to be doing something complex in the background, that's where Perl comes it.

      PHP is a specalized language, meaning it can do one thing really well, but not much else.

      Specialized languages are not necessary good at what they do. From the sounds of it, PHP might do its speciality better than Perl, but it could do it so much better.

Re: The REAL reason for why they choose PHP over Perl.
by qazwart (Scribe) on Jun 13, 2006 at 15:23 UTC
    Two parts to this question:

    Why use PHP over Perl for webpage design?

    I use to do Perl CGI scripting, but switched to PHP because PHP was designed for webpage use. Originally, PHP was actually a Perl script (which is why both languages look so similar and why learning PHP isn't hard if you know Perl).

    However, when I do non-webpage stuff, I still use Perl, and there are many times when I use Perl CGI scripting because the page I'm generating has so little static HTML code in it.

    As others pointed out, PHP has a lot of functions for webpage design. It has built in functions to filter out "dangerous" text from HTML code, and there is quite a bit of very popular software built via PHP. (Mantis BT, Joomla, most Blogging software, etc.).

    However, once you've stopped working with static webpages, Perl is a much more powerful language. I don't know of anyone who uses PHP for non-webpage tasks even though PHP can be executed directly from the command line.

    Part II: Isn't Perl out of date and no one is using it anymore?

    I blame the Python people for that one. I think Python people spend more time denigrating Perl than actually coding. Quite venimous stuff. According to them, Perl is impossible to read, it's not object oriented, it has too many operators, it's confusing, etc.

    I only worked on Python once, and it was basically putting a few lines in a Python script. I spent three hours on the task: Five minutes of writing the code, and then 2 hours and 55 minutes trying to figure out what Python was whining about.

    Seems like I committed the mortal sin of indenting the code with a tab instead of eight spaces. You see, Python uses indents to tell it which lines belong to which blocks of code instead of using curly brackets. A "feature" according to Python people. I haven't touched it since.

    I am learning Ruby which is very similar to Python. It is an interesting language, but not that well supported yet. However, Ruby on Rails is something that I believe is going to make a big dent in the PHP coding segment and is something every PHP coder should be learning.

    The problem with PHP is that it is extremely difficult to maintain in large sites. Your code is scattered all over the place, and gets hard to trace. Ruby on Rails takes care of this problem by providing a framework where the code and the HTML are separated. Also separated out are all the database functionality.

    As a bonus, Ruby (like Perl and Python, but not PHP) is a useful right on the command line. And, unlike Python, it isn't dependent upon the correct whitespacing. My big complaint is that it doesn't use curly braces. Instead, it uses the beginning block's keyword and the word end to mark your blocks, so VI's showmatch mode doesn't work.

      I blame the Python people for that one. I think Python people spend more time denigrating Perl than actually coding. Quite venimous stuff. According to them, Perl is impossible to read, it's not object oriented, it has too many operators, it's confusing, etc.

      I don't. Much of their arguments are legitimate, if you care about the things they complain about.

      Perl *is* a large, complex language; that's a statement of fact, not opinion. I once counted over 200 function call formats in perlfunc; that's a lot for the base language. What's more, each function call can be called in one of three contexts: and lots of people don't understand context right away. You have to memorize each function twice; what it does in scalar context, and what it does in list context, and if they are different or not.

      Perl does a lot automatically, in a lot of different situations, and until you memorize what shortcuts perl is taking, you won't know what it's really doing. Even experts here on perlmonks run code through B:Deparse to try to make sense of what's really happening with strange code.

      Seems like I committed the mortal sin of indenting the code with a tab instead of eight spaces. You see, Python uses indents to tell it which lines belong to which blocks of code instead of using curly brackets. A "feature" according to Python people. I haven't touched it since.

      Every language has it's "rookie mistakes". A long time ago, when I was first trying to learn perl, I wasted several hours trying to figure out why a simple pattern match wouldn't work. Turned out I was using ~= where I should have been using =~ : I'd never used composite operators before, and kept reading over the typo. I nearly gave up on Perl then, too.

      Python's forced indentation has a purpose; it eliminates indentation errors (which can be annoying to track down on your own), and it ensures that your code is indented in a readable format.

      I've wasted a lot of time over the years, in C and in Perl, running a search for a {, % match it, try to figure out if that's what it should match, decide it is, go on to the next match, iterate. I've actually started commenting end braces whenever I have to maintain code; not only does it give a bit more explanation as to what an ugly off-screen construct seems to do, it helps me resolve the painful "does this brace match what it should match?" question. Looking back on those wasted hours over the years, a little "use tabs for indentation" rule just doesn't bother me that much.

      It also neatly solves another problem; pretty printing. If some wingnut formatted Perl inconsistantly (2 column indent half the time, 4 the next, 8 the next), you've got to parse the entire language just to indent the code. Perltidy does a good job with a horribly complicated language ("only perl can Parse perl"), but it didn't exist for years, and took a long time to write.

      With tab indents, you just change the size of a tabstop. A ten year old can write a "tab to space" converter.

      Perl's philsophy is just different than Python's. Perl people tend to focus on initial code development: the perl motto is "there's More than One Way to Do it". Python people tend to focus on maintainance -- something more like "There's One Right Way to Do It: strive to find it".

      Depending on whether your do more coding or more maintenance, you may prefer one over the other...

Re: The REAL reason for why they choose PHP over Perl.
by strfry() (Monk) on Jun 14, 2006 at 01:32 UTC
    let me start this comment out right: i'm biased, and i know it. (:

    however, i think php has had such incredible use primarily because it takes very little time to get moderate results with php; as others have mentioned, almost every hosting provider has mod_php installed, so they don't have to really think about the backend. often, all a person has to do is find some code online, cut and paste it into their page, and whammo! results. similar to javascript - there's a plethora of it online, and very little to do beside emptying your mouse buffer into a file. heck, i met one particular individual who didn't even realize that php was not, in fact, an extention of server-side includes.

    myself, i like perl. when a friend who has a php driven site needs something done, i write it in perl and then integrate it into their site so that it looks 'natural' to their users. and in such instances, the two languages do seem to work nicely with each other.

    now, i won't go into the big argument of which is 'better' - as far as i'm concerned, that's a matter of opinion... and probably an argument better left out of this forum.


    strfry(reality)
Re: The REAL reason for why they choose PHP over Perl.
by aspeer (Initiate) on Jun 14, 2006 at 08:05 UTC
    The hook (I think) with PHP is that you can just take an existing static page, whack a few <?php .. ?> commands into it and instantly have dynamic content. Quick gratification is a powerful inducement to continued usage ..

    Also, even though code and content are mixed, in PHP it is relatively easy to see where one stops and the other starts.

    For a long time with Perl we had to embed HTML into scripts sprinkled with CGI.pm calls to get dynamic output. Often it ended up as a mess of <<HERE documents, endless print statements, or all of the above.

    Things are different now - there is EmbPerl, HTML::Mason and a multitude of other templating engines or frameworks.

    Notwithstanding that I still wanted that "instant gratification" of just inserting some processing commands or <perl>..</perl> tags and getting instant feedback.

    Plug on ..

    When I looked around I never found anything that met that need - so I created my own. Yes, "Yet Another Perl Framework". Once WebDyne (http://webdyne.org/) is installed it allows Perl code to be either embedded directly into a page, or called from an associated package. The tide will never be turned back, but I hope tools like mine, and the others mentioned, may at least give people who are proficient in Perl a reason to stick with it when developing web apps.

    Andrew

Re: The REAL reason for why they choose PHP over Perl.
by cybear (Monk) on Jun 14, 2006 at 17:33 UTC
    Instructors, particularly College profs, don't have any real work to do, so they get bored easily. They often have short attention spans anyway.

    I think that the real problem is that, without some real tasks to complete, the only thing keeping their minds entertained is learning new languages and/or techniques.

    - cybear

      Instructors, particularly College profs, don't have any real work to do, so they get bored easily. They often have short attention spans anyway.

      As somebody who used to work in a university I have a rather large urge to call bullshit on that statement :-)

        Seems that way on the ones that I'm familiar with. Most of them stopped being objective or effective when they began to get paid by a college, instead of needing to produce usable products in a competitive environment.

        This is certainly not true of all profs, but it does seem to be prevelant.

        - cybear

      While it is certainly true that some professors are timeservers, or that others have been sucked into the 'publish or perish' vortex, this seems a wildly unfair categorization. It has been some time since I was an undergraduate student, but I've been taking certificate classes lately, and I have often been deeply impressed by the passion and energy of the professors under whom I have studied. Sometimes things in the ivory tower are a little far-removed from the 'real' world, but I think you'll find that every niche has its blind spots.

      I certainly would prefer a professor who was interested in learning new languages and techniques over one who was stuck on what he or she learned 'back in the day'.


      No good deed goes unpunished. -- (attributed to) Oscar Wilde
Re: The REAL reason for why they choose PHP over Perl.
by exussum0 (Vicar) on Jun 14, 2006 at 19:44 UTC
    A complete php web application that involves php for say, hello world, is one line of php code. For perl, it's more complex because php hides a lot.
    <? print "Hi!" ?>
    vs
    #!/usr/local/bin/perl print "Content-type: text/html\n\nHi!";
    So there's two pieces of complexity. The shebang and the header. Want to refer to variables? In php, it's "easy".

    Perl is so modular, you can mix and match things to get a lot accomplished. You can create a module with your core logic, like in php, then reference it via soap, http, command line or corba... unlike php.

    Documentation for php leads people to realize, to call a php function, you just call it. In perl, you have the nasty import statement. oh noes!

    Then it starts to break down. php needs recompliation for postgresql access and other moduels. In perl, you need to do it as well, but you never have the false idea from the perl documentation that something pre-exists.

    Then you run into consistency issues. Perl is not innocent from this, since there's 100 ways of doing anything via modules, but perl is upfront with that. In php, there's usually one way of doing it and you have to find it.

    But to solve any of these issues and the others, php has momentum. Providers install a db, php and some core stuff, and you never need recompilation.. until one day it bites you. php has a LOT of people who will point you in the right direction, until the one day you can't do the one thing the way you want to. versus perl which is "too complex" from the getgo and kinda makes people think up front.

    There's a touch of sarcasm, and believe-you-me, I favour perl because it makes you think and gives you that flexibility w/o trying to do the web too-well.

      Comparing PHP to a Perl CGI install is a bit flawed. To more accurately show the difference, you'd have to be comparing it to something like mod_perl + Mason. Mason example:
      m <% print "Hi!" %>
      vs PHP's:
      <? print "Hi!" ?>
      Mason lets you embed in an identical style to PHP, the barrier to entry is due to installed code base with most shared webservers. You want popular forum software? VBB and PHPBB are both PHP. You want a Bloggity blog blog blog? Wordpress, Moveable Type (Edit: MT is perl, woo :) ) and pretty much every other blog outside of Blosxom are PHP. You want a CMS? All those nuke etc sites that aren't based off of the PHP forums are PHP, with the exception of Drupal and Everything engine(Actually Drupal may be PHP now, I forget - point still stands).

      I barely touch PHP, but run mod_php on my server due to all the other software that needs it(hosting friends sites and such). Unfortunately that precludes me from running mod_perl on the same server unless I have a high demand app that needs it. Running both simultaneously is only suggested if you enjoy using up all your ram. This also leads to me finding PHP equivilents to the applications I may prefer to have in perl, and jsut contributes to the problem. That, and laziness on my part for not coding more of it :p

      One day, I'll probably mess around with Mason again, as the last I checked they didn't have native mod_perl2 support, so I didn't get farther then playing with it. It's really amazing how it addresses everything PHP can do, while adding in new paradigms like init and argument blocks, alongside being able to include other files with said arguments.

      Random Examples of Mason awesomeness:
      Simple site with dynamic includes:
      <& ../check_auth &> <& ../header, title => "Welcome ".ucfirst(lc($user)) &> <& tabrow, active => 'main' &> <& ../iconcol, active => 'user' &> <div class="content"> Woo! Lookit me! I have content! (User/Main) </div> <& ../footer &>
      The header included in above site:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=IS +O-8859-1"> <TITLE><% $basetitle %></TITLE> <& css &> </HEAD> <BODY> <%args> $css => "main.css" $cssinclude => 0 $title => "" </%args> <%init> my $basetitle = "MasonTest"; $basetitle .= ": $title" if $title ne ""; </%init>
      Damnit, now I have to go play with this stuff again. :/
        Comparing PHP to a Perl CGI install is a bit flawed. To more accurately show the difference, you'd have to be comparing it to something like mod_perl + Mason. Mason example:
        Actually it's quite a fair comparison. As I've stated before, it grows incrementally complex, differently organized and has some user facing architectual differences.

        All you've shown here is a template system that uses perl, which php kinda is already as you've shown. But re-read my post. It's not about tempalting systems. It's ease of getting into it. Sure, I can install mason all over the place, but the subject here isn't just mason. It's perl vs php, where perl is a much larger subject than mason alone.

        Wordpress, Moveable Type and pretty much every other blog outside of Blosxom are PHP.
        Minor point: Movable type is written in Perl.

        The BAD thing about mentioning Movable Type is it is not free any more.. for 1-5 users you are looking at $200USD.
Re: The REAL reason for why they choose PHP over Perl.
by kabeldag (Hermit) on Jun 15, 2006 at 11:08 UTC
    _They_ choose PHP because they don't have beards or excessive facial hair. It's all about the hair. Did the instructor have facial hair ? I bet she/he didn't.

    In all serious though. I don't have extreme facial hair. And I picked up Perl myself (like most things), and a technical college I was at actually had a Perl class. Which I never was in, but attended and helped out at. The teachers were of a Unix/Linux background. I don't know if that holds any relavance. But one thing is for sure. Most *nix people like, and know the many purposes of Perl.

    It's a System Admin, Web, and almost -everything else- language.I can't see myself ever using PHP for any of the things that I want or need to do. That includes web page creation.

    Perl old. No longer in use. Somehow that doesn't seem right.

    use Perl or die;

    ++ END OF MEANINGLESS RANT ++
Re: The REAL reason for why they choose PHP over Perl.
by simon.proctor (Vicar) on Jun 15, 2006 at 11:57 UTC

    Taking the "old" argument I recall a director of mine refusing to use Java because (at the time) it had only been around for three years so hadn't had long enough to become stable.

    I wonder, sometimes, what makes a language old. In my thinking, a language is old when it no longer allows you to do what you need to do to get paid. Or it does but in a very odd and costly manner.

    The fact that Perl has been around for a while doesn't make it old. It just makes it tried and tested. The same is true, then, for C, C++ (yada yada yada). Note - I didn't say bug free ;)

    Again, a personal view, but I tend to think people consider things as old because they aren't in the buzz hilights of the moment. Or in the top ten magazine headlines of your chosen field.

    A good example is a co-worker of days gone by who immediately declared that now we had .NET we no longer needed C++ and could ditch it. C++ (in his eyes) was old.

    Frankly though, I dont' really care. You don't want to program in one of the languages I get paid for . . . all the more paid opportunities for me.

Re: The REAL reason for why they choose PHP over Perl.
by Zzenmonk (Sexton) on May 03, 2013 at 16:31 UTC

    Hi Spidy,

    Ask yourself what your school attempts to do? Learn you programming? Certainly not! If you are not convinced, have a look at Algorithms in C by Robert Sedgewick.(Warning: serious risk of headache!).

    Your teacher has only one goal: teach you just enough for you to find a job. And well! FB was initially written in PHP. Today it is most probably written in C but this does not matter. Your HR counterpart will never know about it and this counterpart decides about your future.

    This is the point: The HR department has to be happy with your curriculum, so it is PHP! Tomorrow it might be Ruby, TCL/TK, Python, Pascal, COBOL, Java, Assembler or even rod logic... whatever will make the HR departments of big firms happy.

    K

    The best medicine against depression is a cold beer!
Re: The REAL reason for why they choose PHP over Perl.
by Zzenmonk (Sexton) on May 22, 2013 at 16:25 UTC

    Hi Spidy

    The real reason why they choose PHP is because of it is a wonderful language which includes the following fabulous features: http://phpsadness.com/ ;-)

    Thanks to jellisii2 for this terrific link!

    Enjoy

    K

    The best medicine against depression is a cold beer!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://554630]
Approved by marto
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (14)
As of 2014-04-16 14:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (431 votes), past polls