Smalltalk and functional programming

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Smalltalk and functional programming

Frank Shearar
Hi,

I'm engaged in a discussion with someone
(http://stackoverflow.com/questions/3527753) on whether Smalltalk is or
is not a functional programming language.

Now admittedly no one in the argument has defined what exactly
checkboxes a language needs to tick to qualify as an FPL. (Also, "Foo
is/is not a Bar" discussions tend to generate more heat than light.)

So at any rate, my position is that because it's natural and idiomatic
to program in Smalltalk in a functional way (see Point class and the
Collection API - #collect:, #select:, #reduce: and friends), yes,
Smalltalk is a FPL.

I'm not quite sure what position igouy holds. Or, rather, I know that he
(I'll just use the English male pronouns here for brevity) says that
Smalltalk's not a FPL, but I'm not sure why. He talks of there being no
way to define named functions outside of a class as being the reason,
but I'm sure that can't be all of it. (You can - Smalltalk at : #square
put: [:x| x * x] - but that's hardly idiomatic.)

At any rate, I've spent a while thinking about the matter, so I'm happy
either way.

It seems to me that the _real_ reason one might label Smalltalk as not
being a FPL is mutable state.

You can, with a smidge of discipline, happily write a functional object.
But it's just as easy to write a mutable object.

Point is a good example of a Value Object (aka "immutable state") as is,
if I recall correctly, Rectangle: methods either return part of the
state of an object (0@0 x) or, if they're state-mutating, return a new
object with the required state (0@0 translateBy: 1@1). There's a mild
hiccup here, where your "return a new object with new state" must
initialise the new object. Point does this by having #setX:setY: in the
'private' category.

But this discipline isn't enforced by the language/environment, which
for some might be a necessary condition for FPL-ness.

Or have I missed the point of what makes a language an FPL?

frank

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Rob Withers-2
You can write a Y-combinator in Smalltalk.  As you point out you can write
Function objects.  You can do currying.  You can do eval.

Smalltalk is a dynamic fuctional object-oriented language.

Rob

--------------------------------------------------
From: "Frank Shearar" <[hidden email]>
Sent: Tuesday, August 24, 2010 8:58 AM
To: "The general-purpose Squeak developers list"
<[hidden email]>
Subject: [squeak-dev] Smalltalk and functional programming

> Hi,
>
> I'm engaged in a discussion with someone
> (http://stackoverflow.com/questions/3527753) on whether Smalltalk is or is
> not a functional programming language.
>
> Now admittedly no one in the argument has defined what exactly checkboxes
> a language needs to tick to qualify as an FPL. (Also, "Foo is/is not a
> Bar" discussions tend to generate more heat than light.)
>
> So at any rate, my position is that because it's natural and idiomatic to
> program in Smalltalk in a functional way (see Point class and the
> Collection API - #collect:, #select:, #reduce: and friends), yes,
> Smalltalk is a FPL.
>
> I'm not quite sure what position igouy holds. Or, rather, I know that he
> (I'll just use the English male pronouns here for brevity) says that
> Smalltalk's not a FPL, but I'm not sure why. He talks of there being no
> way to define named functions outside of a class as being the reason, but
> I'm sure that can't be all of it. (You can - Smalltalk at : #square put:
> [:x| x * x] - but that's hardly idiomatic.)
>
> At any rate, I've spent a while thinking about the matter, so I'm happy
> either way.
>
> It seems to me that the _real_ reason one might label Smalltalk as not
> being a FPL is mutable state.
>
> You can, with a smidge of discipline, happily write a functional object.
> But it's just as easy to write a mutable object.
>
> Point is a good example of a Value Object (aka "immutable state") as is,
> if I recall correctly, Rectangle: methods either return part of the state
> of an object (0@0 x) or, if they're state-mutating, return a new object
> with the required state (0@0 translateBy: 1@1). There's a mild hiccup
> here, where your "return a new object with new state" must initialise the
> new object. Point does this by having #setX:setY: in the 'private'
> category.
>
> But this discipline isn't enforced by the language/environment, which for
> some might be a necessary condition for FPL-ness.
>
> Or have I missed the point of what makes a language an FPL?
>
> frank
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Michael Haupt-3
Rob,

On Tue, Aug 24, 2010 at 3:19 PM, Rob Withers <[hidden email]> wrote:
> Smalltalk is a dynamic fuctional object-oriented language.

you forgot "imperative" and, hey, since you can implement Prolog in
it, "logic". ;-) Sorry for the sarcasm, but Turing completeness just
bites. (Yes, it's a bottom argument, but this kind of question just
calls for it.)

If someone'd ask me, I'd respond that Smalltalk is IMHO not a
functional language. What is the primary means of abstraction at work
in Smalltalk? Not functions, right?

The other way around, would you agree that, uh, Haskell is an
object-oriented language because you can somehow emulate objects and
state using monads?

Best,

Michael

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Alejandro F. Reimondo
In reply to this post by Rob Withers-2

> Smalltalk is a dynamic fuctional object-oriented language.

Smalltalk is a trayectory in time; it what happens to a body
 in-formation when it change through time ... and survives
 that "unique" experience.
It is not it's "definition" nor it contents; because it can
 change while you are still trying to constrain it to a
 description.
Relax and use the part of your smalltalk in the computer;
 but don't forget that there are other parts of your smalltalk
 (some parts outside computer and otehr parts seen
 only in retrospective -sometimes described as
 software evolution- ).

have a good smalltalking day,
Ale.






----- Original Message -----
From: "Rob Withers" <[hidden email]>
To: "The general-purpose Squeak developers list"
<[hidden email]>
Sent: Tuesday, August 24, 2010 10:19 AM
Subject: Re: [squeak-dev] Smalltalk and functional programming


> You can write a Y-combinator in Smalltalk.  As you point out you can write
> Function objects.  You can do currying.  You can do eval.
>
> Smalltalk is a dynamic fuctional object-oriented language.
>
> Rob
>
> --------------------------------------------------
> From: "Frank Shearar" <[hidden email]>
> Sent: Tuesday, August 24, 2010 8:58 AM
> To: "The general-purpose Squeak developers list"
> <[hidden email]>
> Subject: [squeak-dev] Smalltalk and functional programming
>
>> Hi,
>>
>> I'm engaged in a discussion with someone
>> (http://stackoverflow.com/questions/3527753) on whether Smalltalk is or
>> is not a functional programming language.
>>
>> Now admittedly no one in the argument has defined what exactly checkboxes
>> a language needs to tick to qualify as an FPL. (Also, "Foo is/is not a
>> Bar" discussions tend to generate more heat than light.)
>>
>> So at any rate, my position is that because it's natural and idiomatic to
>> program in Smalltalk in a functional way (see Point class and the
>> Collection API - #collect:, #select:, #reduce: and friends), yes,
>> Smalltalk is a FPL.
>>
>> I'm not quite sure what position igouy holds. Or, rather, I know that he
>> (I'll just use the English male pronouns here for brevity) says that
>> Smalltalk's not a FPL, but I'm not sure why. He talks of there being no
>> way to define named functions outside of a class as being the reason, but
>> I'm sure that can't be all of it. (You can - Smalltalk at : #square put:
>> [:x| x * x] - but that's hardly idiomatic.)
>>
>> At any rate, I've spent a while thinking about the matter, so I'm happy
>> either way.
>>
>> It seems to me that the _real_ reason one might label Smalltalk as not
>> being a FPL is mutable state.
>>
>> You can, with a smidge of discipline, happily write a functional object.
>> But it's just as easy to write a mutable object.
>>
>> Point is a good example of a Value Object (aka "immutable state") as is,
>> if I recall correctly, Rectangle: methods either return part of the state
>> of an object (0@0 x) or, if they're state-mutating, return a new object
>> with the required state (0@0 translateBy: 1@1). There's a mild hiccup
>> here, where your "return a new object with new state" must initialise the
>> new object. Point does this by having #setX:setY: in the 'private'
>> category.
>>
>> But this discipline isn't enforced by the language/environment, which for
>> some might be a necessary condition for FPL-ness.
>>
>> Or have I missed the point of what makes a language an FPL?
>>
>> frank
>>
>>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

jsarkela
+9

This is one of the most concise descriptions of Smalltalk I have ever read. It reminds me of G. Spencer-Brown's description of evolution of signal through a form.

John Sarkela

On Aug 24, 2010, at 9:31 AM, Alejandro F. Reimondo wrote:

>
>> Smalltalk is a dynamic fuctional object-oriented language.
>
> Smalltalk is a trayectory in time; it what happens to a body
> in-formation when it change through time ... and survives
> that "unique" experience.
> It is not it's "definition" nor it contents; because it can
> change while you are still trying to constrain it to a
> description.
> Relax and use the part of your smalltalk in the computer;
> but don't forget that there are other parts of your smalltalk
> (some parts outside computer and otehr parts seen
> only in retrospective -sometimes described as
> software evolution- ).
>
> have a good smalltalking day,
> Ale.
>
>
>
>
>
>
> ----- Original Message ----- From: "Rob Withers" <[hidden email]>
> To: "The general-purpose Squeak developers list" <[hidden email]>
> Sent: Tuesday, August 24, 2010 10:19 AM
> Subject: Re: [squeak-dev] Smalltalk and functional programming
>
>
>> You can write a Y-combinator in Smalltalk.  As you point out you can write Function objects.  You can do currying.  You can do eval.
>>
>> Smalltalk is a dynamic fuctional object-oriented language.
>>
>> Rob
>>
>> --------------------------------------------------
>> From: "Frank Shearar" <[hidden email]>
>> Sent: Tuesday, August 24, 2010 8:58 AM
>> To: "The general-purpose Squeak developers list" <[hidden email]>
>> Subject: [squeak-dev] Smalltalk and functional programming
>>
>>> Hi,
>>>
>>> I'm engaged in a discussion with someone (http://stackoverflow.com/questions/3527753) on whether Smalltalk is or is not a functional programming language.
>>>
>>> Now admittedly no one in the argument has defined what exactly checkboxes a language needs to tick to qualify as an FPL. (Also, "Foo is/is not a Bar" discussions tend to generate more heat than light.)
>>>
>>> So at any rate, my position is that because it's natural and idiomatic to program in Smalltalk in a functional way (see Point class and the Collection API - #collect:, #select:, #reduce: and friends), yes, Smalltalk is a FPL.
>>>
>>> I'm not quite sure what position igouy holds. Or, rather, I know that he (I'll just use the English male pronouns here for brevity) says that Smalltalk's not a FPL, but I'm not sure why. He talks of there being no way to define named functions outside of a class as being the reason, but I'm sure that can't be all of it. (You can - Smalltalk at : #square put: [:x| x * x] - but that's hardly idiomatic.)
>>>
>>> At any rate, I've spent a while thinking about the matter, so I'm happy either way.
>>>
>>> It seems to me that the _real_ reason one might label Smalltalk as not being a FPL is mutable state.
>>>
>>> You can, with a smidge of discipline, happily write a functional object. But it's just as easy to write a mutable object.
>>>
>>> Point is a good example of a Value Object (aka "immutable state") as is, if I recall correctly, Rectangle: methods either return part of the state of an object (0@0 x) or, if they're state-mutating, return a new object with the required state (0@0 translateBy: 1@1). There's a mild hiccup here, where your "return a new object with new state" must initialise the new object. Point does this by having #setX:setY: in the 'private' category.
>>>
>>> But this discipline isn't enforced by the language/environment, which for some might be a necessary condition for FPL-ness.
>>>
>>> Or have I missed the point of what makes a language an FPL?
>>>
>>> frank
>>>
>>>
>>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Igor Stasenko
In reply to this post by Alejandro F. Reimondo
On 24 August 2010 16:31, Alejandro F. Reimondo
<[hidden email]> wrote:
>
>> Smalltalk is a dynamic fuctional object-oriented language.
>
> Smalltalk is a trayectory in time; it what happens to a body
> in-formation when it change through time ... and survives
> that "unique" experience.
> It is not it's "definition" nor it contents; because it can
> change while you are still trying to constrain it to a
> description.

Yup. What makes smalltalk to be smalltalk is an evironment of live objects,
not its syntax or rules (because they can be easily changed at run-time).

> Relax and use the part of your smalltalk in the computer;
> but don't forget that there are other parts of your smalltalk
> (some parts outside computer and otehr parts seen
> only in retrospective -sometimes described as
> software evolution- ).
>
> have a good smalltalking day,
> Ale.
>
>
>
>
>
>
> ----- Original Message ----- From: "Rob Withers" <[hidden email]>
> To: "The general-purpose Squeak developers list"
> <[hidden email]>
> Sent: Tuesday, August 24, 2010 10:19 AM
> Subject: Re: [squeak-dev] Smalltalk and functional programming
>
>
>> You can write a Y-combinator in Smalltalk.  As you point out you can write
>> Function objects.  You can do currying.  You can do eval.
>>
>> Smalltalk is a dynamic fuctional object-oriented language.
>>
>> Rob
>>
>> --------------------------------------------------
>> From: "Frank Shearar" <[hidden email]>
>> Sent: Tuesday, August 24, 2010 8:58 AM
>> To: "The general-purpose Squeak developers list"
>> <[hidden email]>
>> Subject: [squeak-dev] Smalltalk and functional programming
>>
>>> Hi,
>>>
>>> I'm engaged in a discussion with someone
>>> (http://stackoverflow.com/questions/3527753) on whether Smalltalk is or is
>>> not a functional programming language.
>>>
>>> Now admittedly no one in the argument has defined what exactly checkboxes
>>> a language needs to tick to qualify as an FPL. (Also, "Foo is/is not a Bar"
>>> discussions tend to generate more heat than light.)
>>>
>>> So at any rate, my position is that because it's natural and idiomatic to
>>> program in Smalltalk in a functional way (see Point class and the Collection
>>> API - #collect:, #select:, #reduce: and friends), yes, Smalltalk is a FPL.
>>>
>>> I'm not quite sure what position igouy holds. Or, rather, I know that he
>>> (I'll just use the English male pronouns here for brevity) says that
>>> Smalltalk's not a FPL, but I'm not sure why. He talks of there being no way
>>> to define named functions outside of a class as being the reason, but I'm
>>> sure that can't be all of it. (You can - Smalltalk at : #square put: [:x| x
>>> * x] - but that's hardly idiomatic.)
>>>
>>> At any rate, I've spent a while thinking about the matter, so I'm happy
>>> either way.
>>>
>>> It seems to me that the _real_ reason one might label Smalltalk as not
>>> being a FPL is mutable state.
>>>
>>> You can, with a smidge of discipline, happily write a functional object.
>>> But it's just as easy to write a mutable object.
>>>
>>> Point is a good example of a Value Object (aka "immutable state") as is,
>>> if I recall correctly, Rectangle: methods either return part of the state of
>>> an object (0@0 x) or, if they're state-mutating, return a new object with
>>> the required state (0@0 translateBy: 1@1). There's a mild hiccup here, where
>>> your "return a new object with new state" must initialise the new object.
>>> Point does this by having #setX:setY: in the 'private' category.
>>>
>>> But this discipline isn't enforced by the language/environment, which for
>>> some might be a necessary condition for FPL-ness.
>>>
>>> Or have I missed the point of what makes a language an FPL?
>>>
>>> frank
>>>
>>>
>>
>>
>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Alejandro F. Reimondo
Hi Igor,

>Yup. What makes smalltalk to be smalltalk is
> an evironment of live objects,

[I have not made any relationship with life.
 I don´t know what "life of an object" is :-) ]

>not its syntax or rules (because they can be easily
> changed at run-time).

The preservation of it identity.
As a system it is defined as something that
 when ovserved through time preserves identity.
 (it is also the only caracteristic of anObject
 that distinguish as an object and not been
 only "something" )

Ale.




----- Original Message -----
From: "Igor Stasenko" <[hidden email]>
To: "The general-purpose Squeak developers list"
<[hidden email]>
Sent: Tuesday, August 24, 2010 10:47 AM
Subject: Re: [squeak-dev] Smalltalk and functional programming


On 24 August 2010 16:31, Alejandro F. Reimondo
<[hidden email]> wrote:
>
>> Smalltalk is a dynamic fuctional object-oriented language.
>
> Smalltalk is a trayectory in time; it what happens to a body
> in-formation when it change through time ... and survives
> that "unique" experience.
> It is not it's "definition" nor it contents; because it can
> change while you are still trying to constrain it to a
> description.

Yup. What makes smalltalk to be smalltalk is an evironment of live objects,
not its syntax or rules (because they can be easily changed at run-time).

> Relax and use the part of your smalltalk in the computer;
> but don't forget that there are other parts of your smalltalk
> (some parts outside computer and otehr parts seen
> only in retrospective -sometimes described as
> software evolution- ).
>
> have a good smalltalking day,
> Ale.
>
>
>
>
>
>
> ----- Original Message ----- From: "Rob Withers" <[hidden email]>
> To: "The general-purpose Squeak developers list"
> <[hidden email]>
> Sent: Tuesday, August 24, 2010 10:19 AM
> Subject: Re: [squeak-dev] Smalltalk and functional programming
>
>
>> You can write a Y-combinator in Smalltalk. As you point out you can write
>> Function objects. You can do currying. You can do eval.
>>
>> Smalltalk is a dynamic fuctional object-oriented language.
>>
>> Rob
>>
>> --------------------------------------------------
>> From: "Frank Shearar" <[hidden email]>
>> Sent: Tuesday, August 24, 2010 8:58 AM
>> To: "The general-purpose Squeak developers list"
>> <[hidden email]>
>> Subject: [squeak-dev] Smalltalk and functional programming
>>
>>> Hi,
>>>
>>> I'm engaged in a discussion with someone
>>> (http://stackoverflow.com/questions/3527753) on whether Smalltalk is or
>>> is
>>> not a functional programming language.
>>>
>>> Now admittedly no one in the argument has defined what exactly
>>> checkboxes
>>> a language needs to tick to qualify as an FPL. (Also, "Foo is/is not a
>>> Bar"
>>> discussions tend to generate more heat than light.)
>>>
>>> So at any rate, my position is that because it's natural and idiomatic
>>> to
>>> program in Smalltalk in a functional way (see Point class and the
>>> Collection
>>> API - #collect:, #select:, #reduce: and friends), yes, Smalltalk is a
>>> FPL.
>>>
>>> I'm not quite sure what position igouy holds. Or, rather, I know that he
>>> (I'll just use the English male pronouns here for brevity) says that
>>> Smalltalk's not a FPL, but I'm not sure why. He talks of there being no
>>> way
>>> to define named functions outside of a class as being the reason, but
>>> I'm
>>> sure that can't be all of it. (You can - Smalltalk at : #square put:
>>> [:x| x
>>> * x] - but that's hardly idiomatic.)
>>>
>>> At any rate, I've spent a while thinking about the matter, so I'm happy
>>> either way.
>>>
>>> It seems to me that the _real_ reason one might label Smalltalk as not
>>> being a FPL is mutable state.
>>>
>>> You can, with a smidge of discipline, happily write a functional object.
>>> But it's just as easy to write a mutable object.
>>>
>>> Point is a good example of a Value Object (aka "immutable state") as is,
>>> if I recall correctly, Rectangle: methods either return part of the
>>> state of
>>> an object (0@0 x) or, if they're state-mutating, return a new object
>>> with
>>> the required state (0@0 translateBy: 1@1). There's a mild hiccup here,
>>> where
>>> your "return a new object with new state" must initialise the new
>>> object.
>>> Point does this by having #setX:setY: in the 'private' category.
>>>
>>> But this discipline isn't enforced by the language/environment, which
>>> for
>>> some might be a necessary condition for FPL-ness.
>>>
>>> Or have I missed the point of what makes a language an FPL?
>>>
>>> frank
>>>
>>>
>>
>>
>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.




Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Nicolas Cellier
2010/8/24 Alejandro F. Reimondo <[hidden email]>:

> Hi Igor,
>
>> Yup. What makes smalltalk to be smalltalk is
>> an evironment of live objects,
>
> [I have not made any relationship with life.
> I don´t know what "life of an object" is :-) ]
>
>> not its syntax or rules (because they can be easily
>> changed at run-time).
>
> The preservation of it identity.
> As a system it is defined as something that
> when ovserved through time preserves identity.
> (it is also the only caracteristic of anObject
> that distinguish as an object and not been
> only "something" )
>
> Ale.
>

Since an object preserves its identity, we can track it's creation and
deletion. It thus has a birth and death, not enough attributes for
using a life metaphore ?

Nicolas

>
>
>
> ----- Original Message ----- From: "Igor Stasenko" <[hidden email]>
> To: "The general-purpose Squeak developers list"
> <[hidden email]>
> Sent: Tuesday, August 24, 2010 10:47 AM
> Subject: Re: [squeak-dev] Smalltalk and functional programming
>
>
> On 24 August 2010 16:31, Alejandro F. Reimondo
> <[hidden email]> wrote:
>>
>>> Smalltalk is a dynamic fuctional object-oriented language.
>>
>> Smalltalk is a trayectory in time; it what happens to a body
>> in-formation when it change through time ... and survives
>> that "unique" experience.
>> It is not it's "definition" nor it contents; because it can
>> change while you are still trying to constrain it to a
>> description.
>
> Yup. What makes smalltalk to be smalltalk is an evironment of live objects,
> not its syntax or rules (because they can be easily changed at run-time).
>
>> Relax and use the part of your smalltalk in the computer;
>> but don't forget that there are other parts of your smalltalk
>> (some parts outside computer and otehr parts seen
>> only in retrospective -sometimes described as
>> software evolution- ).
>>
>> have a good smalltalking day,
>> Ale.
>>
>>
>>
>>
>>
>>
>> ----- Original Message ----- From: "Rob Withers" <[hidden email]>
>> To: "The general-purpose Squeak developers list"
>> <[hidden email]>
>> Sent: Tuesday, August 24, 2010 10:19 AM
>> Subject: Re: [squeak-dev] Smalltalk and functional programming
>>
>>
>>> You can write a Y-combinator in Smalltalk. As you point out you can write
>>> Function objects. You can do currying. You can do eval.
>>>
>>> Smalltalk is a dynamic fuctional object-oriented language.
>>>
>>> Rob
>>>
>>> --------------------------------------------------
>>> From: "Frank Shearar" <[hidden email]>
>>> Sent: Tuesday, August 24, 2010 8:58 AM
>>> To: "The general-purpose Squeak developers list"
>>> <[hidden email]>
>>> Subject: [squeak-dev] Smalltalk and functional programming
>>>
>>>> Hi,
>>>>
>>>> I'm engaged in a discussion with someone
>>>> (http://stackoverflow.com/questions/3527753) on whether Smalltalk is or
>>>> is
>>>> not a functional programming language.
>>>>
>>>> Now admittedly no one in the argument has defined what exactly
>>>> checkboxes
>>>> a language needs to tick to qualify as an FPL. (Also, "Foo is/is not a
>>>> Bar"
>>>> discussions tend to generate more heat than light.)
>>>>
>>>> So at any rate, my position is that because it's natural and idiomatic
>>>> to
>>>> program in Smalltalk in a functional way (see Point class and the
>>>> Collection
>>>> API - #collect:, #select:, #reduce: and friends), yes, Smalltalk is a
>>>> FPL.
>>>>
>>>> I'm not quite sure what position igouy holds. Or, rather, I know that he
>>>> (I'll just use the English male pronouns here for brevity) says that
>>>> Smalltalk's not a FPL, but I'm not sure why. He talks of there being no
>>>> way
>>>> to define named functions outside of a class as being the reason, but
>>>> I'm
>>>> sure that can't be all of it. (You can - Smalltalk at : #square put:
>>>> [:x| x
>>>> * x] - but that's hardly idiomatic.)
>>>>
>>>> At any rate, I've spent a while thinking about the matter, so I'm happy
>>>> either way.
>>>>
>>>> It seems to me that the _real_ reason one might label Smalltalk as not
>>>> being a FPL is mutable state.
>>>>
>>>> You can, with a smidge of discipline, happily write a functional object.
>>>> But it's just as easy to write a mutable object.
>>>>
>>>> Point is a good example of a Value Object (aka "immutable state") as is,
>>>> if I recall correctly, Rectangle: methods either return part of the
>>>> state of
>>>> an object (0@0 x) or, if they're state-mutating, return a new object
>>>> with
>>>> the required state (0@0 translateBy: 1@1). There's a mild hiccup here,
>>>> where
>>>> your "return a new object with new state" must initialise the new
>>>> object.
>>>> Point does this by having #setX:setY: in the 'private' category.
>>>>
>>>> But this discipline isn't enforced by the language/environment, which
>>>> for
>>>> some might be a necessary condition for FPL-ness.
>>>>
>>>> Or have I missed the point of what makes a language an FPL?
>>>>
>>>> frank
>>>>
>>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Frank Shearar
In reply to this post by Michael Haupt-3
On 2010/08/24 15:27, Michael Haupt wrote:

> Rob,
>
> On Tue, Aug 24, 2010 at 3:19 PM, Rob Withers<[hidden email]>  wrote:
>> Smalltalk is a dynamic fuctional object-oriented language.
>
> you forgot "imperative" and, hey, since you can implement Prolog in
> it, "logic". ;-) Sorry for the sarcasm, but Turing completeness just
> bites. (Yes, it's a bottom argument, but this kind of question just
> calls for it.)
>
> If someone'd ask me, I'd respond that Smalltalk is IMHO not a
> functional language. What is the primary means of abstraction at work
> in Smalltalk? Not functions, right?
>
> The other way around, would you agree that, uh, Haskell is an
> object-oriented language because you can somehow emulate objects and
> state using monads?

Well, that's the thing. If you tried to write OO in Haskell, you'd fight
the language, right? It's not natural to use Haskell to write OO.
Similarly, you don't write OO in C because it _hurts_.

On the other hand, while clearly not a pure functional language like
Haskell, it's not hard - it's _easy_ - to write in a functional manner.

Languages support certain ways of working better than others. Smalltalk
seems to support working in a functional manner rather well. (In
contrast, try doing so in Delphi. I don't recommend it.)

(Everything in Common Lisp is an object, so is that not an FPL anymore?)

So, in my book, if a tool's good for hitting things, it's a hammer.
Whether that hammer has a metal end and a wooden handle, or a rock, I
don't really care.

Saying that Smalltalk isn't an FPL because its functions all happen to
be associated with a class just seems foolish to me.

At any rate, it seems I'm relatively alone in thinking this way, which
is fine by me.

frank

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Lukas Renggli
> At any rate, it seems I'm relatively alone in thinking this way, which is
> fine by me.

No, you are not alone. I am glad that Smalltalk has the good features
of both object-oriented and functional languages.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Jecel Assumpcao Jr
Anyone interested in Smalltalk as a functional programming language
should contrast Smalltalk-80 with -72, specially as described in "The
Early History of Smalltalk" by Alan Kay. That early version didn't have
individual methods and one possible programming style was to use a class
as a function (with a very Logo-like syntax). The earlier -71 design
(never actually implemented) with its pattern matching looked even more
like currently popular functional languages.

-- Jecel


Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Colin Putney
In reply to this post by Frank Shearar

On 2010-08-24, at 9:35 AM, Frank Shearar wrote:

> Saying that Smalltalk isn't an FPL because its functions all happen to be associated with a class just seems foolish to me.


It is true that Smalltalk has a kind of "functional OO" flavour that is notably different from the "procedural OO" flavour that, say, C++ has.

But I think you'd be doing a disservice to your audience if you call Smalltalk a functional language. The Big Idea behind Smalltalk was to limit mutability to the local object, and do everything with messages. The Big Idea in functional languages is to limit mutability to the stack and do everything with function application. Neither approach can be completely pure, so of course you can make functions out of objects and objects out of functions. Since it all boils down to machine code at the bottom, I think the utility of OO and FP really come from the way they help us think about programming. They're defined more by style than by crisp sets of tick boxes.

Smalltalk and it's libraries are designed to be used in an OO style, and it doesn't make a lot of sense to write Smalltalk code in a functional style, even though it's possible. This is actually the reason I dislike CLOS: it's certainly possible to write Lisp in an OO style, but if you really want objects, you shouldn't be using Lisp. Similarly, if you want functions, you shouldn't write them in Smalltalk.

Colin
Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Rob Withers-2
In reply to this post by Michael Haupt-3
Yes, I forgot "logic", but this raises a good point.   I brushed by what I
really meant, which is not that the Squeak language is a dynamic functional
object-oriented language, but rather that the Squeak environment supports
dynamic OO, functional, yes logic, and probably statically typed OO
languages.   Is a Closure part of the language or the environment?

I would like the original poster to challenge his functional friends to
write a Haskell or Ocaml compiler in Squeak, a la the Prolog compiler that
exists somewhere on the net (SqueakSource?).   They can specify a Class
which uses the Ocaml compiler and compile the methods as functions - or
whatever works best.   Perfectly doable, I surmise.

As Alejandro is saying, paraphrasing, it is all about the environment, not
the language.

Cheers,
Rob

--------------------------------------------------
From: "Michael Haupt" <[hidden email]>
Sent: Tuesday, August 24, 2010 9:27 AM
To: "The general-purpose Squeak developers list"
<[hidden email]>
Subject: Re: [squeak-dev] Smalltalk and functional programming

> Rob,
>
> On Tue, Aug 24, 2010 at 3:19 PM, Rob Withers <[hidden email]> wrote:
>> Smalltalk is a dynamic fuctional object-oriented language.
>
> you forgot "imperative" and, hey, since you can implement Prolog in
> it, "logic". ;-) Sorry for the sarcasm, but Turing completeness just
> bites. (Yes, it's a bottom argument, but this kind of question just
> calls for it.)
>
> If someone'd ask me, I'd respond that Smalltalk is IMHO not a
> functional language. What is the primary means of abstraction at work
> in Smalltalk? Not functions, right?
>
> The other way around, would you agree that, uh, Haskell is an
> object-oriented language because you can somehow emulate objects and
> state using monads?
>
> Best,
>
> Michael
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Chris Cunnington
In reply to this post by Frank Shearar
Perhaps somebody would be willing to show a piece of code written in a functional style?

This was presented but then quickly dismissed: Smalltalk at: #square put: [: x| x * x ]


Chris 



Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Michael Haupt-3
In reply to this post by Frank Shearar
Hi Frank,

On Tue, Aug 24, 2010 at 6:35 PM, Frank Shearar
<[hidden email]> wrote:
> Well, that's the thing. If you tried to write OO in Haskell, you'd fight the
> language, right? It's not natural to use Haskell to write OO. Similarly, you
> don't write OO in C because it _hurts_.

been there. Once you get the macros right, the pain fades away and
becomes a slightly annoying throb. ;-) Which is to say it was not that
bad after all.

About Haskell: I'm not (yet) familiar with monads and state in Haskell
(getting there, slowly), but I have the strong impression that writing
monadic code is about as elegant as most other things in Haskell. I
would not say it's particularly hard to "do" OO in Haskell. It's not
the primary abstraction, but a sufficiently capable Haskell programmer
would perhaps not feel bad about it. Just as a sufficiently capable
Smalltalker would not feel bad about "doing" things in functional
style here and there in Smalltalk.

> On the other hand, while clearly not a pure functional language like
> Haskell, it's not hard - it's _easy_ - to write in a functional manner.

That's what I meant above.

> Saying that Smalltalk isn't an FPL because its functions all happen to be
> associated with a class just seems foolish to me.

But that is not the case, right? How about blocks as closures?

Best,

Michael

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Igor Stasenko
I wonder, what makes language to be 'functional'?


As to me, its not a syntax in particular (syntax can be changed anyways),
but being able to use declarative style for defining behavior, not
imperative one.

And from this side, smalltalk is quite capable in it.

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Alejandro F. Reimondo
In reply to this post by Frank Shearar
Hi,

> Saying that Smalltalk isn't an FPL because its functions all happen to be
> associated with a class just seems foolish to me.

There is no Function class in most of my images, and all
 are instances of Smalltalk. ;-)  (all survived the changes
 I made from the day I downloaded somewhere)

If we consider messages..., can be undestood
 (or not) by an object, but it do not mean that we can associate
 the receiver with the message, because the receiver
 can change and do/doNot understand the same message
 when we are still reading this sentence.

There are many instances of smalltalk family that
 support instance based behavior from long time,
 so we can start to accept/consider that evidence to
 undestand that smalltalk do not mean what
 was defined +20 years ago...

Diversity is something present in Smalltalk today.
The language model is a model of exclusion and irresponsibility;
 you change/delete one rule and you have ANOTHER language
 with no relationship with the "old" language.
In a world of change sustainability (of the environment) is more
 important than definition and contents.
If we define smalltalk as a language, people think that
 there are things that can´t be done with Smalltalk (with objects);
 and it is not the case today with modern smalltalk VM.

best,
Ale.




----- Original Message -----
From: "Frank Shearar" <[hidden email]>
To: "The general-purpose Squeak developers list"
<[hidden email]>
Sent: Tuesday, August 24, 2010 1:35 PM
Subject: Re: [squeak-dev] Smalltalk and functional programming


> On 2010/08/24 15:27, Michael Haupt wrote:
>> Rob,
>>
>> On Tue, Aug 24, 2010 at 3:19 PM, Rob Withers<[hidden email]>  wrote:
>>> Smalltalk is a dynamic fuctional object-oriented language.
>>
>> you forgot "imperative" and, hey, since you can implement Prolog in
>> it, "logic". ;-) Sorry for the sarcasm, but Turing completeness just
>> bites. (Yes, it's a bottom argument, but this kind of question just
>> calls for it.)
>>
>> If someone'd ask me, I'd respond that Smalltalk is IMHO not a
>> functional language. What is the primary means of abstraction at work
>> in Smalltalk? Not functions, right?
>>
>> The other way around, would you agree that, uh, Haskell is an
>> object-oriented language because you can somehow emulate objects and
>> state using monads?
>
> Well, that's the thing. If you tried to write OO in Haskell, you'd fight
> the language, right? It's not natural to use Haskell to write OO.
> Similarly, you don't write OO in C because it _hurts_.
>
> On the other hand, while clearly not a pure functional language like
> Haskell, it's not hard - it's _easy_ - to write in a functional manner.
>
> Languages support certain ways of working better than others. Smalltalk
> seems to support working in a functional manner rather well. (In contrast,
> try doing so in Delphi. I don't recommend it.)
>
> (Everything in Common Lisp is an object, so is that not an FPL anymore?)
>
> So, in my book, if a tool's good for hitting things, it's a hammer.
> Whether that hammer has a metal end and a wooden handle, or a rock, I
> don't really care.
>
> Saying that Smalltalk isn't an FPL because its functions all happen to be
> associated with a class just seems foolish to me.
>
> At any rate, it seems I'm relatively alone in thinking this way, which is
> fine by me.
>
> frank
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Stéphane Rollandin
In reply to this post by Chris Cunnington
Le 24/08/2010 20:07, Chris Cunnington a écrit :
> Perhaps somebody would be willing to show a piece of code written in a
> functional style?
>
> This was presented but then quickly dismissed: Smalltalk at: #square
> put: [: x| x * x ]
>
>
> Chris

| f g h |

f := Lambda m position: 100 @ 100.
g := Lambda m color: Color red.
h := Lambda m openInWorld.

h <~ Morph new. "shows a Morph"
h <= g <~ Morph new. "shows a red Morph".
h <= g <= f <~ Morph new. "shows a red Morph at 100 @ 100".


... more about this at:
http://www.zogotounga.net/comp/squeak/functionaltalk.htm


Stef



Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Hannes Hirzel
On 8/30/10, Stéphane Rollandin <[hidden email]> wrote:

> Le 24/08/2010 20:07, Chris Cunnington a écrit :
>> Perhaps somebody would be willing to show a piece of code written in a
>> functional style?
>>
>> This was presented but then quickly dismissed: Smalltalk at: #square
>> put: [: x| x * x ]
>>
>>
>> Chris
>
> | f g h |
>
> f := Lambda m position: 100 @ 100.
> g := Lambda m color: Color red.
> h := Lambda m openInWorld.
>
> h <~ Morph new. "shows a Morph"
> h <= g <~ Morph new. "shows a red Morph".
> h <= g <= f <~ Morph new. "shows a red Morph at 100 @ 100".
>
>
> ... more about this at:
> http://www.zogotounga.net/comp/squeak/functionaltalk.htm
>
>
> Stef
>

Great illustration, Stéphane

What about opening a project 'FunctionalProgramming' in FunSqueak with
a few workspaces, some comments and code snippets like this.

--Hannes

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk and functional programming

Chris Cunnington
In reply to this post by Frank Shearar
Thank you for the example and the link to more. 
Lots of progressing examples to go try in Workspace. This'll make it very clear very quickly. 

Cheers, 

Chris