2 ms·
I agree with chromatic below; Java and C++ do not teach you OO. They teach you cut-n-paste without a text editor. (When Bar extends Foo, you're copying-and-pa
by jrockway 15y ago
I agree with chromatic below; Java and C++ do not teach you OO. They teach you cut-n-paste without a text editor. (When Bar extends Foo, you're copying-and-pasting Foo's code into Bar, and then tweaking it. Or at least that's how class-based OO is used a good percentage of the time.)
A better way to program is with interfaces and composition via delegation, something that Java and C++ support but have no syntax for making it easy. Perl's Moose object system, on the other hand, has easy support for composition via roles and delegation via ... well, delegation :)
And, you have "extends"-style OO available if you think it's the right solution to a particular problem. So really, I think it's a fine way to learn OO. Doing things right is easier, if you decide to do them right.
(We do Java OO right at Google, but it sure involves a lot of typing and @hacky-attributes. And I've never seen good Java OO anywhere else.)
- stcredzero 15y agoAs a Smalltalker with a decade of experience, I too find Java a bit lacking. That said, it was a better environment for OO than Perl at the time. I was able to get a feel for refactoring through Java, though. That primed me for Smalltalk and the joy of no primitive types.
- jrockway 15y agoAt the time, yes, absolutely. Now, Perl is pretty nice, and you get a lot of nice libraries. I have used Java and Python extensively now and I like Perl a lot more. All three are quite usable, however.
- prodigal_erik 15y agoReally? I see inheritance as a good antidote for cut'n'paste. If you don't physically duplicate code, you'll never have to read both copies just to make sure they're still the same. I agree most devs do it wrong, but I think it's because they're purely pragmatic and haven't read or thought philosophically about the open/closed principle, programming-by-difference, Liskov-substitutability… And I do want to remind readers that Moose is not the Perl object system, it's an object system added on top of the mess that a huge collection of legacy code presumes.