Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages and disadvantages of Perl for OOP?

Tags:

oop

perl

I was wondering how well Perl would perform for OOP based programming. What are the advantages and disadvantages of using Perl for OOP and if there are disadvantages, are there back-route ways of coding to code around them? Any information on what Perl is used for now — as well as how well a Perl Programmer could be paid in the future — would also be appreciated.

like image 931
Nate the Noob Avatar asked Dec 17 '10 13:12

Nate the Noob


1 Answers

OOP is not an end but a means to an end. Your question is so broad as to be practically meaningless.

If you write Perl programs that enable giant financial institutions to squeeze an extra few billion dollars of profits from their portfolios, you'll be paid handsomely.

If you write Perl programs that solve problems which are hard for other programmers to solve well, you'll be paid handsomely.

If you write Perl programs to process web based contact forms for simple web sites, you won't be paid as well.

If your programs implement encapsulation, polymorphism and composition well, they will be easier to understand, extend and fix than not. Which will give you an edge in getting things done better and faster, which will earn you a premium over programmers who throw things against a wall until something sticks.

Perl gives you freedom in how you create solutions. With freedom come risk and responsibility. Depending on your personality, that may be a good thing or a bad thing.

As for OOP:

  • Perl is succinct.
  • Perl does not require you to treat everything as an object.
  • Perl does not force you to use inheritance as the main mechanism for code reuse.
  • Perl makes using composition for code reuse very straightforward.
  • Perl's lexical scope and closures facilitate encapsulation.
  • Perl allows multiple inheritance.
  • Perl allows operator overloading.
  • With Perl, you are not restricted to using "the one true design principles" someone else decided a decade ago.
  • I am surely forgetting many many other pertinent bits.

As before, you are putting the cart before the horse. You should first thoroughly understand OOP without reference to any specific programming language.

For web applications, Perl gives you many many alternatives. Catalyst is a really nice framework. Dancer makes it easy to express your web application's functionality. Plack makes it easy to deploy it.

You decide how much of what OOP techniques to use with these frameworks.

I recently fell in love with the combination of Moose and Dancer.

Note: Given that you are just starting to learn, I would recommend (notwithstanding class assignments) that you not worry too much about language comparisons. Instead, open yourself to various languages. In this day and age, it is as easy as waiting for a few minute download to get started. When I first decided to learn how to program (slightly less than 30 years ago), paper and pencil was the only way I could write programs and I had to simulate the output of the program with paper. I know, I know, uphill both ways and all ;-)

So, experiment. Don't commit. You will understand the comparative advantages and disadvantages of languages by experimenting yourself. Try to write the same application with various different technologies. Make the task simple.

My first attempt at programming in Perl is still available online with warts and all. The reason I started with that was quite simple: I wanted to do something simple and something that would give me happiness.

Try something simple whose completion will give you satisfaction. Try the same thing with as many languages as you find interesting. Give Erlang a shot.

The job market will be different by the time you graduate from college. The best preparation for college is to have a broad understanding so you do not get bogged down in minutia but are able to complete assignments which others will choose for you.

like image 96
Sinan Ünür Avatar answered Oct 21 '22 15:10

Sinan Ünür