4 ms·
" Also, Perl5 has a modules approach in that there are several potential OO frameworks like Moose, while Python had it as part of the base language which a lot
by tyingq 6y ago
" Also, Perl5 has a modules approach in that there are several potential OO frameworks like Moose, while Python had it as part of the base language which a lot of people prefer."
Perl's built-in OO, without Moose, works fine, and isn't substantially different from python's.
What is different is that "everything is an object" in python. That's not true for Perl. So Perl OO is a bit saddled with references (pointer like things) and sigils ($this, @that, %theother) and therefore intimidating looking data structures, dereferencing, etc. To me, that's what makes OO Perl painful. To be fair, it's also one reason why Perl is often a lot faster than Python...basic types don't have the same amount of overhead.
Personally, I love Perl and still use it often. But I can see why Python sucked away the user base.
- wombatpm 6y agoThis right here. I had a project in 2003 that I started in Perl and wanted to do right with OO. That lasted two days. I switched to Python and have never turned back
- jonathankoren 6y agoI like Perl, and find the complaints about sigils weak given how many people swear by POSIX scripting, when there are so many better tools out there like Perl. However I also found Perl’s OO to be painful. I’d call it a cruel joke. I could never comfortably wrap my head around its implementation because it always felt like a horrible kludge on top of the module system. Is it a module? Is it a class? Is it an object? Are they normal functions? Are they class methods? Or are they member methods? The answer to all for these questions is a resounding yes! TIMTOWTDI bites us once again. Perl is great for its primary use case of being the thinking person’s BASH, and it has the greatest regexp and stdio support for any language I’ve used, but I wouldn’t build anything OO with it.
- tyingq 6y agoI didn't mean to say that sigils were a general issue. Just that they made complex data structures (and thus, OO) more complex...and intimidating for newcomers. As for wrapping your head around Perl OO, really it's just bless(). Bless($thing,'namespace') says "this $thing is an object, in this namespace". You can make an object without adding a namespace beyond the default main namespace... Like: sub test {print "whee\n";} my $foo={}; bless($foo,'main'); $foo->test(); That will print out "whee". Because I "blessed" $foo into the main namespace, calling $foo->test() is calling the subroutine "test" in the main namespace, with '$foo' as the first argument. So OO in Perl is just mapping a namespace to a blessed reference via bless($ref,'namespace'). Then $ref->call($arg) runs the "namespace::call" sub, but as if you did namespace::call($ref,$arg).
- jonathankoren 6y agoYeah, they’re just void pointers. I think lack of syntactic support for nested data structures comes from its origin as a better bash script.