in reply to What if Perl had an OO standard library?

sustained object-orientation in Perl is difficult because the concept and mechanisms were bolted onto the language as an afterthought

I disagree with this characterization: I consider the way OO capabilities were introduced to perl (in the transition from v4 to v5) by adding support for bless() and $obj->method(...)* was beautiful in its elegance, simplicity and power. I still love it to this day.

What difficulties do you actually find in your search for "sustained object-orientation"? If you could describe those with some examples, it might be easier to discuss whether Venus would be a good solution for them.

(*) plus maybe a couple of other bits and pieces

Replies are listed 'Best First'.
Re^2: What if Perl had an OO standard library?
by awncorp (Acolyte) on Aug 24, 2022 at 00:18 UTC

    No offense intended.

    The remark that "sustained object-orientation in Perl is difficult …" is just my own fancy way of saying that “treating everything as an object is difficult/manual in Perl”. Data will always enter your program in its raw primitive form, and while you can objectify it (bless it), the lack of a native type system means that your classes and methods can’t be certain of the type of data they’re being passed, which forces you into a position of defensive programming. Consider the following examples (you made a routine and you want to compare anything passed in) ...

    Note: smatchmatch is experimental and not recommended for production use

    sub compare_things { $_[0] ~~ $_[1] }

    example #1

    compare_things(1, '') ''

    example #2

    compare_things('', '') 1

    example #3

    compare_things(1, []) ''

    example #4

    compare_things(1, bless{}) Died! Smart matching a non-overloaded object breaks encapsulation

    example #5

    compare_things(0, '') ''

    example #6

    Venus::Number->new(0)->eq('') # DMMT and DWIM 1

    example #7

    Venus::Number->new(0)->tv('') # (tv) type and value equality 0

    example #8

    Venus::Number->new(0)->eq(bless{}) # DMMT and DWIM 0

    "I am inevitable." - Thanos