I used all of this features, and felt a sense of freedom that you only get with perl.

Actually you get it with lots of other languages too :-) Java is a very restrictive language (by design). Try playing with Self, Smalltalk, Ruby, Lisp, Python, etc. and you'll find lots of similar benefits.

Learn more languages. More languages good :-)

To demonstrate why this is important sometimes, think of Java's SecurityManager class: It controlls all activities in the JVM including file and inter-thread actions. If one could add and override functions in that class freely, that class would be useless.

Remember - this is only as secure as the JVM itself. If you can compromise this you don't have any real security.

Is there such a way?

You can use techniques like inside out objects, lexically scoped anonymous subroutines, etc. to get similar levels of encapsulation in Perl.

Are there any other downsides (and upsides) that I am not aware of?

Another downside is in creating extensible classes. It is easy to write a class in Perl that can be accidentally broken by a subclass, or have a sub-class that is broken by a private implementation change in a super class.

There are, of course, ways to code around this given sufficient discipline, but it's harder than it should be. As ever it looks like Perl 6 will solve all of these problems ;-)


In reply to Re: OOPerl isn't that bad after all... by adrianh
in thread OOPerl isn't that bad after all... by yosefm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.