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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

To start with, perl's object system was a bolt-on to the existsing module system, which is both ugly (because it kind of exposes the soft underbelly of objects) and cool at the same time (you can do some crazy stuff with modules/typeglobs, and you can now do them with objects too :)

How it handles inheritance is another.

package Foo; @ISA = qw(Bar);
This takes the idea of inheritance and converts it into a "magic" laden assignment statement. This exposes too much of the details of how perl manages inheritance, which IMO is ugly. Maybe I am a purist, but I think that declaring inheritance should be part of the class declaration, or at the very least have its own keyword.

Constructors in perl are nothing special, which at first glance is cool, but it does lead to some ugly code when calling base class constructors in subclasses. I personally like the C# syntax for these things:

class Bar { string name; public Bar (string name) { this.name = name; } } class Foo : Bar { Hashtable attributes; public Foo (string name, Hashtable attributes) : base(name) { this.attributes = attributes; } }
Also, the idea that an object is just a blessed reference IMO is another double edged sword. It makes encapsulation a big issue/problem. (Sure I know you can do Inside-Out objects and closures, etc etc etc, but all of them just add to the already touchy syntax.) Now I know the idea is that you shouldn't mess with the internals because you were not invited, and that it then becomes a social problem. But I would rather not have the social problem at all and have strong encapsulation.

All this said, I love perl, so I have worked with/around all this stuff in my own way, but it doesn't change the underlying ugliness of it. And yes, some might call this elegance, and I will be the first to admit that there is a fair amount of elegance in how minimally invasive the adding of objects to perl was, but when you get deep into the thick of it, there is some real ugliness there no matter what.

-stvn

In reply to Re: Re: Re: Functional Inside Out Closure Objects by stvn
in thread Functional Inside Out Closure Objects by fletcher_the_dog

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, 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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (5)
    As of 2020-10-29 14:56 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favourite web site is:












      Results (271 votes). Check out past polls.

      Notices?