The Question: With the emergence of .NET, J2EE, Python, PHP, et. al, has Perl lost its niche as a scripting glue language? The Answer: Tim O’Reilly gives his two cents.
The Question: With the emergence of .NET, J2EE, Python, PHP, et. al, has Perl lost its niche as a scripting glue language? The Answer: Tim O’Reilly gives his two cents.
I still use perl for most anything console related. Partly because I dont know Python / Bash nearly as well. For me the separation occurs at web scripting. I used to use Perl all the time but since PHP offers such a speed differnce and syntax simplicity I no longer consider perl in that capcity.
It will be a long time before perl is sent out to pasture, but I can see why people think that it is impending!
-nX
it saw a huge resurgence as “the duct tape of the internet.”
It’s also referred to being built with duct tape.
A couple of years ago I was going to learn Perl, until I found Python. Python seems to be the new multi-purpose scripting language, with PHP being the tool of choice for web development. I don’t know much that isn’t possible between Python/PHP, the question is can Perl perform better than these two put together.
Alternatively, if you know Perl, do you need to know Python/PHP?
“Do what you will shall be the whole of the law.”
A. Crowley
A senseless quote from that Satan worshipping, brainwashed worm doesn’t deserve the effort it takes to type.
Perl is unique exampple of “comfortable language”.
Languages like PHP or Python are very good, but they are “ordinary languages”.
The difference is that Perl contains number (loads actually) of hacks that can confuse programming into thinking Perl is hard and inconsistent, but those hacks essentially speed up development of some things. Making some problems very comfortable to solve.
Easiest example of such hacks is m// and s/// in place.
My problem with Perl is all the syntax exceptions – all languages have these but when you’re programming in Perl, the code usually breaks more syntax rules than it follows. Maybe it’s just because I started off with PHP but I’ve never been comfortable with Perl.
If you haven’t been paying attention to
http://perl.com/pub/at/16
the Perl6 development is quite interesting.
They are using Haskell to rough out the language, and the Parrot runtime is coming along.
I, for one, can’t wait to see whether or not Parrot turns the JVMs and Mono into droppings.
You don’t NEED to know more than one of the three languages you mentioned (Python/Perl/PHP). Python can create web programs just as Perl or PHP can – in fact, with mod_python you can use python server pages that let you embed python code in HTML the same way PHP works.
Perl and Python do more than just the web. PHP just does the web. That’s why a lot of people like PHP for the web. They don’t have to worry about database modules and whatnot. Also, probably because PHP is supported by almost every web host.
Actually PHP does far more than just the web. This is a sample console script in PHP
#!/usr/bin/php -q
<?
echo “Hello, world”;
?>
The only odd part is enclosing all of your scripts in <? and ?>. In fact, there are GTK bindings to PHP, so you can use it to create graphical desktop applications. See http://gtk.php.net/
Ofcourse they can all do different things. I was referring to the fact that PHP isn’t ideal for most things that aren’t directly related to web development. Just like Python isn’t perfectly suited to most web development. However, if you know both, you have a language for general scripting, and a language for web development, both of which are perfectly suited to those categories.
Whereas Perl tries to be perfect at both. The question being is Perl better than Python at general scripting and PHP at web development?
Perl is quite difficult to learn, due to an over-abundance of features and an odd jumble of syntaxes taken from the languages that inspired it. PHP comes with a far greater standard library, and organises its features in more standard ways, than Perl does currently.
Further, both PHP, Python and Ruby provide clean frameworks for object orientated programming (though PHP only really caught up in version five). Given that all new programmers these days are though OOP, this is a major advantage. Perl currently supports – just about – a form of OOP; however it is so complicated that a lot of developers simply ignore it.
Basically, all the languages released since or after Perl 5 are better than Perl 5. However we will have to see what Perl 6 offers before it can be counted out. The author’s have talked about making significant changes.
Realistically though, Perl has lost a lot of developers since Perl 5 was released, and if they don’t offer some major incentives in version 6, they could find themselves being the next TCL.
Perl’s OOP is very good, and it is massively used, if you didn’t know.
Look at CPAN, most modules there provide OO interfaces.
Modules like DBI, CGI all provide perfect object oriented interface, as well as Net::LDAP, LWP, and basically everything I’ve touched so far.
Perl’s OO is, as everything in this language, is easy, simply-looking, unnecesary to use if you don’t need it, and amazely flexible and powerful, I guess it have features of which both Python and PHP don’t even think. Python is minimalistic, and PHPP is a reduced Perl, given that.
The GTK bindings for PHP are fairly new and experimental at this point. They’re not really practical for that sort of development right now.
What Tim said here is key:
> Languages then grow up, get computer-science envy, and forget their
> working-class roots.
The “Perl makes easy things easy” thing is what I use it for. For small stuff, you *could* use any scripting language really, but:
A. I already know some Perl
B. Perl is good enough
C. Using Perl is just a bit quicker than the alternatives. But only just a bit.
For anything bigger than a page or two, I’d consider turning it into a “real app” and writing it in Java.
i think perl fits better in small size, mostly console applications. like read a file, do some changes, process and save it. Or text processing intensive applications. it is used in more complex applications (like SlashDot site i think), but those are exceptions if you ask. i do not think it is proper for team developement, it seems more like a “hacker’s tool” . too easy to lost the track. Especially if developer skills are not equal.
Perl 6 cannot replace Java or .Net IMHO. they are too late, and there should be a really killer reason to chose it over others.
So now you’ll tell us that SlashDot, LiveJournal, all these perl forums are jokes and hacker’s tools?
Yes, I agree, java and .net pplay in different league, but Perl is on par and can beat PHP when writing just a Web site. Not an enterprise portal.
Perl is on par and can beat PHP when writing just a Web site.
That’s ridiculous. What proof do you have? Simply that Slashdot is a larger site? I won’t even get into the fact that Slashdot is super SLOW and often doesn’t respond when I try to post, etc. Yahoo, on the other hand, has written huge sections of their site in PHP on FreeBSD, and they always seem to be speedy. Also, new big website, like say, Blogger, are written in Python, which was obviously chosen OVER Perl.
I have nothing against Perl at all, but I hate it when people make mass generalized statements like that.
Seriously. How many of you have have come into a shop to find some nasty old Perl scripts hanging around that nobody wants to touch?
I love Python because you can grab a cup of coffee, fire up pdb, and figure out what the hell is going on in a particular piece of code before lunch. Even if it’s REALLY BAD code, Python “gets out of the way” better than any other language I’ve used.
Crappy programmers perfer scripting langauges.
Dumb people make dumb comments?
Or do you write a C++ code just to analyze a log file once a month and generate a CSV report?
yeah, there is cgi php, which is really nice for testing your php web application from the command line.
I write most of my scripts in bash, but I’ve used the php binary before and if you know how to program a php website, it’s exactly the same.
there is no never a need for ugliness or hacks in high level languages. for reasons of clarity, maintainability, security, and many more. and speed. yes speed also includes the time cost of trying to fix someone else’s badly formed code.
if you need speed then there’s no need for high level languages. so that’s a different question.
with the proliferation of languages and problem domains, the languages that will persist into the medium an dlong term are those that:
(1) clearly define their problem domain
(2) address their problem domain
(3) define sensibke constraints on their form
perl has never sought to do any of these in my opinion. c++ is also guilty of this too.
Perl’s OO is horrendous! It’s mostly a hack on top of the module system.
The only thing I actually like (a lot) about it is that it’s really, really easy to access the nuts-and-bolts of the class and OO system, which means you can write your own attributes module, etc. Unfortunately, this also means you actually *have* to write one — or use one from CPAN.
If you want to do good OO right now, I favour Ruby, CL or even O’Caml. I don’t agree that Python does it properly.
However, one of the side-effects to this which is probably going to make Perl6 lovely to work with is that all these language extensions/enhancements/etc from CPAN are written in Perl5, which means they can be easily played with and tweaked without having to go anywhere near a C-compiler, let alone the inner workings of Perl5 — kind-of like the way CLOS (OO for Lisp) was created, tweaked and tested and found successful enough to become part of Common Lisp.
I’ve also read somewhere that several of the CPAN modules that try to give you useful OO tools and functionality will be part of the Perl6 language.
Seriously. How many of you have have come into a shop to find some nasty old Perl scripts hanging around that nobody wants to touch?
I think that’s just the nature of scripts in general. I mean I’ve run into nasty scripts in every language. Especially quick and dirty stuff. Forget readability with anything that does a lot of text parsing with regular expressions. Trust me when you start banging out some really complex regex’s nobody will be able to read them quickly.
The trick to developing well in any language is to document your code and document functions, parameters and. I even make a point of documenting limitations of the program/script so 5 years from now. Even messy code that’s well documented is orders of magnitude easier to read than elegant code with no documentation. NO language is going to save you from that no matter how pretty.
Perl lets you do a lot of stuff with very little typing, but requires constant practice to stay proficient. A 5 line program might solve a problem in seconds, but take an hour to write and debug if you haven’t done it in a while. When some job comes up that could use Perl, I have to decide whether to spend the time to come up to speed again or just do it by hand in vim.
If I did use Perl all day every day, I’d still use Python or the like if a program got over a few hundred lines or was likely to have to be maintained. Perl’s sweet spot is the 5-10 line quickie.
I’ve long thought of Perl as being a very quirky language, written by quirky people, the very quirkiest of all being Larry Wall. And that’s fine for people. But not for languages.
When I’m trying to code, or figure out someone else’s code, the last thing I want is a language with a quirky sense of humor, or any sense of humor at all, actually.
So just give me my Python. With Python, The humor stops with the name. The language itself is serious, clear, and elegant, and that’s what I like.
Other’s opinions may vary. That’s just mine.
Anonymous (IP: 217.150.102.—) wrote:
> If you want to do good OO right now, I favour Ruby, CL or even O’Caml.
> I don’t agree that Python does it properly.
Please elaborate.
Through recent years I have seen a trend growing stronger where those languages and tools are noted “good” which are easier to learn by those who are new “coders”. Many of these languages have turned out to be quite promising, still, I never could convince myself that easily learnable languages could be better just because of the fact that lame newbies can quickly throw together some bug-full unusable crap which they can call software and themselves coders in a day. I think that it’s not always bad to have a necessary learning curve since it can teach the coder many things about the particular language. And on the other hand, quickly learning some highlevel language won’t make anyone a good coder in a night’s time. Not even a week. And if you know what I’m talking about you also know that having a strong basis knowledge can make one able to learn new languages very quickly and able to adapt also very quickly. Thus, the easyness of a new language plays a very minor role when judging its viability.
And with this I have arrived to the point where I have to tell that I think Perl is and has been one of the most usable and handy tools over the last very many years. It’s one of those scripting languages which I use for many years now on multiple platforms with great satisfaction. Of course, good coders always use the best tool for a given goal, and while Perl (as phyton, ruby, sometimes even php) can be used to solve quite a wide range of problems, there are certainly many areas where one’d better pick another tool, e.g. there’s nothing hard in coding a web server in perl or in phyton or in ruby, I still wouldn’t do it, unless explicitly wanted and paid for
Perl is a great languge, still I’d never compare it to j2ee or .net-related languages, even the idea seems wierd. I’ve also read recently some articles about ruby’s superiority and why it should be used and everything else dropped (including php), and I always came to the same conclusion: most of these people who write these “article” don’t know their subjects more than some ignorant nut gardner just released from an assylum trying to learn space eva security protocols.
I hope Perl will be a long time more around, and I’m happy that I have the tools (Perl included, among many others) which can sometimes make my coding life so much easier. I wouldn’t waste too much time in comparing apples to oranges, or to [uselessly] find out whether a crocodile is longer or greener ?
Programming languages are useless if they don’t have a good framework behind them. That’s why stuff like .net and even Java are the future. I don’t care about what language people use but i do care about the great framework that joe code monkey wrote in X language and i WANT to use that framework in my prefered language. I want to use the programming language that fits my style of programming and couple it with great libraries.
I was always a lisp guy, i also work with python and ruby. Instead of constantly looking for libraries to do X or Y, a new web server that supported my language or just something that is stable and not an hack that is constantly in alpha stage i jumped to .NET and stopped worring. I can develop my webpages with lisp, smalltalk, python, perl and asp.net. Heck, if i really want to, i can develop asp.net pages in PHP. I also can use python to develop JSP, servlets in java.
Programming languages are a commodity, use them on a system that is orthogonal to all other languages and stop worrying about libraries and alpha quality products.
For me its very simple:
– simple things: bash
– a bit more complex to very modular: perl
– web: php
I read a lot about ruby on rails, but everytime I start a project I ask myself why I should use other things, when I have a huge knowledge of PHP plus tons of libs, classes, etc.
Same with perl. I always try to find a reason to try out python, but whenever I need perl, I don’t have the time to learn something like python.
So what does python give me that perl does not? Same with ruby. What does Ruby give me what I don’t have with PHP?
CPAN is the reason people keep using Perl.
Nothing else comes close. NOTHING. Does Python even have an automatic repository access script?
I agree that the Perl6 progress is very troubling though. Why they are wasting time on Pugs is beyond me. All Pugs work should be taken out of the mainstream project work – they seem to be more interested in Pugs now than Perl6 proper. Its a stupid diversion.
On any system where you have regular software updates (which means almost every production box), using the automatic repository access script is a really REALLY stupid idea.
If you do, the next time perl gets updated every module you got that way will be broken.
I know Perl/PHP/Python like the back of my hand but have severely gone off PHP, even for small personal projects, due to speed and security issues (mainly due to badly-written libraries like XML-RPC and PHPLIB).
I love Python for cross-platform GUI apps, but for anything web/admin -related, I always use Perl, it just seems to make more sense, is more widely-available than Python and is a more secure than PHP.
Perl’s object oriented nature makes it easy to build complex scripts or manage obscure data sets. I wrote a generic object that automaticly creates accessor methods for me if they don’t already exist. This object with about 350 lines of code gets inherited into all my objects, so they don’t need complex constructor or clone methods, and it makes it easy to pass data around via these accessor methods.
So I hacked up about 1800 lines of code to have a web interface for managing a couple directories of files in a couple days. Wrote about 3000 lines of code to automate LFS. Having these generic objects makes it easy to change the API to suit my needs, so instead of wasting time dealing with someone else’s poorly designed objects I have my own. And these objects are self documenting with POD.
I don’t know what works for you, but Perl definitely works very well for me. I’m also interested in ocaml and C/C++ and maybe lisp or Python, but it will be a long time before I know any of them well enough to replace Perl, assuming they can…
If an object has a property that can be handled by a generic accesor, then it doesn’t need that accesor, and you should modify the property itself.
Accesors for their own sake are silly.
try ruby, automagic attr definers are builtin
Perl coding can be quite idiosynctratic (sp?), very difficult to maintain, especially if you maintain the code you didn’t write in a first place. Its philosophy of accomplishing the same thing by gazillion means (which is exactly opposite to Python) is somethig which makes the code difficult to read. Perl designers and maintainers? They look like a bunch of a happy idiots, just enjoying themselves being the members of Church of St. Larry Wall. From my experience of implementing large Internet performance collection system, as a mix of C and Perl: you choose the Perl – you shoot yourself in a foot.
It’s a full language, people like to use it, isn’t that enough? Next please.
As a random guy, I know Perl much better than Ruby or Python than I’ve only browsed their tutorial.
So Perl *is* relevant. On a current project I’ve tried to push Ruby or Python instead of Perl (that we didn’t use finally, we used bash instead), the answer of my boss: no, too few guys know these language.
Now on the future, this may change soon:
-while I know Perl, I dislike it very much: Python and especially Ruby are much more eleguant.
-Perl6 won’t change this: from what I’ve seen it is as ugly as normal Perl.
When a big part of those who know a language hates it, if the competition becomes competitive (CPAN-like clone, critical mass of programmer) then Perl could become history *very fast*, and I hope it will be!
Rails is becoming a good niche for Ruby, it is hard to know if it is a fad that will disappear or if this is a seed from which it will grow..
Besides CPAN,.. it’s the docs.
Perl has the best docs I’ve ever seen for any programming language (and any software project I’ve used for that matter). The Camel book. The Cookbook. The online perldocs. It’s just really excellent technical writing, written by exceptionally intelligent people, and it’s fun to read too.
Good documentation is *so* important.
Ooh I dunno, PHP.net is excellent for docs of the central library, although filled with submitted code from crappy 14 year-old “programmers”.
CPAN to me is a good documentation resource, but how many times have you downloaded the source to see how it works because there’s not been enough in the POD?
Python documentation is still a bit thin on the ground, but the tutorials at python.org are excellent.
I hate to say it, but JavaDoc is probably the best – although with a language that obtuse, you need good documentation 😉
of mapping it’s syntax and standard libraries to the way I think about programming.
I hear lots of complaints about how Perl code is ugly, but if you want to write simple, elegant code in Perl, it is just as easy as it is in any other language.
Perl also has found a rather unique compromise between a language designed to acheive a set of goals, and an evolutionary process that has allowed it to adapt to new environments with ease.
Perl has a community of programmers that other languages fail to match – Because it is so accessible to the curious beginner programmer, with such powerful capabilities are exposed through such simple yet intriguing syntax – it is dead-simple to learn and takes a lifetime to master – there is always a new and challenging avenue to explore.
Perl appeals to those people to whom programming is not just an unpleasant job to be done, but to whom programming is an expression, a craft. There is More Than One Way to Do It, and you can do it your way with Perl.
Perl has failed to disappear simply because to know perl is, in the vast majority of cases – to love it.
I’m willing to bet that Perl will outlive Java. Java will be extinct/forgotten before Perl will. But then both will still be around long after I’m gone, so I don’t have to worry about losing the bet 🙂
CPAN to me is a good documentation resource, but how many times have you downloaded the source to see how it works because there’s not been enough in the POD?
Sorry for the confusion: I meant, besides the vast resource that is CPAN, the other major thing Perl has going for it is the great docs.
The online docs I was referring to were for the built-in stuff that comes with Perl. I don’t know much about the POD that comes with other modules.
Re. JavaDoc and POD — they seem pretty much the same to me, except that they have different syntax. I like the cross-linked html output of JavaDoc… though there’s probably a tool that does that for Perl too.