views:

2441

answers:

18
+17  Q: 

Is Perl worth it?

Hello,

My boss has decided to use Perl as our (preferably) single, main development language. For me, it just doesn't seem right. I'm asking on your opinion about it, as my feelings might be influenced by today's trends and the horrible syntax (coming from c/java background).

For me, specifically, after Java, I was shocked about the lack of a good IDE (like Eclipse), the syntax and the contexts, implementation of threading, etc. You know what I'm talking about.

What do you think? Am I just getting older, or indeed, Perl is probably not the right choice nowadays as a general-purtpose language for new developments?

+38  A: 

Perl is a very expressive language with a rich syntax. There are lots of ways to express the same idea in Perl, which makes it fun to program. Unfortunately, since your co-workers will inevitably find other ways to express the same idea, it is, in my opinion, sometimes difficult to maintain other people's code. It's also prone to ugly code and "stupid programmer tricks". But with discipline and coding standards, you can go far.

That said, if I didn't have 10 years experience with it, I would skip Perl and go straight to Python. It's just better at everything I stated as drawbacks to Perl.

Paul Tomblin
+1 for Python as a sensible alternative to perl
S.Lott
‘better at everything’ may be rather overstated, but certainly it has a more generalist appeal than Perl, which is more suited to being a ‘single main development language’ for all tasks — if you really *must* choose one of those.
bobince
@bobince - I changed that sentence from "better at everything" to "better at everything I stated as the drawbacks to perl". ie. stupid programmer tricks, ugly code, too many idioms.
Paul Tomblin
I wouldn't skip to Python if threading is important (re: GIL)... as mentioned by the poster.
draegtun
I would also skip Python and go to Lisp ;o)
Svante
I agree, unless you have legacy perl code you need to support, I don' t think now is the time to choose perl. I would recommend Python or Ruby as more modern alternatives.And as to the threading, the multiprocessing module is now available to bypass any GIL issues.
monkut
draegtun
re: Python Multiprocessing module - This is still new (comes in Python 2.6) and therefore still not a good reason to skip ;-)
draegtun
Strict policy with Perl::Critic will solve the "There's more than one way to fuck it up" problem. You can hook Perl::Critic into your version control commit script to enforce coding standards for example. If you're coming from the Java world, then you probably will feel weird about because it's about 10x less verbose.
singingfish
Preventing checkins is unwise in my experience. Better to run a smoke test with Critic on committed code; Test::Perl::Critic goes in your t/ directory with all your other tests and does the job nicely.
ijw
Yeah Python makes you more sane.
jpartogi
+8  A: 

Depends on what you're developing. Perl is great as a general-purpose scripting language. Used properly it can be easy to maintain. Much like C++, used improperly it can be a nightmare to do any maintenance. I probably wouldn't choose perl as the sole language for a large project, but then, I wouldn't tend to choose Java as the sole language for a large project either. Really, most projects require a mix of technologies to really be done right, and selecting one language as the only development environment seems a bit short-sighted in general.

tloach
+12  A: 

If you want IDE support, then have you considered EPIC

toolkit
+8  A: 

I'm a carpenter and my boss has just decided that we are now all to use a screwdriver to do our job.

All I want to say: Use the right tool for the job! There is no such thing as one tool to rule them all.

If Perl makes you happy, use it!

In my carpenter example: if all our products are ikea-style I'll probably be happy. But if I need to hammer nails...

thijs
+25  A: 

Learn to love CPAN.

jms
+36  A: 

We can't recommend a language if you don't tell us what tasks you'll be using it for. Perl is fantastic for some applications, poor for others.

As for the syntax, Larry Wall (Perl's creator) has described it as "diagonal" (in contrast to "orthogonal" languages). The syntax is designed to mirror the flexibility and expressiveness of natural language. Seeing code like next unless /foo/ can be slightly jarring at first but you quickly realize that it flows much more smoothly.

The other reason that people complain about Perl's syntax is that regular expressions are a first-class part of the language. What looks like obscure Perl syntax is actually a regex pattern without the (programmer) overhead of wrapping it in a method call.

Perl's concept of (list vs. scalar) context is unusual and AFAIK unique. It isn't right or wrong; it's just different.

There are IDEs available for Perl. For Eclipse there is the EPIC plugin. ActiveState has Komodo. Personally, I prefer to use a generic and configurable text editor for all my programming as I work in a variety of languages and prefer a consistent interface to a highly specialized one.

Michael Carman
mean Emacs :)
ZeroCool
+10  A: 

What are your boss reasons for using Perl? You don't mention any, but I suppose he came up with a couple.

As for your concerns, there are a couple of IDEs available, EPIC was already mentioned, but also Komodo although most Perl programmers seem to use vi or emacs. Coming from C, Perl's syntax is really easy to pickup, you start by writing "C in Perl" then learn more as you go along. Make sure you check out Moose for your OO needs, pick up a few books beyond the usual Learning/Mastering/Programming Perl, like the oft mentioned Perl Best Practices, but also Perl Testing (the Perl community has a VERY strong testing culture), and you should have no problem learning the language.

And when you figure out that most of the code you need to write has already been written and is available, searchable and easy to install, from CPAN, maybe you will even learn how to like the language. Or at least how productive it makes you.

mirod
+9  A: 

Perl is an amazingly good choice when you are writing a lot of "glue" that has to talk to a bunch of disparate systems or work with text.

In many ways, my favorite platform is CPAN. Perl just happens to be the language you have to use to pull together the modules in CPAN.

The ability to just 'get stuff done' by loading a couple of CPAN modules and talking to them is dramatic when you compare it to even trying to figure out the API for an equivalent chunk of code in a more traditional high level language like Java.

That assumes that in java/c#/c++ you can even find a library that does what you want, and that the maintainer of the library still actively maintains it and doesn't charge an arm and a leg.

A large part of that power comes from Perl's initially-strange-seeming 'do what i mean' semantics.

Edward Kmett
+33  A: 

Ugliness is only skin deep!

Give Perl a shot by trying one or more of the following...

There's plenty of beauty to fall in love with once you've scratched thru the surface. Have a look and make your own call.

/I3az/

PS. I've worked for a few companies now that decided on using Perl as their main development language. In all cases its been a successful decision.

draegtun
+1 for the reference for Moose.
Brad Gilbert
A: 

Perl as main devt language? If I was being ultra cynical (how unlike me) I’d wonder if that decision was made merely to keep the team in business till the heat death of the universe (*1)

Perl is maybe OK as a glue, or small utility language – but I’d still rather use Groovy. Or anything else.

I do think Perl is symptomatic of the ills of IT. A purely techie tool promoted to enterprise application development. A language which encourages terseness does not encourage simplicity, and KISS overrides (OO term, Perl developers please note (*2)) anything else.

And I’ve yet to meet a Perl developer who understands TDD (*3).

(123) Now, don’t get out of your hair, not trying to to be nasty, I just __hate Perl....

Chris Brooks
"If you put a million monkeys at a million computers for a million years, one of them would eventually write a Java program. The rest would write Perl" --anonymous
Steven A. Lowe
Duh, hopefully the rest would use Smalltalk. Anyway, I'm puzzled, have they finished writing Shakespeare or what?
Chris Brooks
"Perl frightens me. It looks like an explosion at an ASCII factory" -- anonymous
Steven A. Lowe
What does choice of programming language have to do with KISS (which is *not* an OO term)? WRT TDD, clearly you are hanging out with the wrong Perl developers.
ysth
LOL. How typical of a Perl developer, __overrides__ is the OO term...
Chris Brooks
_"And I’ve yet to meet a Perl developer who understands TDD (*3)."_Curiously I've had the opposite experience. I find Perl folk to be one of the more TDD (and testing in general) aware group of developers. Maybe it's just the folk I hang with :-)
adrianh
This response was paramount to reputation suicide :)
rjurney
Thanks for the update. I guess amoungst Perl coders you're _so_ right. But they aren't 'folk' I 'hang with'.
Chris Brooks
+1 to counter the haters.
Steven A. Lowe
+3  A: 

I heard a quote somewhere, and I think it applies. "If you make people think they're thinking, they'll love you; but if you really make them think, they'll hate you." (http://www.quoteworld.org/quotes/8707)

This hit me hard once when my boss wanted to use C++ for everything, and I was trying to slowly warm him up to the combination of C++ and Python. I was challenging my boss to think about things in a new way, and he hated me for it.

If your boss likes Perl, he's creating a Perl culture that you might not enjoy in the long haul. Don't fight it. Find a culture you do thrive in.

(the above is stated in absolutes, but it's really just a weakly-held opinion.)

Jim Carroll
+4  A: 

The only issue with Perl, compared to something like Java, is Perl offers more freedom, its easy to do the "wrong" thing, its harder to throw an inexperienced programmer at a problem and expect them to come up with a nice solution.

That being said, there is no reason why you can't do great things in Perl, but if you are new to this road, I'd highly recommend getting everyone in the team a copy of Perl Best Practices, and making sure you always run perlcritic and perltidy over your code. This will help to keep everyone writing in a similar fashion.

Matthew Watson
+4  A: 

Some other gurus on OS thoroughly explained their opinions on Perl yesterday and convinced me to start on it a bit early. As explained by Brian, a lot of people bash on Perl for horrible syntax, but the syntax is only as maintainable as the developer makes it. You can make Perl code just about as elegant as any other code, people just get a different perception when they see somebody make a small obfuscated statement. Having obfuscation competitions in Perl specifically doesn't help the image either, but eh, what can ya do. My one recommendation for you is to pick up the Camel though. You'll know what I mean when you see it =]

John T
+21  A: 

Is Perl worth it?

Absolutely. Here's just a few reasons:

  • CPAN - is the most comprehensive open source code repository of any language
  • Conway's "Perl Best Practices" - have solidified Perl coding standards (see Perl::critic on CPAN)
  • Moose - a meta object protocol for Perl means much of Perl6 OO is available now
  • Here comes everyone - Perl has a long but thankfully low learning curve. CPAN contributions will continue apace as even more programmers reach the CPAN-end of the curve.
  • Perl6 - is designed to become the lingua franca of computer languages (http://pugscode.org). Larry Wall has synthesised the best features of all other programming paradigms (functional, OO, logic, static, dynamic, concurrency etc) into one language.

I predict in the next couple of years Parrot (the Perl6 virtual machine) and other Perl6 implementations will be released - so starting to learn Perl5 now helps you to prepare for Perl6.

In my opinion Perl is the most valuable tool in any programmer's toolbox.

Newbie Git
+1  A: 

Perl is the best scripting language out there. even better than Java if you ask me.

zamfir
-1: java is not a scripting language
Steven A. Lowe
Perl **is not** a scripting language.
Brad Gilbert
+18  A: 

For years I read a lot of "obfuscated" Perl code. I really had trouble figuring out what was going on. Then one day I stumbled over the work of a real Perl programmer. The code was understandable, well-documented, and as a result easy to maintain.

He had a personal Perl process that used a coding standard, consistent style.

This reminded me that good programming is more about the programmer and less about the language.

DanM
In much the same way, I challenge you to read any non-programming Excel user's macros.
ijw
+4  A: 

I honestly think the language you use is a minor consideration in the grand scheme of things. I ever wrote a blog recently about this subject which covers my feelings pretty completely: Why the programming language you use should be the last thing you worry about

My first real programming job was at a Perl shop. I didn't even know Perl when I started and most of my experience prior had been in C/C++. I continually bitched and moaned about the lack of an IDE, the loose typing, and various other things I thought sucked about Perl.

But you know what? We pushed out an amazing amount of code and supported a huge number of users with an incredible performant system. My subsequent time with Java and .net really makes me appreciate the benefits a 'lightweight' language like Perl has to offer. Of course, we we working within a well-thought out object oriented framework that mirrored much of what was done subsequently in the Java world (and had been created when Java was still painfully slow).

Sure, a lot of Perl is hacky scripting, but if you do it right, it works just fine. I don't think the decision to use Perl or another language (unless it's something silly like assembler) is going to make or break any project, provided you put some real critical thought into the work you're doing.

That said, I still prefer programming in Java. But sometimes I actually find myself missing Perl.

Zac
+1  A: 

Here are some thoughts I had while reading through this.

It's all about productivity.

If you have programmed expertly in Perl for 10 years, in Python for 10 years, and in Java for 10 years, then you'll probably write your program in Perl because you'll complete the program faster, the program will have fewer lines of code, and the language will stay more out of your way.

If you are not an expert in Perl, Python, or Java, and you have to choose one of those languages, then I recommend that you choose Python. You'll become proficient with Python a lot faster than you will with Perl and Python is far more concise than Java.

The following line of Perl code works exactly as you see it. You don't have to wrap it in a method or a function or a class. You don't have to compile it separately. It doesn't need any external modules. You can just run it.

@a= grep {/9$/} map {$_ * $_} (1..50);
say scalar(@a), ": ", join(", ", @a);

The above code counts the numbers between 1 and 50 (inclusive) that have squares that end in the number 9. It then prints to the standard output the count followed by the comma-separated square values. For someone who's been programming Perl a long time, the code is actually easier to follow than the English description in the two sentences that precede this one.

I'll leave the Java version, laden with boiler-plate code, as an exercise for the reader.

To some degree, the success of Perl probably relates to the extremely high productivity of a Perl expert compared to the productivity of a C/C++/Java/C#/Etc expert. This productivity translates into a real advantage for businesses. Python and Ruby also give developers enormous productivity gains compared to other more wordy and more restrictive languages. And they're much easier to master than Perl.

--Donnie

Donnie