From: William James
Subject: Re: relativity of programming languages
Date: 
Message-ID: <1156814628.613944.26340@74g2000cwt.googlegroups.com>
Fabien LE LEZ wrote:
> On 28 Aug 2006 13:47:20 -0700, "goose" <····@webmail.co.za>:
>
> >First: Don't regard this as a troll!
>
> Agreed. This is not serious enough to be a troll.
>
>
> >Second: What do others think of these weightings?
>
> I've seen several weightings like that, but this one seems even more
> arbitrary and groundless than usual.
>
> Hey, why not make another set of weightings?
> Like, "What's the best drink to have when programming?"
>
> (defun weight-drinks-for-programmer (list-of-drinks)
>   (mapcar (lambda (x) (list x (random 100))) list-of-drinks))

This is a very awkward way to express it.
But this code can be very easily parsed by the computer,
you say?  "[P]rograms must be written for people
to read, and only incidentally for machines to execute."

def weight_drinks_for_programmer list_of_drinks
  list_of_drinks.map{|x| [x, rand(100)] }
end

> (weight-drinks-for-programmer '(tea coffee chocolate beer water wine))

a = weight_drinks_for_programmer %w(tea coffee chocolate beer water
wine)
    ==> [["tea", 69], ["coffee", 60], ["chocolate", 94], ["beer", 89],
         ["water", 61], ["wine", 30]]

a.sort_by{|x| x.last}
    ==>[["wine", 30], ["coffee", 60], ["water", 61], ["tea", 69],
        ["beer", 89], ["chocolate", 94]]

--
Common Lisp is a significantly ugly language.  If Guy and I had been
locked in a room, you can bet it wouldn't have turned out like that.
  --- Dick Gabriel

From: ·······@yahoo.com
Subject: Re: relativity of programming languages
Date: 
Message-ID: <1156821657.920881.282850@b28g2000cwb.googlegroups.com>
William James wrote:

> Fabien LE LEZ wrote:
> > (defun weight-drinks-for-programmer (list-of-drinks)
> >   (mapcar (lambda (x) (list x (random 100))) list-of-drinks))
>
> This is a very awkward way to express it.
> But this code can be very easily parsed by the computer,
> you say?  "[P]rograms must be written for people
> to read, and only incidentally for machines to execute."
>
> def weight_drinks_for_programmer list_of_drinks
>   list_of_drinks.map{|x| [x, rand(100)] }
> end

You're kidding right?  I can't tell the difference.

Are you are saying that it is overwhelmingly more clear to think of map
as message that a list can respond to than to think of it as a globally
available procedure that acts on a list?  Is there some other
difference between the two snippettes that I missed?
From: Ken Tilton
Subject: Re: relativity of programming languages
Date: 
Message-ID: <ecPIg.167$3b6.16@newsfe10.lga>
·······@yahoo.com wrote:
> William James wrote:
> 
> 
>>Fabien LE LEZ wrote:
>>
>>>(defun weight-drinks-for-programmer (list-of-drinks)
>>>  (mapcar (lambda (x) (list x (random 100))) list-of-drinks))
>>
>>This is a very awkward way to express it.
>>But this code can be very easily parsed by the computer,
>>you say?  "[P]rograms must be written for people
>>to read, and only incidentally for machines to execute."
>>
>>def weight_drinks_for_programmer list_of_drinks
>>  list_of_drinks.map{|x| [x, rand(100)] }
>>end
> 
> 
> You're kidding right?  I can't tell the difference.

How about?:

  (loop for drink in list-of-drinks
        collecting (list drink (random 100)))

Of course now we are cheating, because Python does not have macros. It 
does, however, have Cells:

   http://pycells.pdxcb.net/

:)

ken

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Raffael Cavallaro
Subject: Re: relativity of programming languages
Date: 
Message-ID: <2006082822305716807-raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2006-08-28 21:23:48 -0400, "William James" <·········@yahoo.com> said:

>> (defun weight-drinks-for-programmer (list-of-drinks)
>> (mapcar (lambda (x) (list x (random 100))) list-of-drinks))
> 
> This is a very awkward way to express it.
> But this code can be very easily parsed by the computer,
> you say?  "[P]rograms must be written for people
> to read, and only incidentally for machines to execute."
> 
> def weight_drinks_for_programmer list_of_drinks
>   list_of_drinks.map{|x| [x, rand(100)] }
> end

And this is somehow magically "intuitive?" The reality is twofold:

1. Which of these two idioms is more "natural" is entirely a matter of 
experience and taste. I find the first more "natural" but that's 
because I program much more lisp than python. A python programmer would 
find the latter more "natural." Neither is objectively more "natural." 
Both are completely artificial, and which one prefers is just a matter 
of experience and personal taste.

2. In common lisp, you can give yourself any syntax you find convenient 
(via macros). Don't like the mapcar idiom? - write one you do like. In 
Python you are stuck with those syntactic forms and only those 
syntactic forms that BDFL Guido permits you to have.
From: Fabien LE LEZ
Subject: Re: relativity of programming languages
Date: 
Message-ID: <1p97f2lgnku7ucsps1muvpqtju3aflbr9p@4ax.com>
On Mon, 28 Aug 2006 22:30:57 -0400, Raffael Cavallaro :

>1. Which of these two idioms is more "natural" is entirely a matter of 
>experience and taste. 

And since this is a Lisp newsgroup, I'm pretty sure a
out-of-the-textbook use of mapcar should be readily understandable by
most readers.
From: Jules
Subject: Re: relativity of programming languages
Date: 
Message-ID: <1156868798.046855.164180@i3g2000cwc.googlegroups.com>
William James' code is in Ruby, not Python?

You can easily tell that he's picked the numbers ad random because he
says that Ruby is faster than Python and Lisp is more popular than Ruby.
From: Robert Uhl
Subject: Re: relativity of programming languages
Date: 
Message-ID: <m31wqzuxhs.fsf@NOSPAMgmail.com>
Raffael Cavallaro <················@pas-d'espam-s'il-vous-plait-mac.com> writes:
>
> 1. Which of these two idioms is more "natural" is entirely a matter of
> experience and taste. I find the first more "natural" but that's
> because I program much more lisp than python. A python programmer
> would find the latter more "natural."

He might, but I'm pretty certain that the code in question is Ruby, not
Python.

-- 
Robert Uhl <http://public.xdi.org/=ruhl>
Isn't it amazing how a large number of evil morons can give the appearance
of being a single evil genius?                                --Mel Rimmer
From: Raffael Cavallaro
Subject: Re: relativity of programming languages
Date: 
Message-ID: <2006082916154175249-raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2006-08-29 15:56:31 -0400, Robert Uhl <·········@NOSPAMgmail.com> said:

> He might, but I'm pretty certain that the code in question is Ruby, not
> Python.

Right - I was kind of wondering when Python got Smalltalk style blocks 
and I'd somehow missed that :^) I just assumed we were still discussing 
the difference between lisp and Python which is how this thread started.

In any event just substitute "Matz" for "Guido" and the conclusion is 
the same - you can abstract syntax with lisp macros to give yourself 
any syntactic form you like. You can only use those syntactic forms 
that the langauge designer gives you in a language without real macros 
like Ruby (or Python, or Perl, etc.)