in reply to Dots and cargo-cult programming
Last month, when I heard Damian Conway talk about stuff coming up in Perl 6, there was much crabbiness from the crowd (or at least one member of the crowd as he discussed the dot operator, but apparently Larry's reasons are pretty much what you said:
Perhaps they feel that their languages won't compete well with other languages that use dots.
Perhaps they want to extend the reach of their languages into the ranks of the VB macro/spreadsheet community.
Larry wants Perl to carry forward, and apparently feels that the arrow is some sort of barrier to entry, and that people are afraid of Perl because of the "nonstandard" way of calling methods. The Visual Basic thing is seen as a huge potential "market" for Perl.
xoxo,
Andy
--
<megaphone>
Throw down the gun and tiara and come out of the float!
</megaphone>
How I Learned to Stop Worrying and Tolerate the Dot
by frag (Hermit) on Jul 15, 2001 at 11:56 UTC
|
Yeah, I don't like the dot. Here's why:
When I first started with Perl, I had only used the dot occassionally in
C and Javascript. When it came time to learn Perl's arrow, it was
relatively easy: whereas a dot suggests termination, both as period and (US)
decimal, the arrow suggests action, i.e. $object->does_something. This
is the basic reason I hate the dot. Essentially, it throws off the
natural-language written text parser in my head, in a way that is
diametrically opposed to its normal use. (Is there any modern written human
language out there that does not use the period as the default mark for
terminating utterances? Has anyone involved with human-computer
interaction/usability testing ever examined the usability of the semantics
assigned to semicolons, brackets and other "line noise" ascii in different
computer languages? Besides the ongoing sniping over white space vs.
brackets?)
But now, thanks to Java, VB, and other languages,
the dot is the Dominant Programming Convention, and we, the valiant hold-out
programmers who know better, are doomed. Doomed! Doomed, I say! Or should
that be
$we = $I.say("Doomed!" x3);
Damian assured me that the Grand Poobah's
mind is set, and our fate is sealed. And he cajoled me that it wouldn't be
so bad, getting used to using dots instead of arrows; that he had been
against it, tried it, and after a while it was no big deal. He convinced
me, reluctantly, because ultimately that line of code above isn't so bad.
He also gave me this really yummy blue pill.
Plus, I wouldn't call this "cargo cult programming". That's about
propagating ignorance. This seems to me to be a matter of a concession to
convention, when the convention's hold reaches a critical mass and when the
convention is suboptimal but not abhorrent. And I definitely wouldn't go
that far.
Anyway, I'm actually much more concerned about =~ vs ~= right now. Dot
vs. arrow is a nuisance, but that's potentially lethal, and at the
least I hope it's dealt with intelligently by perl6's warnings.
-- Frag. | [reply] [d/l] |
|
I wouldn't call this "cargo cult programming"
The point of the original poster wasn't that the dot
was cargo cult programming, but that it encouraged
people to cut 'n' paste VB code into Perl programs, because
there was no translation of the -> to a .
xoxo,
Andy
--
<megaphone>
Throw down the gun and tiara and come out of the float!
</megaphone>
| [reply] |
|
I guess I was trying to say that I don't think that permitting
cut'n'paste is itself the motivating factor for the change. I got the
impression from Damian's comments that it's about reducing one factor that
might daunt (does daunt?) Veebians, Javanese, etc. when trying to use Perl,
by giving in to the common convention.
Also, now that I think about it, I don't think there's anything wrong
with using example code, and I don't think that's the same as cargo cult.
Everyone does it from time to time (raise your hand if you own
the Cookbook) especially when starting out on a new topic. The question is,
will you stop with that? Will you let the example persist unmodified into
production, without bothering to figure out what it's doing?
I think this is mostly a matter who you are - whether you've got the
drive to understand, and take pride in your work. I think it was Socrates
who said "The unexamined code is not worth executing", but there are plenty
of people who wouldn't properly examine their code no matter what language
they're using. Making conversion of VB code into Perl easier, by itself,
IMHO, won't encourage cargo cult any more than the Cookbook does now.
-- Frag.
| [reply] |
|
| [reply] |
|
That's a good point. I'm so used to it by now that I haven't considered how
weird it is to use '.' as concat. I think it's because I've grown to think of
the Perl5 dot as like a decimal point, in that the two parts of the number
have to be adjacent to each other.
-- Frag.
| [reply] |
|
Yes, so many things we think of as normal now were caused by a lack of characters in ASCII and its predicesors. Why not use × for multiplication and ÷ for division, since they are in the common Latin-1 8-bit character set? I mean, isn't it time we moved beyond 7 bits?
Now we think of * as meaning multiply, when originally it was an available substitute because character 0xD7 didn't exist yet.
You could also use → for dereference and ← for assignment (as early Algol-family languages originally wanted!), if only the fonts weren't drawn so terribly.
—John
Hmm... I know that's worked before, so why are characters with high bit set (multi-byte in UTF-8 encoding) showing up as sequences in the preview window? Looking at HTML source, there is no meta tag for charset present. Works fine as entities, though, but much harder to type!
| [reply] |
Re: Re: Dots and cargo-cult programming
by Everlasting God (Beadle) on Jul 15, 2001 at 01:42 UTC
|
Not to be pedantic, but where I come from (c++) -> *is* the standard way to call functions that live inside an object that you have a pointer to, which is pretty much the only way I ever use it in perl too. (blessed ref to an object)
'The fickle fascination of and Everlasting God'
- Billy Corgan, The Smashing Pumpkins | [reply] |
|
| [reply] |
|
I'm not sure I follow this. The dot is ugly, but it's not like it
inherently discourages you from using it. In fact, it could be said "->"
is better for that purpose: more letters to type. (And 3 times more keys!)
Plus, you have to use it for objects, unless you want to encourage 'indirect
object' syntax.
-- Frag.
| [reply] |
|
|
Well I'm glad somebody pointed this out.
It isn't to emulate Java, VB or SmallTalk so much as to
make the code cleaner and easier to parse. Admittedly I'm
attached to the existing arrow operator but I can get used
to using a dot instead.
There are more important battles to fight. That's such a minor one.
| [reply] |
|
|