Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Perl's OO encapsulation is weak at best

There can be levels of encapsulation. And this may not be a good thing. Acording to Stroustrup in C++ there is one too many. In The design and evolution of C++ page 302 he says In retrospect, I think that protect is a case where "good arguments" and fashion overcame my better judgement and my rules of thumb for accepting new features. Admittedly in Perl there is no level of encapsulation. Object variable members are accessible to anyone but people cannot access one by mistake unlike C++ because in Perl one must explicitly mention the object when accessible a member variable $self->{var}. Perl6 will probably be hoepfully less verbose while still avoiding the C++ potnetial ambiguity: $.var (note the dot that means that a member variable is accessed). In C++, in a member method, you can access by mistake a member variable of the class or a parent class when you thought you were accessing a global variable or if you forgot to declare the lexical variable you use.

Also there is two kinds of encapsulation: forced or not. In perl no one is ever forced to anything. As I said before, there is encapsulation in the sense that no one can unwillingly access object data.

BTW: C++ forced encapsulation is a joke because it is so easy to defeat. It is just a compilation thing, no check at link time:

#define private public #define protected public #define class struct

Anyway, one must always be careful of language comparaison because one always uses the metric adapted for its favorite language. Judging a language only for its OO-ness is a very restricted view in my opinion.

In fact pure OO language are insanely verbose for the "Hello World" test. One of the perl feat is to scale from oneliners to moderately big programs. In this case, good score in the "pure OO-ness" metric is a _bad_ thing.

Corrected the Stroustrup reference

-- stefp -- check out TeXmacs wiki

In reply to Re: Re: Perl - Is it an OO Language by stefp
in thread Perl - Is it an OO Language by krisahoch

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (5)
    As of 2018-06-22 06:27 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (121 votes). Check out past polls.