Is there anything that you lose by using Perl instead of PHP?
Let me preface this by saying that I'm pretty familiar with PHP; in fact, I've taught it professionally. I've also been working with Perl for a number of years; in fact, that's what I started with, while PHP (like a number of other languages) is something I picked up at a job where it was needed.
Now, as to what you lose: unresolved (and unresolvable) bugs in standard PHP functions would have to be #1, followed closely by the long-standing vulnerabilities at #2. You'd also be losing developers who appear to be deaf to the community that actually uses the language. You'd lose the security "add-ons" that protect the language from itself. Gone is the extraordinary clumsiness in handling variables more complex than a scalar, and inside-out weirdness in scoping variables. You'd lose the "ceiling" of PHP: once past a certain (low) level of code complexity, PHP just runs out of steam and can't go any further, while Perl has not such limitation (no blame here, really; PHP is intended to be a presentation-only language with minimal utility outside of that, but people try to push it way beyond that.) There's a bunch of other things, mostly annoyances, that would be gone.
As to positive bits - not much. Perl doesn't have anything quite as convenient as php.net's function lookup (e.g., http://php.net/trim for the 'trim' function) - but you'll have built-in documentation instead. It doesn't have the very nice "include/require" facility - which, in PHP, is (ab)used to create spaghetti code as often as not. But you can get all of those things, and much more, while still retaining all the goodies that Perl has, by learning one of the many templating systems available under Perl. This allows you to separate the presentation from the code - and you'll be amazed at how much clearer and easier this makes large projects.
I also have three general Perl questions: 1) Does it get complicated using lots of different modules? Is it hard to keep them updated? 2) Can somebody point me to a thread detailing how to import subs, like a library? 3) Have there been any problems or gotchas you have experienced or noticed which consistently occur amongst converts?
Modules, once you've learned the two basic styles (functional and object-oriented) are easy; when you look at the docs that come with it, the first thing that you'll (almost) inevitably see is an example of code using that module. Steal it. :) As to installing them, keeping them updated, and so on, the CPAN module (already installed with your Perl) makes that trivial.
How to import subs is part of the standard Perl documentation: just type "perldoc perlmod" at your command line, and you'll have a document describing all the semantics of modules, etc. For a general overview of the docs, see "perldoc perl".
For gotchas - not just for PHP, but for people who have experience in other languages who are just starting to explore Perl - I'd suggest checking out "perldoc perltrap". Well worth reading for the contrast, and as a reminder.
All in all, I think you may find Perl a rather liberating experience. The only way I can judge that, having started from Perl, is that working with PHP feels very constrictive to me these days...
In reply to Re: From PHP to Perl - Should I, and how?
by oko1
in thread From PHP to Perl - Should I, and how?
by salazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |