On 1/19/06, Juerd <[EMAIL PROTECTED]> wrote:
> Rob Kinyon skribis 2006-01-18 20:57 (-0500):
> > Well, for one thing, you can't write OO code in P5.
>
> Nonsense. OO isn't a set of features, and OO isn't syntax.
>
> Granted, syntax can really help to understand OO, and a set of features
> is nice, because it avoids having to re-invent wheels.
>
> But OO is just that: object orientation. It is a way of programming, and
> that can very well be done without any syntax or features for that in
> place.

I've said those very same things on Perlmonks. I stand by them, yet I
still maintain that you cannot write truly OO code in P5.

OOP is all about black-box abstraction. To that end, three items have
been identified as being mostly necessary to achieve that:
    1) Polymorphism - aka Liskov substitutability
    2) Inheritance - aka specialization
    3) Encapsulation

P5 excels at #1, does #2 ok, and fails completely at #3. Now, one can
argue whether the programmer should make the decision as to whether
strong encapsulation is desirable, but the point is that you cannot
create encapsulation in Perl that someone else cannot violate.

Hence, you cannot write OO code in Perl.

> C's filedescriptors are objects/invocants, and so are PHP's MySQL
> resources.

I point you to http://www.perlmonks.org/?node_id=112180 where I say
that Perl's scalars are objects. I have since realized that tilly is
right, particularly after learning a more OO language (which just
happened to be Ruby).

> Perl 5 has syntax for OO, and even a few useful features. Even though
> these are not needed at all to write OO code, it certainly does help
> people to stick to OO design.
>
> And if more features are needed, CPAN has them.
>
> Object orientation is still object orientation if you write it
> differently: "$bar->{foo}->()", if that's how you decide to write a method
> call on $bar, is still OO.
>
> Classes, like OO syntax, are not necessary for OO.

Javascript is a good example of this. Yet, even in JS, you have the
"prototype", which is the "class". Unless you plan on building
everything by hand, you still need a model for the new instance you're
creating. That model is the class. It's not an OO requirement, but an
OO consequence.

> > You can write code that behaves like you're in OO-land and that talks
> > with an OO accent (so long as you don't look behind the curtain), but
> > it's not OO.
>
> Your definition of OO is far too specific for a 2-letter acronym.

OO is a spectrum, not a point. What I was trying to say was that when
comparing the OO you can do in P5 with the OO you will be able to do
in P6, it seems silly (to me) to cripple P6 out of a misguided effort
to maintain backwards compatibility with P5.

Rob

Reply via email to