Hi Shawn!

On Thursday 25 Mar 2010 20:38:59 Shawn H Corey wrote:
> On Thu, 25 Mar 2010 19:54:48 +0200
> 
> Shlomi Fish <shlo...@iglu.org.il> wrote:
> > Well, this is a bike shed argument. I find using "shift;" instead of
> > "shift(@_);" when inside subroutines to be faster to write, more
> > concise and more idiomatic. shift has this magic for a reason. I'm
> > unlikely to use shift the other way when outside or inside
> > subroutines. (And if I do, my automated tests will catch this.)
> 
> I use substarter
> http://search.cpan.org/~shcorey/Sub-Starter-v1.0.6/script/substarter
> 
> It comes with Sub::Starter
> http://search.cpan.org/~shcorey/Sub-Starter-v1.0.6/lib/Sub/Starter.pm
> 
> You can change its template to anything you want.

So you generate your subs (if I understand you correctly). Nevertheless the 
extra << shift(@_); >> syntax still clutter the code and make noise. To quote 
Paul Graham from http://www.paulgraham.com/popular.html :

<<<
3 Brevity

Given that you can supply the three things any language needs-- a free 
implementation, a book, and something to hack-- how do you make a language 
that hackers will like?

One thing hackers like is brevity. Hackers are lazy, in the same way that 
mathematicians and modernist architects are lazy: they hate anything 
extraneous. It would not be far from the truth to say that a hacker about to 
write a program decides what language to use, at least subconsciously, based 
on the total number of characters he'll have to type. If this isn't precisely 
how hackers think, a language designer would do well to act as if it were.

It is a mistake to try to baby the user with long-winded expressions that are 
meant to resemble English. Cobol is notorious for this flaw. A hacker would 
consider being asked to write

add x to y giving z

instead of

z = x+y

as something between an insult to his intelligence and a sin against God.

It has sometimes been said that Lisp should use first and rest instead of car 
and cdr, because it would make programs easier to read. Maybe for the first 
couple hours. But a hacker can learn quickly enough that car means the first 
element of a list and cdr means the rest. Using first and rest means 50% more 
typing. And they are also different lengths, meaning that the arguments won't 
line up when they're called, as car and cdr often are, in successive lines. 
I've found that it matters a lot how code lines up on the page. I can barely 
read Lisp code when it is set in a variable-width font, and friends say this 
is true for other languages too.

Brevity is one place where strongly typed languages lose. All other things 
being equal, no one wants to begin a program with a bunch of declarations. 
Anything that can be implicit, should be.

The individual tokens should be short as well. Perl and Common Lisp occupy 
opposite poles on this question. Perl programs can be almost cryptically 
dense, while the names of built-in Common Lisp operators are comically long. 
The designers of Common Lisp probably expected users to have text editors that 
would type these long names for them. But the cost of a long name is not just 
the cost of typing it. There is also the cost of reading it, and the cost of 
the space it takes up on your screen.
>>>

Note the last paragraph. I don't want to clutter my code with extraneous @_ in 
shift(@_); because it will take more time to read and clutter my screen.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Parody on "The Fountainhead" - http://shlom.in/towtf

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to