Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Perl - Is it an OO Language

by Abigail-II (Bishop)
on Aug 27, 2002 at 09:22 UTC ( [id://193107]=note: print w/replies, xml ) Need Help??


in reply to Perl - Is it an OO Language

I don't think it's right to call a language OO if it supports inheritance, abstraction, polymorphism and encapsulation. You should judge how easy it is, and how easy it is to do it right.

You can do all four in C and Pascal, but most people will agree those languages shouldn't be labelled OO. In Perl, it's easy to make something that smells like OO. It's easy to make something that has a variable left of an arrow and a method to the right the arrow. But that doesn't mean you have done it right.

You can do inheritance, abstraction, polymorphism and encapsulation right in Perl. But it's surprisingly hard in Perl to do all four right at the same time. You have to do most of it yourself - the language isn't helping you much. In fact, it tends to work against you. You won't find the right way in the documentation, that just shows you the quick and dirty (wrong) way. It's every (wo)man for him/herself, making it hard to use or understand someone elses code.

If all you care about is writing quick glueing scripts, this OO mockup works handy-dandy. Just as GURU_01 says. But to do it right, Perl is just one small step above C.

I won't call Perl OO for the same reason I won't call Perl a functional programming language. Not because it's impossible to do, but because the language doesn't give you enough tools to make it easy.

Abigail

Replies are listed 'Best First'.
Re: Re: Perl - Is it an OO Language
by krisahoch (Deacon) on Aug 27, 2002 at 15:20 UTC

    This is the answer I was looking for.

    I posed BrowserUK's bullet points to GURU_2. He then showed a Java example to me while outlined the four tenents he described in one section of code. It was 6 lines total and they were all easily read. Over the course of his demonstration he also said nearly verbatim what Abigail-II said here, and what ignatz said as well.

    ++ Abigail-II, BrowserUK, Merlyn, ignatz, Zaxo and others for your insight and help

    Thank you very much,

    Kristofer A. Hoch

      I draw your attention to charnos and merlyn's points above how even Java has jumped out of the "OO paradigm" to satisfy its own necessities.

      I find it fascinating that Guru_2 can write 6 LoC in java once you've done the importing and class declaration is there really that many lines left ;)

      Jokes aside, of course the lines of java was easy to read, many of the shortcuts in Perl do make the code less readable but removes unnecessary lines in the process and the readability over effeciency is a whole different debate that rages on.

      I would like to point out though that on the whole perl is run from the script and would ask you to try and read the java .class file that the computer compiles. Alternatively look at the tremendous number of issues surrounding a Java JITC (Just In Time Compiler), as many of these are memory inefficient and would quite hapily get kicked from pillar to post by perl. Don't get me wrong I find programming in Java fascinating and enjoy using it for different things, you could sit here forever pointing out the pro's and con's of each language when compared against each other.

      Do something unholy and post the lines of Java up that GURU_2 used in his example, and see what people post back with for a perl equivelent.

      --pray.

        Personally I find that given a little effort, you can balance Perl's brevity with readability. Certainly you need a proficient Perl programmer to be able to read the resulting code easily, but such a programmer can pick up the happenings very quickly. Java and many other languages on the other hand are invariantly verbose, which annoys me greatly.

        I realize there's things other languages are better suited for than Perl, but I'd gravitate to Perl just for its brevity, or to be precise, its potential brevity, even in those cases. When it takes only one or two lines to filter certain elements out of a complex data structure as opposed to 15, and when the entirety of a data munging algorithm fits on a single screen, I can simply concentrate on what the code is actually doing much better. But then, I'm a rather right-brained, whollistic thinker and work better when I can keep the entire big picture in my head at once, whereas more linear thinkers will likely be annoyed by the density of Perl. To each his own.

        Makeshifts last the longest.

        Unfortunitly I cannot post the code, because it is proprietary stuff.

        I can say that it is an advanced GIS system that cannot be easily converted into perl

        I do not want to get into a language war with this post please. I simply wanted to read what others think about perl as an OO language or not.

        Thank you

        Kristofer A. Hoch

Re: Re: Perl - Is it an OO Language
by ignatz (Vicar) on Aug 27, 2002 at 11:11 UTC
    Very well said.

    If Perl was "OO" Ruby wouldn't exist.

    ()-()
     \"/
      `                                                     
    
      Not true. Ruby exists primarily because existing scripting languages didn't have good Japanese support.

      But it is possible that if Perl's OO was better then there might not be a viable niche for Ruby in the English-speaking world.

Re: Re: Perl - Is it an OO Language
by John M. Dlugosz (Monsignor) on Aug 27, 2002 at 15:28 UTC
    You won't find the right way in the documentation, that just shows you the quick and dirty (wrong) way.

    What is the right way?

    —John

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://193107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2025-07-20 16:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.