develooper Front page | perl.perl5.porters | Postings from December 2008

Re: [PATCH] Class as a Feature (take four)

Thread Previous
Jonathan Rockway
December 16, 2008 01:54
Re: [PATCH] Class as a Feature (take four)
Message ID:
* On Tue, Dec 16 2008, chromatic wrote:
>> Making it even easier to replace things and add new modular features
>> will make Perl more attractive to people like me.
> I don't care about what makes Perl attractive to really smart, really capable
> developers like you.  Perl's been very good at that.  I care about what makes
> Perl attractive and useful and maintainable and clear for the other six and a
> half billion people on the planet.

Sorry to veer off in the direction of philosophy but you know me... I
can't resist.

I am tempted to think that the reason people act stupidly is because
they're treated like they're stupid.  If we keep telling people that
things are hard, they're going to try them, notice that they are not
immediately successful, and assume that they are too dumb to ever use
that "hard" feature.

This has happened to me.  I took Japanese in high school.  Part of the
curriculum was learning to write; one day the new character was katakana
"ro" (ロ).  The teacher said something like, "if you want to write this
correctly, the left and right lines need to angle inward slightly, but
*this is hard* so just draw it like a square for now".  Well, I
immediately took his advice, and just drew a three-lined square.  (The
top and right sides are one line.)  Doing it right was going to be too
hard, so why even try?

Fast forward a year or two into the future, and I was going to high
school in Tokyo.  As astute readers may note, the first character of my
last name is "ro", and so I was writing this katakana "ro" a lot.  Every
time I wrote it, the words "this is too hard" echoed in my head.
Writing it right was too hard, so why even try?  It's too hard!

One day, for reasons I don't understand, I decided to try writing the
character with the lines angled inwards, "correctly".


It wasn't hard.  It was fucking *TRIVIAL*.  It was just like making a
square, except the lines were angled in a bit.  Why did I avoid trying
something so simple for *years*?!?!?

Anyway, the point is that if *I* avoided drawing lines for years because
someone told me it was too hard, imagine what people are doing when we
say installing CPAN modules is too hard?

Installing CPAN modules is not that hard -- if you are installing an XS
module, the worst case goes something like:

 $ apt-get install gcc make
 $ apt-get install libfoo-dev
 $ cpanp install LibFoo::Interface

Three steps.  Even easier than drawing three lines, yet we still tell
everyone it is too hard, and they believe us.  It is *easy*, not hard.
The reason we say "hard" is that it's going to take a while to get used
to, and "hard" seems like a nice thing to say.  "Oh, you're not dumb,
it's just hard." "OK, I feel good about myself now."

Except they are not really saying the second thing, they are saying,
"It's hard, I will probably never figure it out, so I am not even going
to try anymore."


("easy" has a similar effect -- "Oh, this is easy." "I can't do it, I
guess I am too stupid even for this."  The best advice is: don't boil
down complex concepts to simple words like "easy" and "hard".  It
doesn't work.

I have also noticed this effect with "slow" and "fast".  Sometimes I say
in my documentation that something is "fast", even though it isn't
really all that fast.  I have never had a complaint about it being slow.

Moose, on the other hand, talks about the "speed hit" and how some
things are "slow".  Well guess what, now everyone whines about how slow
it is.  I think this is because they know slow is bad, and they were
told it was slow, so they assume that they are not actually imagining
the problem.  If they didn't have their minds contaminated beforehand
with words with negative connotations, they probably would have never

OK yeah, we were talking about Perl?  About that...

> I can maintain my own class keyword patch against bleadperl ad infinitum.  I
> can write and maintain my own source filter and mandate its use in every
> project I write.  I sent it here instead because I think it might be very
> nice for everyone who wants to create a class in Perl 5.12 someday to be able
> to say:
> 	class MyAwesomeClass is Your AwesomeClass {
> 		...
> 	}
> ... because I think they might find that more clear than:
> 	{
> 		package MyAwesomeClass;
> 		push @MyAwesomeClass::ISA, 'YourAwesomeClass';
> 		...
> 	}

So let me document the mini-nightmare that was going through my mind
when this conversation started.

Precondition 1: all of the Moose devs said they will never put/maintain
Moose in core

Precondition 2: rgs said, "the perl core should have

Hopefully you see the problem.  If we put "class" in core, then we are
going to put a sub-par object system in core, or we are going to put in
an ANCIENT version of Moose that is broken and will only be fixed once a
year, and only if it doesn't break compatibility.

This will suck balls, and then I will have to read about how Perl's new
object system sucks, and how Moose sucks too because the sugar is the
same. (People do this already.  "Hey look, I reimplemented Moose and
it's 8 times faster!"  No, you didn't.)

Before you know it, I will be forced to gouge out my eyeballs with these
TPF "round tuits" I have on my desk.

So really, I just want to avoid the splinters in my eye sockets.  Adding
the "class" keyword is the first step down that road.  (Remember the
children's book that goes like "If you give a Moose a muffin, then it
will want a glass of milk; ..."  Well, if you give Perl5 a class
keyword, it will want a Moose.  Very metacircular...)

The end goal is to avoid making Perl look bad because it has to maintain
a development snapshot of Moose for the Rest Of Forever.  (What is
"stable" today is going to be "obsolete" in a few months.  Moose has no
problem breaking compat to fix internal bugs.  This is my favorite
feature, but is one that the perl community as a whole seems to hate
with a passion.  Wonder why Catalyst hasn't changed in 3 years?  There's
your reason.)

> Second, what's the likelihood that the name by which we call what other
> languages call a 'class' is going to change?  I have it on pretty good
> authority that the syntax in this patch resembles the syntax of Perl 6
> strongly.  Is there not a desire to hew somewhat in that direction?

Just in general, it is about the right level of meta.  A class keyword
would be nice, sure, but I think it would be nicer to let anyone write
any keyword in pure Perl.  You can have class, and you can have anything
else you want that way.  (Considering we already have a class keyword
that is better than the one you propose, I think this strategy is a good

If we don't tell people it's hard, it will be useful to everyone.  It
will be easier to maintain, and it will only break people's apps when
they do it to themselves.  (Has anyone ever complained to the list "I
typed sub foo, and it overrode my other sub foo!?  I hate you guys!"
No.  But I bet they would complain if the next version of Perl broke
their "foo".)

>> I don't think adding a half-assed version of Moose to the core would
>> help anyone.  It would be a waste of time for the people writing it, and
>> a waste of time for the people using it.  (This is more in response to
>> rgs' comment, rather than yours.  Moose is the right way to get
>> attributes and "final" classes in Perl 5.)
> Then what is the purpose of this mailing list?  Why not drop all core modules
> except those necessary to bootstrap and instead concentrate on fixing
> bugs and occasionally refactoring the internals?

I know you are being sarcastic, but YES PLEASE.  Why do I have to wait
for some random dependency of a dependency of CPANPLUS to fix a bug to
get a release of Perl that fixes issues with array assignments?
Distribute the core as core, distribute the modules as modules.

(BTW, I like CPANPLUS and everything... but we have two CPANs in core?

In conclusion, I really shouldn't drink coffee after midnight.

Jonathan Rockway

print just => another => perl => hacker => if $,=$"

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About