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

Al is a terrific dev and nice dude. Venus is built on Mars. That was fun to write. I have yet to try either but I’ve been planning to do so. I do know that they are quite performant and Mars is faster than everything other than raw hand-roled objects or similar tiny/optimized packages like Mo.

  • Comment on Re: What if Perl had an OO standard library?

Replies are listed 'Best First'.
Re^2: What if Perl had an OO standard library?
by haj (Vicar) on Aug 23, 2022 at 12:56 UTC
    Venus is built on Mars.
    It doesn't use it, though. It duplicates the code.

      With all due respect, that's a distinction without a difference.

      "I am inevitable." - Thanos
        ...until Mars is updated and the Venus dev(s) choose to either copy the updates (difference: additional work for the dev(s), potential to introduce errors if it's not used verbatim) or to leave Venus using the OldMars code (difference: Venus and Mars no longer behave the same way in some cases).

        Or, even better:

        ...until an exploit is found in Mars. and then users have to find every copy of both Mars and Venus on their systems to apply the security update. Which they might not know they need to do if they're not aware that Venus uses its own independent copy of the Mars code.

        The latter case came up a few months ago with zlib. Since it's FOSS and fairly simple, many developers chose to include their own copy of the zlib source instead of being dependent on the system having a working zlib installed. Then a major zlib exploit was found, and I had to spend a day or two tracking down everything that used zlib code on any of the machines I'm responsible for, checking if each one had an update available, and then either installing the updates or figuring out how to mitigate the vulnerability where updates weren't available. If they had all just used the system zlib, then I could have updated that and been done with it. That's only "a distinction without a difference" if you're not the poor schmuck who has to admin systems which use the code.

Re^2: What if Perl had an OO standard library?
by awncorp (Acolyte) on Aug 23, 2022 at 23:42 UTC

    :bow: @YourMother. Thanks for the kind words. Here's some cool stuff I haven't blogged about yet that you can do with Venus:

    # throw exceptions easily
    Venus::Path->new('/path/to/nowhere')->throw->error({message => 'Missin +g file'}) "Missing file"
    # catch exceptions easily
    Venus::Path->new('/path/to/nowhere')->catch('open')->message "Can't open /path/to/nowhere: No such file or directory"
    # determine and call methods on each item in an array
    Venus::Array->new(['a'..'d'])->call('map', 'uppercase'); [ 'A', 'B', 'C', 'D' ]
    # use indirect dispatching to nest calls (in this case, on each item in an array)
    Venus::Array->new(['a'..'d'])->call('map', 'box', 'uppercase'); [ bless({'value' => bless({'value' => 'A'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'B'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'C'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'D'}, 'Venus::String')}, 'Venus: +:Box ) ]
    # use MORE POWER and force return an "autoboxing" object so you can continue chaining things
    Venus::Array->new(['a'..'d'])->box('call', 'map', 'box', 'uppercase'); bless({'value' => bless({'value' => [ bless({'value' => bless({'value' => 'A'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'B'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'C'}, 'Venus::String')}, 'Venus: +:Box'), bless({'value' => bless({'value' => 'D'}, 'Venus::String')}, 'Venus: +:Box ) ]}, 'Venus::Array')}, 'Venus::Box'});
    "I am inevitable." - Thanos
Re^2: What if Perl had an OO standard library?
by Anonymous Monk on Aug 23, 2022 at 12:58 UTC
    Mars uses dualvar instead of use real true false !!0 !!1

      I'm not sure what you mean by "real" true and false. Perl doesn't have real true and false yet. If you're talking about "true" and "false" from the "builtin" pragma, that's still very experimental and only available from Perl 5.36+. What we have now are different conventions for representing true and false, i.e. the legacy 1 and 0 (and the problems they have, i.e. cross-language interoperability), the YAML/JSON spurred \1 and \0 (but that doesn't play nice with legacy code), and now my dualvar-based 1|"1" and 0|"0" which is (IMHO) better than all the rest because it's fully backward-compatible (i.e. legacy code expecting 1 or 0 works just fine) yet easy to identify as a boolean (via is_dualvar).

      "I am inevitable." - Thanos

        Side note: Perl might have booleans now, maybe. :P No idea how compatible or permanent but they’re trying (v36.0).

        builtin::true, builtin::false, builtin::is_bool

        true and false return boolean true and false values. Perl is still perl, and doesn't have strict typing of booleans, but these values will be known to have been created as booleans. is_bool will tell you whether a value was known to have been created as a boolean.