Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'll point out that moving from Perl to PHP is *very* easy.

Is it really? Perhaps you are right for simple web based stuff like a mail form, a simple database driven site or just templating. However, real programming isn't translated to PHP so easily.

First of all, what are you going to do with namespaces? PHP still does not have namespaces.

Then, what will you do with closures? PHP has no closures. Heck, it doesn't even have anonymous functions. That's another thing: how will you be rewriting that hash of coderefs? A hash of strings that are evaled at runtime?

And what about all those objects that aren't simple hashes?

But let's assume you didn't use any of these slightly more advanced programming techniques than the average PHP "programmer" can handle. But you did use modules. You do use modules, don't you?

PHP is a web programming language, so it must have a good HTML parser ready, right? One is available, but it cannot be called good. It cannot even parse processing instructions like, ehm, <?php ...?> itself.

Another common task in web programming is sending HTML mail with a few inline images. So what alternative for MIME::Lite do you have? The PHP-ish solution is to build the message manually. Good luck, and have fun.

But at least it can open files over HTTP. Yes, that it can. But what do you do if you want more than that? What if you want to provide POST content, headers, or implement ETags? Then, you must use Curl, which isn't nearly as convenient as LWP. Don't even think about having something like WWW::Mechanize in PHP.

Enough with the modules. I think I've proven my point that CPAN makes Perl strong. Now let's discuss the core. In fact, let's focus on something extremely elementary in programming: arrays!

PHP's "arrays" are hashes. It does not have arrays in the sense that most languages have them. You can't just translate $foo[4] = 4; $foo[2] = 2; foreach $element (@foo) { print $element } to $foo[4] = 4; $foo[2] = 2; foreach ($foo as $element) { print $element }. The Perl version prints 24, PHP insists on 42. Yes, there is ksort(), but that isn't something you can guess. It requires very in-depth knowledge of PHP. And that's the one thing PHP's documentation tries to avoid :)

Also, don't think $foo = bar() || $baz does the same in PHP. In PHP, you end up with true or false. So you must write it in two separate expressions.

Exactly what makes you think and even say moving from Perl to PHP is easy? It's very, very hard to un-learn concise programming and go back to medieval programming times. And converting existing code is even harder.

Juerd # { site => '', plp_site => '', do_not_use => 'spamtrap' }

In reply to Re^2: Is Perl a good career move? by Juerd
in thread Is Perl a good career move? by Mutant

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (4)
    As of 2021-04-17 15:11 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found