Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-03-30 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found