tags:

views:

992

answers:

12
  1. At first, I was doing C (2 years).
  2. Now, I am doing PHP (1.5 years).
  3. My boss wants me to learn Perl now. He says the company is going to have many Perl projects now and he need me to do it.

How complex is Perl to learn in my case? Should I clearly say no to him OR should I give it a try.

Edit: You all asked why I would say no to a learning opportunity. Because whenever I switch to a new language, many months are lost in learning it to a standard where I can say, "yes I know this language".

And as brian d foy said:

You might learn the syntax quickly, but that's just the very basics. Learning a language is a lot more than learning syntax, and learning a dynamic language makes that even more so. You can program in Perl as you do in C, but that's ignoring most of Perl's power.

A: 

Perl is similar to PHP, so I think you will not have much trouble learning the basics.

Kevin Panko
It's similar to PHP in that they both start with P. Some of the syntax looks the same, but that's about all they have in common. Don't try to program Perl like it's PHP. :)
brian d foy
I agree, PHP is practically based on Perl. Not true, Brian d foy - they share a lot of functions names and concepts. PHP was inspired by Perl in a large part... check out the history. It's just that Perl is much more powerful than PHP, and more sophisticated, and better designed... in my opinion.
Alex JL
Sharing function names isn't that big of a deal. You can give Lisp the same function names, but that doesn't mean it's a similar language. If that's the level you're looking at, most things can look similar.
brian d foy
Yes, Brian, I know there are many differences. That is why I mention "the basics." Someone familiar with PHP will be able to jump into Perl and be productive fairly quickly.
Kevin Panko
+4  A: 

It's not bad until you have to support somebody else's legacy Perl code :)

Honestly though, it's kind of a fun language to master. Years ago I considered myself something of a Perl ninja, but it's been so long that I've fallen out of practice. Start with the llama book and go from there. There's a lot you can do with Perl, and a hundred different ways to do it. (That's part of where supporting somebody else's code becomes a hassle... they do things differently than you would.)

David
Sometimes it's not bad until you have to support your own legacy code. Looking at the stuff I wrote in 1995 is kinda painful, not because it's cryptic but because I was such a Perl dumb ass back then :)
brian d foy
@brian, that happens with everyone. Every year I hate the code I wrote in the previous year.
shamittomar
Actually, it doesn't happen to everyone. I've been in enough code reviews with other people to know that a lot of people aren't embarrassed by anything they wrote and will defend it to the death, mostly because they can't ever admit they ever did anything dumb.
brian d foy
+2  A: 

Even as a beginner you will quite easily get into Perl. It is very very flexible and allows multiple approaches to a problem.

One drawback is that because of its unbelievable flexibility you can have very hard times maintaining the code someone else has written. It is because Perl kinda allows you to approach a problem your personal way just the way you think rather than dictating a way to solve it.

Perl is extremely powerful if used correctly. It's spectrum is very broad.

You can take a look at the already written and freely available modules which you can simply incorporate into your project. Most of the time you can solve more than half maybe the complete project just by using what the CPAN provides you. Here is a link to the CPAN search.

Go for it. You won't regret.

EDIT: One more thing you should know about Perl. You can run Perl scripts on Windows too. ActiveStates ActivePerl is a good tools for that and it's PDK (Perl Developer Kit) allows you to create executables packed with all necessary libraries in it. This is sometimes is quite handy.

Octavian Damiean
CPAN. This is a good headstart.
WhatIsOpenID
[Strawberry Perl](http://strawberryperl.com) is also a good option for Windows.
brian d foy
Agree with Brian - I have been really happy with Strawberry.
Paul Nathan
Strawberry now is better than ActvePerl and PAR::Packer is free unlike PDK.
Alexandr Ciornii
Strawberry with Padre http://padre.perlide.org/ also make good combination on windows
ppant
+16  A: 

Perl is easy to learn. There are lots of online resources as well. Your background in C and PHP will be of help to you while learning Perl. Some resources to learn Perl:

Apart from online resources, there are many books which will help you learn Perl. For example: Learning Perl.

If you would like editors, checkout Padre or Kephra.

Try to get a copy of Perl Best Practices, which will help you develop good coding style.

Enjoy Perl! :-)

Alan Haggai Alavi
Perl borrowed heavily from C, and PHP borrowed heavily from Perl. The OP has a good foundation for leaping into Perl.
mobrule
OK. If you say it's easy, I will give it a shot. But I heard it's hard. Why do people say it hard :-/
WhatIsOpenID
No clue. I have always enjoyed Perl, which is what got me started with PHP.
Brad F Jacobs
@WhatIsOpenID It is only hard to maintain/debug code witten by someone else that's it. Learning Perl is quite easy.
Octavian Damiean
Perl is "hard" because people have to figure out how to operate the sigils, references, and the array type. Sigils: Scalar $ is easy, a list is `@list`, a hash is `%hash`, but a scalar in the list/hash is `$list[1]` or `$hash{foo}`. Arrays/lists: Most people are used to dealing with what (in Perl) would are *list references*, and Perl's naked lists and arrays are less "contained". E.g. `@a = (@b, @c)` puts all elements of @b and @c together into @a; they expect instead something like `$a = [\@b, \@c]` which is a listref with 2 listrefs in it).
fennec
I found that learning other languages was hard because they *didn't* have sigils. The point of the special character is to partition your variable names from the keywords so you don't have to know all of the language to choose a name. :)
brian d foy
+1  A: 

It's quite a bit easier to write good code in Perl than PHP, IMO.

There aren't a lot of current tutorial resources on the 5.8+ release series. Most target early Perl 5 (e.g., 5.0001), which is considerably cruftier than, say, Perl 5.12.

Perl is very good for working up code quickly and straightforwardly. I find the semantics usually intuitive. Typically I find that Perl doesn't scale well for me after several thousand lines. But, most Perl I write is shorter than that so it's not an issue. =)

You can also think of Perl as PHP + C and you won't be too far off.

Paul Nathan
@Paul - if you stick to proper software engineering standards, Perl will scale fairly easily. Among the things I'm currently maintaining are a couple-K C++ program that's impossible to read/comprehend, and a Perl system with at least 100k LOC that's a breeze. It's a lot more to do with the developer's skills.
DVK
@DVK: I'm not sure exactly why I find this. It's not that I don't document or modularize; it's just that other languages seem to scale better for me (in maintainability/understandability) than Perl. Arguably that simply indicates *I* shouldn't write large-scale Perl. *Possibly* that is more an after-effect of the early design choices of Perl as a simple scripting language. I'm not actually sure. Out of curiosity, what does your Perl system do? (bioinformatics, build systems, etc?)
Paul Nathan
@Paul - a large chunk of a trading system at a big financial company. Also, do you have any specific patterns/solutions/approaches that you can use in other languages that you find missing in Perl? (you might post those as specific SO questions for education of all, AND get better Perl experience for yourself)
DVK
@DVK: One of the big frustrations is dynamic variables and typingmismatches (e.g., I alter a hash field layout and down the road ararely used function that uses the previous variant calls it andsuddenly dies because it can't access the hash field). Another one isnot being able to trivially create structs ala C#/C++ without havingto redeclare package namespace. Another one is that libaries aren'tstatically linked and thus deployment on arbitrary machines can be anuisance. Another pain is the side-effected variables ($_ forexample).
Paul Nathan
Arguably this is because I havn't embraced writing 1000s oftests or w/e, but again, these are are not issues with someother languages. Some might say that *I* am the problem and not having experienced Perl enough and so forth, and that might be true.Arguably these frustrations are avoidable by extra-super rigorousattention to detail, but compiled languages don't seem to have thisproblem. I could go on, but, eh. (I'm not good enough at haskell/F# toquantify dynamic type-inferenced languages in this fashion). Pleasedon't get me wrong, however. Perl is my preferred scriptinglanguage.
Paul Nathan
@Paul - I think that most of these can actually be addressed in idiomatic way (some, I have done myself)... Ask them as piecemail questions on `[Perl]` tag and see what you get for answers (I can probably take on some of them as well). If you decline, I might turn them into questions myself later on as they are definitely worth asking and being answered for the community
DVK
Compiled languages have those problems. They tend not to compile though, if they are the type-checking sort.
brian d foy
+4  A: 
  1. Learn Perl.
  2. Make your boss happy.
  3. ????
  4. Profit.
shamittomar
yeah... profit.
WhatIsOpenID
+2  A: 

Perl's killer rep stems largely from:

  1. It gives you a large number of options for doing stuff. You'll see things that would be elemental components of syntax in other languages that are optional in Perl.
  2. Perl loves side effects -- special magic variables that get set by a given operation, or that serve as a default parameter for a given operation, that you'll never know exist unless you have the documentation in front of you.
  3. Perl has a nasty habit of encouraging golfing, of attempting to accomplish your task in the fewest keystrokes possible.

Add it all up, and you have a language that is indeed difficult to maintain; you'll learn to hate other peoples' code. Just as they will hate yours, unless you're meticulous about maintaining readability. (Which is actually a very good idea.)

But learning it? Especially with PHP in your bag of tricks? Unlikely to be a problem. It's a very usable language.

BlairHippo
Golf should be avoided in production. Golf is after all, a /sport/, not so much a commercial product.
Kent Fredric
perlcritic helps writing better code
Alexandr Ciornii
+7  A: 

Here's my completely subjective answer:

  1. It's always a good thing to learn a new programming language. If your employer pays you to learn a new language, you should do that. This comment is completely independent of whether it's Perl or Prolog or Haskell or whatever.

  2. Perl is just another imperative scripting language with a cryptic sigils, $ or % or @. It won't take you much time to learn it if you already know C and PHP.

  3. Perl has a big community, so there are excellent online/offline resources to learn new tricks.

So, why don't you just jump in and give it a try?

Yuji
You might learn the syntax quickly, but that's just the very basics. Learning a language is a lot more than learning syntax, and learning a dynamic language makes that even more so. You can program in Perl as you do in C, but that's ignoring most of Perl's power.
brian d foy
@Yuji, I agree it's good. But on the topic of "Perl has a big community". It still has only 6607 questions in comparison to 57925 of PHP. Why so? Are there lesser Perl problems or lesser Perl answerers?
shamittomar
It not that there are *fewer* Perl problems, just a lot more places besides StackOverflow to get help. Perl has Perlmonks, a site much like StackOverflow, that has existed for over a decade already. There are also hundreds of Perl user groups, Perl mailing lists, etc, etc already there to help Perl people. One of the nice things about StackOverflow is that other technologies without strong existing communities now have a place to gather.
brian d foy
Maybe I should've said Perl "has had" a big community. It predates Stack Overflow, predates PHP, and perl 5 has been almost feature frozen for the last few years. I think it's just that every conceivable Perl5 question has been answered in the 'Net which makes it unnecessary to ask questions here in SO.
Yuji
Yeah brian gave the same answer as mine while I was writing :p
Yuji
@shamittomar :there might be a variety of factors,some of which are: A lot more newbies are doing PHP => lot more of PHP programmers are liable to ask questions than Perl ones; Perl is more mature and has well established resources already if one's willing to Google. Also, there are technical factors (there's a LOT of MySQL questions also tagged PHP because many people somehow don't see the the difference), ditto with web programming related questions which are not strictly speaking PHP specific and which in Perl land are more liable to be labeled explicitly as html/css/js tags without Perl.
DVK
@Yuji: Perl 5 has been far from "feature frozen" in the past few years. I think it's just the opposite: they are adding features too quickly for most people to pick up on them: http://www.effectiveperlprogramming.com/blog/category/perl/new-features
brian d foy
OK brian, that shows how I'm left behind :p
Yuji
shamittomar: Perl has good books. And big community means that there are other good sites like Perlmonks and whole IRC network, so many questions are answered there.
Alexandr Ciornii
+35  A: 

Learning Perl is usually as hard as you make it. Some people can't get over the fact that it's a different language so they try to do things like they would in a different language.

Your ease of learning will also depend on how you decide to learn it. There are a lot of bad tutorials and books out there that guess at some things in Perl. There are really only a handful of concepts that you need to know, but if you don't pick those up you're going to have a lot of pain. Most tutorial writers seem not to know those concepts. Of course, I recommend my book Learning Perl, if not live Perl training from an expert whom you can ask questions and get some guidance. It's very important to not be lead astray from the start. With a good foundation, you can branch out on your own.

A lot of people think learning a language means learning the syntax, but that's just kindergarten. You really need to learn the libraries and tools of a language ecosystem. Perl is mostly popular because of everything it has despite its syntax, including a very dedicated community. You aren't going to learn that stuff from books (although I try to impart some of that in Mastering Perl and Effective Perl Programming). That's mostly a matter of experience.

If you're doing PHP, I might infer that you are doing web stuff. In that case, check out Catalyst. It might not be the Perl web framework you end up using, but it's a good place to start if you don't have an existing preference. Get the Apress book, not any other one.

However, it's probably pretty dumb for a company to take a bunch of people who don't know Perl yet and make them into a Perl shop quickly. I've worked for a few companies that would lie and cheat to get business then scramble to develop the skills they needed to do the project. That's a pretty dumb way to run a business because almost no one likes working in that environment.

You really need someone who's familiar with the landscape to really use Perl (or any language) effectively. You might be able to find a Perl mongers group near you where you can find some experienced people. Find some Perl friends and get to some Perl events if you can.

Perl is a great language to know, but if your boss is expecting a proficient Perl team pumping out solid code in a month by starting from scratch, he's probably moonlighting as one of the characters of FantasyLand.

brian d foy
Most complete answer on the thread.
shamittomar
+1 for mentioning the libraries/ecosystem as being more important than the language.
Marc B
Good to get an answer from author of Perl books. SO is a good place. Accepted your answer.
WhatIsOpenID
Among the 100+ programming books I have read over the years I think Learning Perl is one of the best regardless of the language.
Copas
+3  A: 

You may find this comparison chart helpful on the Hyperpolyglot - Programming Language Reference Sheets website (and fortunately PHP & Perl are in the first two columns).

Also you may find this question on SO helpful: What are good books for learning Perl? and perhaps this SO answer

/I3az/

draegtun
That chart is awesome.
shamittomar
+2  A: 

I also hesitated in learning Perl. My reason was the proliferation of sigils ($, @, % etc). Having learned that there is a context for using each (e.g, using the scalar $ to access an element in an array (@)) did not help either.

However, using things like the PLEAC, as well as the O'Reilly nutshell book helped me.

I also rely heavily on Perl::Critic, to know that I'm going down the 'best practices' road.

Scott Hoffman
Stay away from the Perl code in PLEAC. It's really dated in terms of modern practice and current standards. It was good when it was good, but that isn't now. :)
brian d foy
Perl-Critic on the strictest level is a good way to learn things. Its insanely strict, but often its a good idea to follow its recommendations unless you're certain you know better.
Kent Fredric
+2  A: 

Since you already know how to program, and you just need to learn Perl, I recommend skimming the Modern Perl Book which provides a good overview of how modern Perl programmers code and the concepts they need to know rather than just focusing on syntax so you can get an idea for yourself about what you're going to want to cover. It's currently in final draft form, and can be read online http://www.modernperlbooks.com/mt/2010/06/modern-perl-the-book-the-draft.html

Mark Fowler