Skip navigation

Really Weird Conversation With David Pollak

========  From: Pierre R

Two interesting reddit post today :

http://www.perl.com/pub/a/2007/12/06/soto-11.html?page=1

http://www.dreamsongs.com/ObjectsHaveFailedNarrative.html

Some people believe Larry Wall is kind of crazy. I have actually a lot
of respect for him. Same for R P Gabriel I guess in a different
genre.

I really like this two guys ... It probably means I am a bit crazy
myself which is a good sign.

It reminds me of Samuel Beckett in "Waiting for Godot" (in French)
"On nait tous fous. Quelques uns le demeurent"

If someone have an English translation ... By the way Beckett mastery
in French is totally amazing.

========
========
=
=
========  From: Jason Dusek

These are neat articles, thanks for forwarding them along. I'm
not really pulling for Perl 6 -- I'd really like to see
something else come along in the scripting space -- but Larry
Wall's perspective is valuable to me even though his language
has ceased to be.

He says "both Perl and Ruby take their functional programming
support rather more seriously than Python does", but Python is
the only one of the three to offer first class functions. I
shudder at the thought of serious functional programming without
functions as values!

========
========
=
=
========  From: David Pollak

Jason Dusek wrote:
> These are neat articles, thanks for forwarding them along. I'm
> not really pulling for Perl 6 -- I'd really like to see
> something else come along in the scripting space -- but Larry
> Wall's perspective is valuable to me even though his language
> has ceased to be.
>
> He says "both Perl and Ruby take their functional programming
> support rather more seriously than Python does", but Python is
> the only one of the three to offer first class functions. I
> shudder at the thought of serious functional programming without
> functions as values!

Ruby has functions as values.  The wacky yield syntax is only sugar on top
of functions as values.

========
========
=
=
========  From: Jason Dusek

David Pollak wrote:
> Ruby has functions as values.  The wacky yield syntax is only
> sugar on top of functions as values.

Ruby has values as functions, but not functions as values. Try
this:

 def plus_one(val)
   val + 1
 end

 plusser = plus_one  # error at this line

Notice how we can not assign a function to a value. To get
close, we have to do the C++/Java trick of making an object with
an agreed upon 'execute' method -- and that is
values-as-functions, not functions-as-values. To put it another
way, functions in Ruby are not first class values.

As an aside, shouldn't "sugar" make the syntax sweeter, instead
of less verbose? I wrote Ruby for two years before learning
Python, by the way; and the switch was totally motivated by the
presence of first class functions in the latter language.

========
========
=
=
========  From: Jason Dusek

Jason Dusek wrote:
> As an aside, shouldn't "sugar" make the syntax sweeter,
> instead of less verbose? I wrote Ruby for two years before
> learning Python, by the way; and the switch was totally
> motivated by the presence of first class functions in the
> latter language.

Please amend the part after second comma, above, to "instead of
more verbose?".

========
========
=
=
========  From: David Pollak

pony:~ dpp$ irb
irb(main):001:0> def plus_one(val); val + 1; end
=> nil
irb(main):002:0> plus_one(33)
=> 34
irb(main):003:0> l =method('plus_one').to_proc

irb(main):007:0> l.call (44)
=> 45

So... even though the syntax is less than optimal, the ability to
store Procs (functions) in arrays, hashes, etc. exists.

========
========
=
=
========  From: Jason Dusek

The difference is *semantic* as well as syntactic -- a function
definition is an *expression* in Python or Haskell or
JavaScript, whereas it is a *statement* in Ruby and C and Perl.

Procs are not functions, they are objects. If you want to see,
just try calling the Proc directly, without calling any of it's
methods.

If you have to wrap a function in something in order to store
it, you by definition do not have first class functions.

========
========
=
=
========  From: David Pollak

Jason Dusek wrote:
> The difference is *semantic* as well as syntactic -- a function
> definition is an *expression* in Python or Haskell or
> JavaScript, whereas it is a *statement* in Ruby and C and Perl.
>
> Procs are not functions, they are objects. If you want to see,
> just try calling the Proc directly, without calling any of it's
> methods.
>
> If you have to wrap a function in something in order to store
> it, you by definition do not have first class functions.

So, Scala is does not have first class functions?  That'd be news to
people writing Scala code.

========
========
=
=
========  From: Jason Dusek
On Dec 6, 2007 6:19 PM, David Pollak wrote:
> On Dec 6, 2007, at 6:16 PM, Jason Dusek wrote:
> > If you have to wrap a function in something in order to store
> > it, you by definition do not have first class functions.
>
> So, Scala is does not have first class functions?  That'd be news to
> people writing Scala code.

You are going to have to show me some code before I can
say anything at all -- otherwise, what we've got here is
argument from authority ("those Scala people must know what they
are doing").

========
========
=
=
========  From: David Pollak

On Dec 6, 2007 6:34 PM, Jason Dusek  wrote:
> On Dec 6, 2007 6:19 PM, David Pollak  wrote:
> > On Dec 6, 2007, at 6:16 PM, Jason Dusek wrote:
> > > If you have to wrap a function in something in order to store
> > > it, you by definition do not have first class functions.
> >
> > So, Scala is does not have first class functions?  That'd be news to
> > people writing Scala code.
>
> You are going to have to show me some code before I can
> say anything at all -- otherwise, what we've got here is
> argument from authority ("those Scala people must know what they
> are doing").

lambda calculus in Ruby:
http://meta-meta.blogspot.com/2007/06/church-code.html

What is Scala?

Scala is a general purpose programming language designed to
express common programming patterns in a concise, elegant, and
type-safe way. It smoothly integrates features of
object-oriented and functional languages. It is also fully
interoperable with Java.

http://www.scala-lang.org/

Everything (even functions) are stored as Objects in both Scala
and Ruby.

Both have methods to invoke the functions (Scala calls this
method "apply" and Ruby calls it "call").  The Scala compiler
will convert f() to f.apply() if f is a subclass of Function,
but that's syntactic sugar on top of the Object wrapper.

They are functions because they are units of code that are
optionally bound to variables in a different scope (unlike
function pointers in C.)

They can be passed as parameters and they can be stored in data
structures (Lists, Hashes, etc.)

In terms of questioning the authority of a a large number of
people with PhDs in computer science as to whether Scala is a
functional programming language, where does your authority come
from?  Do you have a PhD?  What is your list of articles
published in peer reviewed journals?

Thanks

========
========
=
=
========  From: Jason Dusek 

David Pollak wrote:
> Both have methods to invoke the functions (Scala calls this
> method "apply" and Ruby calls it "call").  The Scala compiler
> will convert f() to f.apply() if f is a subclass of Function,
> but that's syntactic sugar on top of the Object wrapper.

That's part of the answer -- but how do you define functions in
Scala? Is Scala function definition in the world of statements
or the world of expressions?

> where does your authority come from?  Do you have a PhD?  What
> is your list of articles published in peer reviewed journals?

I don't have a college education, David -- but I have millions
of dollars. Ergo, I'm right. QED.

========
========
=
=
========  From: David Pollak

On 12/7/07, Jason Dusek  wrote:
> David Pollak  wrote:
> > Both have methods to invoke the functions (Scala calls this
> > method "apply" and Ruby calls it "call").  The Scala compiler
> > will convert f() to f.apply() if f is a subclass of Function,
> > but that's syntactic sugar on top of the Object wrapper.
>
> That's part of the answer -- but how do you define functions in
> Scala? Is Scala function definition in the world of statements
> or the world of expressions?

This is not part of the answer.  The syntax of creating a
function is immaterial as to the ability to, for example, do
Church Encoding.

Incomplete — will finish transferring convo later.

Advertisements

Post a Comment

You must be logged in to post a comment.
%d bloggers like this: