Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: difference between OOPs in Perl and java

by dHarry (Abbot)
on Jan 21, 2011 at 07:25 UTC ( #883482=note: print w/ replies, xml ) Need Help??

in reply to difference between OOPs in Perl and java

I don't like Perl OO too much, IMHO there are two many ways to do it! If you want to use OO in Perl I suggest to take a look at Moose. There is manual and a cookbook to get you started.

There are big differences, the two languages are completely different. On top of what ikegami said Let me add/clarify something on Inheritance. Perl supports both single and multiple inheritance. In Java multiple inheritance is not supported directly. This was a design decision. Instead Java has the concept of interfaces. According to some multiple inheritance is evil. The standard argument is the "diamond problem":

A / \ B C \ / D

Suppose a virtual method in A is implemented by both B and C. Question: Which one do you get when you instantiate D?

If you use the Java's interfaces it's not a problem, interfaces don't have implementations. If you make A, B, and C all interfaces, then D chooses how to implement the A method. The Java interfaces are a kind-of multiple inheritance but simplified. Having said this if you use abstract base clases with pure virtual functions (I'm thinking more C++ here) there is no reason why you can't use multiple inheritance.



Comment on Re: difference between OOPs in Perl and java
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-08-21 10:55 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (134 votes), past polls