Re: PERL as a first programming language?

Robert Sanders (rsanders@mindspring.com)
26 Jul 1994 06:55:43 GMT

On Mon, 25 Jul 1994 16:09:26 GMT, lwall@netlabs.com (Larry Wall) said:

>> I like the Lisp/Scheme/Dylan/Python approach; variables aren't
>> typed, but objects are.

> You can put Perl 5 in that list too.

Although it's a sin to disagree with Larry in comp.lang.perl, I just
don't think I get this one. Perl5 variables are typed exactly as
Perl4 variables are; the only difference is that scalars may also hold
a special kind of scalar called a "reference." That isn't quite the
same. Sure, you can do some of the same things with it, but in Perl5
the machinery is just a little too public.

$$sref to use a reference to a scalar, @$ref to use a reference to an
array, and %{$ref} to use a reference to an assoc. array just aren't
pretty to my delicate eyes. Of course, those are only for builtin
types, but even the use of refs to class instances isn't pretty.

Let's say I implement an arbitrary precision class in CLOS or STk,
Dylan, and Perl5. Here's how addition will look in each of these
languages (a and b are both instances of MP):

CLOS: (+ a b) or, assuming I leave the standard + function alone,
(add a b)

Dylan: a + b

Perl5: $a->add(b) or MP::add($a, $b) # unless the overload patches
# make it in one day

Since we're talking about teaching languages, clarity is an important
point. I don't think it will come as a surprise to anyone that Perl
isn't the clearest language in this example.

What I like most about CLOS, Dylan, and some Schemes with object
systems (i.e. STk, scheme+tiny-clos, etc.) is that objects take care
of themselves. I find that the generic function approach to OOP is
more in line with my view of it than the methods-belong-to-classes
path that C++ and Perl5 have taken.

-- Robert

P.S. NO MORE ROT13 JOKES! It's not Larry's fault if his home keys
are all punctuation. :-)