Why I Love Perl
I just wrote a complete XML-RSS aggregator that pulls in data from 137 feeds that are in a MySQL table, parses each feed, adds new entries into another MySQL table, and then changes the first table's entries to represent the last fetch time, last processing time (if the feed retrieval was successful), and last update time (if there were new entries added to the other table). I accomplished all this over today while doing other things, likely spending less than three hours on the actual project, including time studying a legacy MySQL table to which I am trying to conform.
That's why I love Perl. I am not someone who just loves to program, but Perl makes things efficient and sensible enough that at least I can get what I need to get working done in as little time as possible. cough Unlike cough PHP cough.
More on just how this fits into yesterday's post later.
Tim, and what about Python? Do you think it is good as a Web development language?
Curious to see the code. given that php can also do regular expressions (haven't done Perl in a while) I'd like to see what Perl has to offer that PHP can't. No bashing, just curious. Its funny because I stopped using perl in favor of php for the exact reasons you like Perl.
different strokes I guess.
I remember being told that Perl is a great lang for “just getting things done” while PHP is when you want to keep doing them. Don't know if that's fair enough but I have seen it numerous areas.
Eduardo: I'm really not sure. I'm “functionally illiterate” in Python. Python isn't nearly as popular as Perl and PHP as a web language, though. Mailman is Python based, and quite nice, fwiw.
Mark: I don't know if I want to show my hodge podge.
Seriously, I'll show it to you when I get a little more done if you'd like to see it.
I use both PHP and Perl, but here are my reasons:
Anyway, that's why I'm not fond of PHP. I'd be interested in hearing your reasons for going away from Perl.
To begin, I've always looked at perl as a Text manipulation lang. I know that's an insult given its true power but that's been my usage in the past; for me it went with Gawk perfectly.
Given that I started doing dynamic sites using ColdFusion, which is known for its rapid design speed, I didn't look to Perl to develop sites. Please correct me if I am wrong but Perl tends to be single programs while php resides in multiple files. For me this allowed easy dev with many people. Again maybe it just comes down to style and being used to DOD large scale developement.
I also remember when I was sent for training for Javascript and the first thing the instructor told us was how to stop people from injecting perl scripts into a form in order to hack a site. So for me, perl was the tool that enabled people to cause trouble. And one of the reasons I have a function which strips certain chars in my comments form to avoid such issues.
I'm also coming at web development from a different direction then you; I'm guessing. Most of my professional developement has been done behind firewalls in a corp setting where security “tends” to be a none issue, on windows machines. Please correct me if I am wrong but I don't think Perl runs on Win while PHP can. (See easyphp for example)
So do I have anything against perl, no. I don't have anything against any lang, ok I hate Ada but that's for another post.
Well, you can develop with Perl pretty much the same way you do with PHP. For instance, this very blog has one front end script (for design reasons that aren't really relevant anymore), but all of the functionality is done by a bunch of different scripts that are “required” in and then sent on their merry way. Another one of my sites actually uses a bunch of different Perl scripts that are completely independent, other than calling on the same set of libraries, much in the same way PHP-Nuke or other php stuff is developed. I think it is mostly a difference in developer attitude — PHP developers are inclined to make more separate files, I think, since the original idea of PHP was to embed the code into actual web pages. A Perl hacker is more likely to think in terms of creating one backend script with a bunch of “masks” using the power of Apache mod_rewrite.
As I see it, the Perl way ™ is more like what you might do with C/C++, etc., whereas the PHP way ™ is a bit more like you might do with JavaScript. Perl “feels” almost like a compiled language to me in the way you do things. With Perl 6's Parrot, maybe someday it will be. Kinda hard to explain why I get that feeling, but…
Perl does run on Windows. That's actually where ActiveState got their start. MS paid them to port Perl to Windows. There are several other variants of Perl for Windows as well. At one point, when I was still running Windows, I had a fully functional Apache 1.3.x server on Windows 98 (and then Win2k) that had a full Perl install so that I could use it as a test bed for scripts.
I am coming from it from a much different direction. Partially, as a site owner who has had PHP sites cracked into due to some techniques I see utilized in PHP, and now also as a system admin that sees how hard it is to secure PHP on my server without crippling it. For example Gallery, my photo album tool, won't let me add new photos now that I secured PHP, since securing PHP requires removing the ability to run any type of *nix commands.
I don't dislike PHP… it is a bit easier to throw together a small site using it, although once things grow larger, I think it all equals out in terms of efficiency. For example, I can do Reg Ex and file processing much more efficiently in Perl (and Perl's LWP::UserAgent is absolutely amazing for implementing web crawling and XML::RPC stuff), but MySQL manipulation takes a bit more work in it — I usually include a subroutine that simplifies it to the level PHP has it at. Still, since usually I need some of all of those things in a big project, I probably come out about the same time wise. Given the caveats, I've stuck with Perl.
I must hear about Ada sometime.
I love perl because this past semester I took compiler. I was able to get everything in my compiler working in under 1000 lines with perl. The other people in the class that were using java were averaging something like three to four times as many lines of code…
As for php/perl, their both great languages and I use whatever makes since to use at the time. Though I often end up using php for web stuff because the ability to mix code and html saves time.