in reply to Re: Is Perl a good career move?
in thread Is Perl a good career move?

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' }