|Welcome to the Monastery|
Apparent Inconsistencies in Perl Function Namingby princepawn (Parson)
|on Nov 24, 2000 at 17:05 UTC||Need Help??|
princepawn has asked for the
wisdom of the Perl Monks concerning the following question:
Note that the first word in the title is apparent, meaning that the rest of the title is thing as they appear to me, not necessarily the way they are.
Ok, let's do this storybook style. I'm sitting in my office and my boss says "how do you find out the length of an array in Perl?" So I tell him
A week later I'm reading comp.lang.perl.misc and Uri Guttman says to someone asking a similar question about strings: To take the length of a string, you use length. Larry did a good job of naming the Perl functions.
So then I, the nobody, have the nerve to email Uri Guttman, one of the Perl 5 Porters and lead author on one of the best Perl papers ever (on sorting) and tell him he isn't right about Larry naming the functions... Larry didn't do so great a job... why? Take a look:
In other words, the desired operation is the same in each case, but the way it is done in Perl is not... while one may say: "RTFM", one thing that reduces the learning curve for a language is for it to be intuitive. That's why I'm in awe when I hear people (even Damian Conway) say: "my brain thinks like Perl"... I have to stop,drop my jaw and say: "why in the world would you want different names for the exact same conceptual operation and what is it about your brain that seeks diversity in the function names for the exact same thing?
Operation: Taking a "slice" of something in Perl
Again while a logical person would say "how do I take subseries of something, regardless of whether it is a string or an array", we have the questionable brilliance involved in creating two radically different syntactic mechanisms for doing so.
And again, one must think seriously about offering a CAT scan to anyone who proclaims that such unwarranted non-homogeneity is "how their brain thinks".
ConclusionPerl makes simple things simple, and hard things possible, but also makes consistent operations possible through highly inconsistent means.
And of course we cant forget the recent interview on Perl.COM with Ilya Zakharavich handled by BigJoe about how FILEhandle information is inconsistently handled by Perl.