[aklug] Re: Perl 5 OOP

From: Christopher Howard <choward@indicium.us>
Date: Thu Jan 07 2010 - 13:23:11 AKST

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Arthur Corliss wrote:
> On Wed, 6 Jan 2010, Christopher Howard wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Okay, well here's a semi-random thought for the list:
>>
>> Perl 5 OOP sucks. Even with Moose.
>>
>> I guess I've been pampered lately, working mostly with C++ and Java.
>> Actually, Java has pretty cool feature which I just found out about
>> recently (being a Java n00b) called interfaces, where you can actually
>> define an interface (a sort of completely abstract class) and just
>> attach it to any class you want, independent of the inheritance
>> hierarchy.
>>
>> Anyway, right now I'm working with Perl because of a cool Perl module,
>> but I have to switch my code over to OOP, and even the Moose interface
>> seems awkward.
>>
>> I guess Perl 6 is supposed to improve that, but as Perl 6 doesn't even
>> seem to be in the Gentoo repositories yet, I'm probably not going to
>> play around with it.
>
> Perl OOP was intentionally vague to allow for flexibility. I kind of see
> arguments like these similar to postfix versus sendmail -- both do the same
> job, but there's a huge degree of difference in the range of flexibility.
> In short, Perl does OOP, but it isn't pendantic about it. You're
> allowed to
> leverage as much of it as you like, and still mix it with functional &
> procedural styles.
>
> Personally, I like the flexibility. I'd take that over the Java-based
> mentality, where simple things like arrays are objects(?!). You pay
> a price for that level of abstraction. At least in Perl you have a chance
> (and a choice) to do more low level optimizations where you like. Of
> course, I don't do OOP as much because it doesn't make as much sense for my
> kind of work.
>
> Basically, Perl appeals to those of us coming from lower level languages
> like C. Don't expect it to be comparable across the board with other
> strict high-level languages.
>
> And remember, you may not like it, but I'll bet everyone here is using it,
> consciously or not. :-) It's the one higher-level language that's
> included out of the box on every major UNIX (and clone) under the sun. Try
> taking it off your system, and see what breaks.
>
> --Arthur Corliss
> Live Free or Die

All right -- language war!

Err, oops... mature response: Doubtless, Perl is a powerful and
convenient language, or it wouldn't have had such an integrated,
gripping influence in the Unix world. Is it even possible to run even a
minimalistic Linux system without Perl, with all the utilities we have
come to depend on?

Perl was actually my first language, and C was my second language. I
have actually been a rather firm Perl supporter in the past, and there
are a number of things that I do really like about Perl.

Having said that, I have come to realize that Perl does not provide a
very comfortable environment for developing structured code bases that
grow and bend well to fit the needs of the project. As others have
mentioned often (here and elsewhere) much of syntax and capabilities
that modern programmers have come to love and depend on were sort of
tacked on to Perl 5 as an afterthought in the form of modules. And
sometimes these additions never quite reach the same level of natural
comfort as in most other languages, OOP being probably the most sore
example.

Your argument about allowing low-level manipulation has merit, although
it is something of a double-edged argument in the case of Perl. For
while you have the option to do low-level coding, do you really have the
option to do high-level coding? That is, if it takes twice as much
thought and code to do high-level programming, is it really high level?

Java is probably not the best comparison as it is supposed to be
strictly high-level. Most notably, no pointer arithmetic allowed. A
better comparison would probably be C++. C++ gives you natural OOP,
concise syntax, comfortable exception handling, and so forth. But it
also always you to drop down into C style constructs and mess with
pointers, manipulate structures, and heck, even execute assembly code if
you want to!

In all fairness, though, every language has changed an adapted over
time. Perl 6 was supposed to give us everything we wanted. But what is
the state of Perl 6? When does it become something that we can expect to
find readily available in most major distributions?

- --
Christopher Howard
http://indicium.us
http://theologia.indicium.us

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktGXs8ACgkQQ5FLNdi0BcUocwCfXqDvOAyBZKowtUVSPfh6Jf6R
q/8Anjo3018zpdsF24Esn0kOKPKtwlJA
=wlE2
-----END PGP SIGNATURE-----
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Thu Jan 7 13:24:44 2010

This archive was generated by hypermail 2.1.8 : Thu Jan 07 2010 - 13:24:44 AKST