This page is no longer maintained — Please continue to the home page at www.scala-lang.org

functional/immutable programming question

125 replies
Tony Morris 2
Joined: 2009-03-20,
User offline. Last seen 42 years 45 weeks ago.
Re: functional/immutable programming question

On 18/11/10 09:19, Jesper Nordenberg wrote:
>
>
> Luc Duponcheel skrev 2010-11-17 22:49:
>> by the way, now you suddenly talk about /pure/ functional languages,
>> but,
>> aside of that, what exactly do you mean by /imperative/,
>
> Wouldn't it be reasonable to think of "imperative" as a sequence of
> steps performed to produce a result? The difference is that in Haskell
> this sequencing is made explicit in the type system through the use of
> monads, but in most commonly used programming languages it's not
> reflected in the types, but instead built into the language as
> statements.
>
> /Jesper Nordenberg
>
s/monads/types

Raoul Duke
Joined: 2009-01-05,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

On Wed, Nov 17, 2010 at 3:20 PM, Tony Morris wrote:
>> it sounds to me like you advocate denotations of functional, but use
>> connotations of imperative.
>>
> I simply advocate exploring interesting questions and I prefer not to
> labour boring questions. I'm not sure how to make this clearer.

hrm, i get the feeling we're not going to get along, at least via this
particular communications medium... so far it seems to me like you see
only what fits what you think you see. well, best wishes on your
travels.

sincerely.

Razvan Cojocaru 3
Joined: 2010-07-28,
User offline. Last seen 42 years 45 weeks ago.
RE: Re: functional/immutable programming question

Tony - Now you've done it! You pissed me off!

...and, feeling bad that a beginner on IRC picks it up faster than I, even
with Outlook, I've just spent a few hours bouncing between Wikipedia, some
PDF articles, pen and paper and I think I'm starting to get it, even
presented that way.

Thank you. I think I understood some other things stashed for a while
somewhere in my brain...

-----Original Message-----
From: Tony Morris [mailto:tonymorris [at] gmail [dot] com]
Sent: November-16-10 5:24 PM
To: scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Re: functional/immutable programming question

On 16/11/10 23:37, Razvan Cojocaru wrote:
> So my attempt at explaining how monads help encapsulate side-effects
failed miserably... The part with "monoids in the category of endofunctors"
was a joke as was fondling elephants.
>
Perhaps, but I have seen a beginner have monads successfully explained to
them as monoids in the category of endofunctors while on IRC (which is
profound in itself). There were no elephants.

--
Tony Morris
http://tmorris.net/

Razvan Cojocaru 3
Joined: 2010-07-28,
User offline. Last seen 42 years 45 weeks ago.
RE: Re: functional/immutable programming question

Now that would be cruel, wouldn’t it?

-----Original Message-----
From: Stefan Wagner [mailto:wagner [dot] stefan [at] berlin [dot] de]
Sent: November-17-10 11:24 AM
To: scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Re: functional/immutable programming question

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Razvan Cojocaru schrieb:

> The real world has state and any program trying to model the real
> world will have to stash some state somewhere...

The real world has cats, too. Does that mean, that every program that models the real world has to stash some cats somewhere?

- --

Tschööö--->...Stefan
- ---------------------------
Don't visit my homepage at:
http://home.arcor-online.net/hirnstrom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkzkAYwACgkQQeATqGpDnRq16ACfTL22KqWQvuPCovGB5anTIRO5
9IwAoIf744aj/XorW2lN3FzdatnBKYz4
=AwvS
-----END PGP SIGNATURE-----

Russ P.
Joined: 2009-01-31,
User offline. Last seen 1 year 26 weeks ago.
Re: Re: functional/immutable programming question
On Wed, Nov 17, 2010 at 1:14 PM, Tony Morris <tonymorris [at] gmail [dot] com> wrote:

PS: I note an earlier statement that "the real world has state." This
fallacy is of a similar ilk and ironically, departs from anything
resembling the real world. A meta-fallacy about the real world is
something I encounter all too often in programming to such an extent
that I now find it quite boring.


I really shouldn't be wasting my time on this claim, but I am curious about what it could possibly mean.

The statement that "the real world has state" is a "fallacy"? Why? (I'll assume you don't mean that the statement is grammatically incorrect, because that is not the same as being false.)

Does the "real world" exist? Does "state" exist? If both "state" and "the real world" exist, then does "state" exist in "the real world"? If not, then where does it exist?

In my field, the "state" of a flight means its position, velocity, and possibly other attributes of the motion of the aircraft, such as attitude, turn rate, etc. In a given volume of airspace, the "state" of the traffic means the collection of the states of each individual flight. In "state estimation and control theory," a "state vector" is a list of coordinates or components that represent a "state" in terms of a particular coordinate system and set of physical units. In other fields of engineering, "state" can include other aspects of a "system," such as the temperature or pressure of a chemical process. Those states certainly exist in the real world, so I think we can safely conclude that "the real world has state."

What are we to make of someone who claims otherwise? That he doesn't live in the real world?

Russ P.

--
http://RussP.us
William Uther
Joined: 2010-09-13,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

Hi Tony,
Response below:

On 18/11/2010, at 8:14 AM, Tony Morris wrote:

> I'm quite sure I have posted the State data structure and the
> associated monad several times now. I'm not sure why it's not sinking
> in (perhaps it was ignored).

It isn't sinking in because I suspect most people can't understand your answers. They see a short snippet of code, and don't get its relevance.

I've been floating here for a little while. I understand some parts of functional programming quite well I think, but I haven't internalised category theory (and have other priorities).

I'm not going to go back and find examples in email, but I'll use a recent post from your blog: . In that post you list "15 (probably fun) exercises", but I can't easily read the questions. i.e. I don't think I'd have too much trouble doing the questions, if I knew what the question was. I don't think I'm the only person with this problem - I noticed on one of your blog posts that someone was asking if they'd answered a question correctly and you said that if it compiled the answer must be correct. That may be true, but a) it is weird for most people, and b) that means they need to REALLY understand scala types and most people don't.

Your emails are similar to your blog posts - they are very compact and I'm sure make perfect sense to someone who understands this stuff, but I simply can't understand them at normal reading pace. I might be able to decode them if I spent a fair while thinking about it, but I'm not willing to spend that time (I'm just lurking after all), and I suspect that many readers wouldn't even if they had more than a passing interest in the subject.

Now, this email is not meant to be critical of anyone. It could be read as critical of either you (for not explaining better) or others on the list (for being lazy readers), but it isn't meant to be either.

It isn't your job to educate people. But, if you do want to educate people then your current short responses could be improved.

In summary, it isn't sinking in because I suspect most people can't understand your answers. They see a short snippet of code, and don't get its relevance.

Cheers,

Will :-}

Tony Morris 2
Joined: 2009-03-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

Hello William,
Take the following code and try to do the exercise.

http://paste.pocoo.org/show/292912/

If it compiles, you probably have it right, though this just happens to
be less true for State operations than other simple data structures. If
it compiles and you are wrong, I will tell you. I will even give you the
tools to verify it, however, if I gave them to you right now, you'd feel
even more overwhelmed by the exercises.

Where do you get stuck?

I take teaching seriously (and it is my job in fact). Programming is
hard and I'm not fond of pretending otherwise.

On 18/11/10 13:36, William Uther wrote:
> Hi Tony,
> Response below:
>
> On 18/11/2010, at 8:14 AM, Tony Morris wrote:
>
>
>> I'm quite sure I have posted the State data structure and the
>> associated monad several times now. I'm not sure why it's not sinking
>> in (perhaps it was ignored).
>>
> It isn't sinking in because I suspect most people can't understand your answers. They see a short snippet of code, and don't get its relevance.
>
> I've been floating here for a little while. I understand some parts of functional programming quite well I think, but I haven't internalised category theory (and have other priorities).
>
> I'm not going to go back and find examples in email, but I'll use a recent post from your blog: . In that post you list "15 (probably fun) exercises", but I can't easily read the questions. i.e. I don't think I'd have too much trouble doing the questions, if I knew what the question was. I don't think I'm the only person with this problem - I noticed on one of your blog posts that someone was asking if they'd answered a question correctly and you said that if it compiled the answer must be correct. That may be true, but a) it is weird for most people, and b) that means they need to REALLY understand scala types and most people don't.
>
> Your emails are similar to your blog posts - they are very compact and I'm sure make perfect sense to someone who understands this stuff, but I simply can't understand them at normal reading pace. I might be able to decode them if I spent a fair while thinking about it, but I'm not willing to spend that time (I'm just lurking after all), and I suspect that many readers wouldn't even if they had more than a passing interest in the subject.
>
> Now, this email is not meant to be critical of anyone. It could be read as critical of either you (for not explaining better) or others on the list (for being lazy readers), but it isn't meant to be either.
>
> It isn't your job to educate people. But, if you do want to educate people then your current short responses could be improved.
>
> In summary, it isn't sinking in because I suspect most people can't understand your answers. They see a short snippet of code, and don't get its relevance.
>
> Cheers,
>
> Will :-}
>
>

Robert Wills
Joined: 2009-03-04,
User offline. Last seen 32 weeks 4 days ago.
Re: Re: functional/immutable programming question

A statement can't be a fallacy. Only an argument can be fallacious.
At best you could say that the "common sense" chain of reasoning which
leads people to conclude that the real world has state is fallacious.

I agree that it is not clear when you think about it whether "The real
world has state" is true or indeed what exactly it means. There is a
body of philosophical literature which deals with the question as to
what metaphysical status should be given to events and actions. See
http://plato.stanford.edu/entries/events/: the bit about events and
objects is probably most relevant here -- Tony, I assume you would
agree with Quine. It's also not clear whether 'state' and 'events'
refer to similar concepts.

Of course, once you get philosophical most general statements we might
make about the world have a tendency to dissolve. "The real world has
objects" is also not uncontroversial -- Kant for one would not agree.

Maybe the fallacy lies just in trying to take some commonplace about
the 'real world' and use it in an argument about programming.

Well that woke me up.

-Rob

On Thu, Nov 18, 2010 at 2:10 AM, Russ Paielli wrote:
> On Wed, Nov 17, 2010 at 1:14 PM, Tony Morris wrote:
>>
>> PS: I note an earlier statement that "the real world has state." This
>> fallacy is of a similar ilk and ironically, departs from anything
>> resembling the real world. A meta-fallacy about the real world is
>> something I encounter all too often in programming to such an extent
>> that I now find it quite boring.
>>
>
> I really shouldn't be wasting my time on this claim, but I am curious about
> what it could possibly mean.
>
> The statement that "the real world has state" is a "fallacy"? Why? (I'll
> assume you don't mean that the statement is grammatically incorrect, because
> that is not the same as being false.)
>
> Does the "real world" exist? Does "state" exist? If both "state" and "the
> real world" exist, then does "state" exist in "the real world"? If not, then
> where does it exist?
>
> In my field, the "state" of a flight means its position, velocity, and
> possibly other attributes of the motion of the aircraft, such as attitude,
> turn rate, etc. In a given volume of airspace, the "state" of the traffic
> means the collection of the states of each individual flight. In "state
> estimation and control theory," a "state vector" is a list of coordinates or
> components that represent a "state" in terms of a particular coordinate
> system and set of physical units. In other fields of engineering, "state"
> can include other aspects of a "system," such as the temperature or pressure
> of a chemical process. Those states certainly exist in the real world, so I
> think we can safely conclude that "the real world has state."
>
> What are we to make of someone who claims otherwise? That he doesn't live in
> the real world?
>
> Russ P.
>
> --
> http://RussP.us
>

Graham Matthews
Joined: 2009-12-22,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

On Nov 17, 2010, at 10:25 PM, Robert Wills wrote:
Maybe the fallacy lies just in trying to take some commonplace about
the 'real world' and use it in an argument about programming.


To me this is the only fallacy worth talking about in this chain of discussion.
I am interested in writing reliable, high performance programs. As an engineer I use the techniques, theory, etc that allow me to do this, irrespective of what is "in the real world". 
This is one of the reasons I like Scala, and O'Caml -- they allow me to chose among various programming/engineering choices depending on the situation. I can mix and match as need be.
graham
Tony Morris 2
Joined: 2009-03-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

On 18/11/10 16:25, Robert Wills wrote:
> A statement can't be a fallacy.
>
A statement can be a fallacy. The word fallacy derives from the word
"false." The statement under discussion is false, therefore, it is a
fallacy.

Luc Duponcheel
Joined: 2008-12-19,
User offline. Last seen 34 weeks 3 days ago.
Re: functional/immutable programming question
Jesper,

maybe a reason to partition them in pure functional resp. not pure functional ?

Luc

On Thu, Nov 18, 2010 at 12:09 AM, Jesper Nordenberg <megagurka [at] yahoo [dot] com> wrote:


Graham Matthews skrev 2010-11-17 23:58:
A functional program language is one in which *all* functions are
*guaranteed* to be referentially transparent (RT) -- so

Uhm, this definition would exclude a lot of programming languages normally considered functional, for example ML, OCaml, F#, Lisp etc.

/Jesper Nordenberg




--
   __~O
  -\ <,
(*)/ (*)

reality goes far beyond imagination

Robert Wills
Joined: 2009-03-04,
User offline. Last seen 32 weeks 4 days ago.
Re: Re: functional/immutable programming question

Sorry this is getting off topic I know...

'Fallacy' and 'false' share a common origin but 'fallacy' does not
derive from 'false':
http://www.etymonline.com/index.php?term=fallacy
http://www.etymonline.com/index.php?term=false
They both derive from 'fallere' but 'false' derives from the past
participle of 'fallere': ie of having been deceived.

Even if the one did derive from the other I wouldn't accept your
argument: 'cretin' derives from 'Christian' but this does not imply
that if someone is a Christian, then that person is a cretin-- though
one might believe the conclusion for other reasons.
http://www.etymonline.com/index.php?search=cretin

Sorry for being so tedious -- I studied philosophy at university so I
have trouble letting these sorts of things drop. Anyway, Tony, I
think I generally agree with you about state and the world.

-Rob

On Thu, Nov 18, 2010 at 7:46 AM, Tony Morris wrote:
> On 18/11/10 16:25, Robert Wills wrote:
>> A statement can't be a fallacy.
>>
> A statement can be a fallacy. The word fallacy derives from the word
> "false." The statement under discussion is false, therefore, it is a
> fallacy.
>

Randall R Schulz
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
Re: Re: functional/immutable programming question

On Thursday November 18 2010, Robert Wills wrote:
> Sorry this is getting off topic I know...

But it is nice to have a philosopher / logician around.

The ontological schools of thought in question here are perdurantism and
endurantism. Tony's position corresponds most closely to endurantism.
Special relativity (along with general relativity is an astonishingly
well-confirmed physical theory) is problematic for endurantism [1]

Randall Schulz

[1] 

> 'Fallacy' and 'false' share a common origin but 'fallacy' does not
> derive from 'false': ...
>
> Sorry for being so tedious -- I studied philosophy at university so I
> have trouble letting these sorts of things drop. Anyway, Tony, I
> think I generally agree with you about state and the world.
>
> -Rob
>
> On Thu, Nov 18, 2010 at 7:46 AM, Tony Morris wrote:
> > On 18/11/10 16:25, Robert Wills wrote:
> >> A statement can't be a fallacy.
> >
> > A statement can be a fallacy. The word fallacy derives from the
> > word "false." The statement under discussion is false, therefore,
> > it is a fallacy.

Stefan Langer
Joined: 2009-10-23,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

Could you move this to scala-debate as it is really getting OT

2010/11/18 Randall R Schulz :
> On Thursday November 18 2010, Robert Wills wrote:
>> Sorry this is getting off topic I know...
>
> But it is nice to have a philosopher / logician around.
>
> The ontological schools of thought in question here are perdurantism and
> endurantism. Tony's position corresponds most closely to endurantism.
> Special relativity (along with general relativity is an astonishingly
> well-confirmed physical theory) is problematic for endurantism [1]
>
>
> Randall Schulz
>
>
> [1] 
>
>
>> 'Fallacy' and 'false' share a common origin but 'fallacy' does not
>> derive from 'false': ...
>>
>> Sorry for being so tedious -- I studied philosophy at university so I
>> have trouble letting these sorts of things drop.  Anyway, Tony, I
>> think I generally agree with you about state and the world.
>>
>> -Rob
>>
>> On Thu, Nov 18, 2010 at 7:46 AM, Tony Morris wrote:
>> > On 18/11/10 16:25, Robert Wills wrote:
>> >> A statement can't be a fallacy.
>> >
>> > A statement can be a fallacy. The word fallacy derives from the
>> > word "false." The statement under discussion is false, therefore,
>> > it is a fallacy.
>
>
>

Richard Dallaway
Joined: 2009-02-21,
User offline. Last seen 42 years 45 weeks ago.
Re: Funtional programming reading
On Wed, Nov 17, 2010 at 6:11 PM, Jason Zaugg <jzaugg [at] gmail [dot] com> wrote:
I recommend Eric Meijer's series on functional programming, on Channel 9.

http://channel9.msdn.com/Shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1


+1

I've also recently finished reading Bird & Wadler's Introduction to Functional Programming (1988!) and I found that helpful. 
Roland Kuhn
Joined: 2008-12-26,
User offline. Last seen 3 years 14 weeks ago.
Re: Re: functional/immutable programming question

It is amusing to see philosophical arguments based on solid scientific
foundations go wrong at the last turn, especially when the author
displays a rather high degree of knowledge about their usual
interpretations.

In a nutshell, as this is probably off-topic even for scala-debate:

Because of the finite speed of light, what you see at one time has
actually happened at (different) times in the past. More precisely, what
you see is radiation emitted by some particle which was on the light
cone around the negative time axis in your rest frame (assuming the
"eye" is at the origin). That this radiation constitutes a "proper part"
of that particle has not been argued and there is a priori no reason to
assume so [1]. Hence, whether you may be able to simultaneously see
different parts of an object as they existed at different times is
completely immaterial to the question at hand.

Dr. Roland Kuhn (specializing in high-energy quantum physics)

[1] If you go down this route by relying on quantum entanglement, the
whole universe (at least within our event horizon) must be viewed as one
single object.

Am 18.11.2010 15:06, schrieb Randall R Schulz:
> On Thursday November 18 2010, Robert Wills wrote:
>> Sorry this is getting off topic I know...
> But it is nice to have a philosopher / logician around.
>
> The ontological schools of thought in question here are perdurantism and
> endurantism. Tony's position corresponds most closely to endurantism.
> Special relativity (along with general relativity is an astonishingly
> well-confirmed physical theory) is problematic for endurantism [1]
>
>
> Randall Schulz
>
>
> [1]
>
>
>> 'Fallacy' and 'false' share a common origin but 'fallacy' does not
>> derive from 'false': ...
>>
>> Sorry for being so tedious -- I studied philosophy at university so I
>> have trouble letting these sorts of things drop. Anyway, Tony, I
>> think I generally agree with you about state and the world.
>>
>> -Rob
>>
>> On Thu, Nov 18, 2010 at 7:46 AM, Tony Morris wrote:
>>> On 18/11/10 16:25, Robert Wills wrote:
>>>> A statement can't be a fallacy.
>>> A statement can be a fallacy. The word fallacy derives from the
>>> word "false." The statement under discussion is false, therefore,
>>> it is a fallacy.
>

Razvan Cojocaru 3
Joined: 2010-07-28,
User offline. Last seen 42 years 45 weeks ago.
RE: Re: Re: functional/immutable programming question

So... singleton or not... this universe... does it or does it not have
state?

----------

Well, of course my sentence itself is true, syntactically speaking, since
the world (*now* at least) includes my sentence which includes the word
"state"...

What is a fallacy (either as false or rather wrong) is what I tried to mean
(or rather do) by using that sentence in that context... i.e. the semantics
behind the words... an attempt and psychological bullying, to reach a wanted
conclusion, using an obviously true and undisputable statement (undisputable
at least at first reading)...and *this* is what he must've reacted to, as
evidenced by the other half of the respective paragraph... I would've
thought that was obvious...

I'm not arguing that everything Tony says is obvious (rather the contrary,
since without the effort, there can be no learning, eh?), but this one
seemed so...

------------

What really pissed me off is the sudden realization that I had to put my
bikes away for the next 5 months of winter, while some can probably go at it
throughout the year... but this was even more off-topic than the currently
off-topic topic...

-----Original Message-----
From: Roland Kuhn [mailto:rk [at] rkuhn [dot] info]
Sent: November-18-10 12:01 PM
To: Randall R Schulz
Cc: scala-debate [at] listes [dot] epfl [dot] ch
Subject: [scala-debate] Re: [scala-user] Re: functional/immutable
programming question

It is amusing to see philosophical arguments based on solid scientific
foundations go wrong at the last turn, especially when the author displays a
rather high degree of knowledge about their usual interpretations.

In a nutshell, as this is probably off-topic even for scala-debate:

Because of the finite speed of light, what you see at one time has actually
happened at (different) times in the past. More precisely, what you see is
radiation emitted by some particle which was on the light cone around the
negative time axis in your rest frame (assuming the "eye" is at the origin).
That this radiation constitutes a "proper part"
of that particle has not been argued and there is a priori no reason to
assume so [1]. Hence, whether you may be able to simultaneously see
different parts of an object as they existed at different times is
completely immaterial to the question at hand.

Dr. Roland Kuhn (specializing in high-energy quantum physics)

[1] If you go down this route by relying on quantum entanglement, the whole
universe (at least within our event horizon) must be viewed as one single
object.

Am 18.11.2010 15:06, schrieb Randall R Schulz:
> On Thursday November 18 2010, Robert Wills wrote:
>> Sorry this is getting off topic I know...
> But it is nice to have a philosopher / logician around.
>
> The ontological schools of thought in question here are perdurantism
> and endurantism. Tony's position corresponds most closely to endurantism.
> Special relativity (along with general relativity is an astonishingly
> well-confirmed physical theory) is problematic for endurantism [1]
>
>
> Randall Schulz
>
>
> [1] lepdf/endurantism.pdf>
>
>
>> 'Fallacy' and 'false' share a common origin but 'fallacy' does not
>> derive from 'false': ...
>>
>> Sorry for being so tedious -- I studied philosophy at university so I
>> have trouble letting these sorts of things drop. Anyway, Tony, I
>> think I generally agree with you about state and the world.
>>
>> -Rob
>>
>> On Thu, Nov 18, 2010 at 7:46 AM, Tony Morris wrote:
>>> On 18/11/10 16:25, Robert Wills wrote:
>>>> A statement can't be a fallacy.
>>> A statement can be a fallacy. The word fallacy derives from the word
>>> "false." The statement under discussion is false, therefore, it is a
>>> fallacy.
>

Meredith Gregory
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Funtional programming reading
Dear Jan,
The value of the resources depend on your aim vis-a-vie functional programming. For example, i might recommend the Structure and Interpretation of Computer Programs, as a classic that every programmer should read, but especially those interested in DSL-based design and how that relates to functional programming. On the other hand, if your interest is in the how various features and capabilities relate to each other, such as pattern-matching and types or comprehensions and polymorphism, then you could do worse than Graham Hutton's book -- from which Erik's C9 lectures come. Erik's friend, and mine, Brian Beckman (also a C9 star), highly recommends Hudak's book. None of these are targeted to the Scala language, however.
Best wishes,
--greg

On Thu, Nov 18, 2010 at 6:21 AM, Richard Dallaway <dallaway [at] gmail [dot] com> wrote:
On Wed, Nov 17, 2010 at 6:11 PM, Jason Zaugg <jzaugg [at] gmail [dot] com> wrote:
I recommend Eric Meijer's series on functional programming, on Channel 9.

http://channel9.msdn.com/Shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1


+1

I've also recently finished reading Bird & Wadler's Introduction to Functional Programming (1988!) and I found that helpful. 



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
7329 39th Ave SWSeattle, WA 98136

+1 206.650.3740

http://biosimilarity.blogspot.com
Russ P.
Joined: 2009-01-31,
User offline. Last seen 1 year 26 weeks ago.
Re: Re: functional/immutable programming question
At one time in my life I was interested in becoming a philosopher, but fortunately I took a different path. Instead, I studied control engineering. For those who are not aware, control theory/engineering is a huge field, with many journals and conferences every year devoted to it and its many branches. It is now a fairly mature field, having had its major growth period over the past few decades.

Control engineering can be broken down into two basic categories: linear and nonlinear. In linear control theory, the dynamics of the system to be controlled are linear (or at least modeled as linear), and the basic equations are

dx/dt = A x + B u
y = C x + w

where x is the state vector, A is the state transition matrix, u is the control vector (the control inputs), B is the input distribution matrix, y is the output vector (the measurements from the sensors), C is the observation matrix, and w is the random measurement noise. The vectors x, u, y, and w are all functions of time, but matrices A, B, and C are constant (or slowly varying and approximated as constant). These two equations in one form or another have appeared in literally thousands of papers on control theory. The objective of the control theorist or engineer is to determine the feedback control settings u as a function of the output y to make x do what we want it to do. A related field is estimation theory, which is the art of getting the best estimate possible of the state x in the presence of the random measurement noise w.

For a nonlinear dynamic system, the equations are generalized to

dx/dt = f(x, u)
y = h(x, w)

where f and h are nonlinear functions in general. Linear control theory is complex enough, but nonlinear control theory is much more complex yet.

The "state" of a dynamic system is basically just a snapshot in time of its dynamic state. To label as "fallacious" the statement that "the real world has state" is at best semantic pedantry and at worse nonsense. It is to claim essentially that points in time do not exist. Do they exist? I'm going to go out on a limb and say they do. If they don't, then they are a very useful approximation anyway.

We could get into a deep discussion about relativity, but for practical mechanical (e.g., automotive or aeronautical) control engineering, Newtonian mechanics is more than adequate. If some engineer suggested accounting for relativistic effects in flight control, he would quickly be relieved of his job.

--Russ P.

On Thu, Nov 18, 2010 at 6:06 AM, Randall R Schulz <rschulz [at] sonic [dot] net> wrote:
On Thursday November 18 2010, Robert Wills wrote:
> Sorry this is getting off topic I know...

But it is nice to have a philosopher / logician around.

The ontological schools of thought in question here are perdurantism and
endurantism. Tony's position corresponds most closely to endurantism.
Special relativity (along with general relativity is an astonishingly
well-confirmed physical theory) is problematic for endurantism [1]


Randall Schulz



--
http://RussP.us
Alec Zorab
Joined: 2010-05-18,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

Unless, of course, the plane used GPS for navigation, in which case
they would indeed be using relativistic effects!

...but I digress.

On Thu, Nov 18, 2010 at 3:05 PM, Russ Paielli wrote:
> At one time in my life I was interested in becoming a philosopher, but
> fortunately I took a different path. Instead, I studied control engineering.
> For those who are not aware, control theory/engineering is a huge field,
> with many journals and conferences every year devoted to it and its many
> branches. It is now a fairly mature field, having had its major growth
> period over the past few decades.
>
> Control engineering can be broken down into two basic categories: linear and
> nonlinear. In linear control theory, the dynamics of the system to be
> controlled are linear (or at least modeled as linear), and the basic
> equations are
>
> dx/dt = A x + B u
> y = C x + w
>
> where x is the state vector, A is the state transition matrix, u is the
> control vector (the control inputs), B is the input distribution matrix, y
> is the output vector (the measurements from the sensors), C is the
> observation matrix, and w is the random measurement noise. The vectors x, u,
> y, and w are all functions of time, but matrices A, B, and C are constant
> (or slowly varying and approximated as constant). These two equations in one
> form or another have appeared in literally thousands of papers on control
> theory. The objective of the control theorist or engineer is to determine
> the feedback control settings u as a function of the output y to make x do
> what we want it to do. A related field is estimation theory, which is the
> art of getting the best estimate possible of the state x in the presence of
> the random measurement noise w.
>
> For a nonlinear dynamic system, the equations are generalized to
>
> dx/dt = f(x, u)
> y = h(x, w)
>
> where f and h are nonlinear functions in general. Linear control theory is
> complex enough, but nonlinear control theory is much more complex yet.
>
> The "state" of a dynamic system is basically just a snapshot in time of its
> dynamic state. To label as "fallacious" the statement that "the real world
> has state" is at best semantic pedantry and at worse nonsense. It is to
> claim essentially that points in time do not exist. Do they exist? I'm going
> to go out on a limb and say they do. If they don't, then they are a very
> useful approximation anyway.
>
> We could get into a deep discussion about relativity, but for practical
> mechanical (e.g., automotive or aeronautical) control engineering, Newtonian
> mechanics is more than adequate. If some engineer suggested accounting for
> relativistic effects in flight control, he would quickly be relieved of his
> job.
>
> --Russ P.
>
> On Thu, Nov 18, 2010 at 6:06 AM, Randall R Schulz wrote:
>>
>> On Thursday November 18 2010, Robert Wills wrote:
>> > Sorry this is getting off topic I know...
>>
>> But it is nice to have a philosopher / logician around.
>>
>> The ontological schools of thought in question here are perdurantism and
>> endurantism. Tony's position corresponds most closely to endurantism.
>> Special relativity (along with general relativity is an astonishingly
>> well-confirmed physical theory) is problematic for endurantism [1]
>>
>>
>> Randall Schulz
>>
>>
>
> --
> http://RussP.us
>

Russ P.
Joined: 2009-01-31,
User offline. Last seen 1 year 26 weeks ago.
Re: Re: functional/immutable programming question
On Thu, Nov 18, 2010 at 1:35 PM, Alec Zorab <aleczorab [at] googlemail [dot] com> wrote:
Unless, of course, the plane used GPS for navigation, in which case
they would indeed be using relativistic effects!

...but I digress.


I thought about mentioning that, but I figured I'd rambled long enough and had better get back to work before I am relieved of my job!

--Russ P.

--
http://RussP.us
Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question
You are holding both ends of the rope here.How can you discuss whether or not "imperative programming is a superset of functional programming" without a working definition of "imperative programming"? In more general terms, in order to agree on whether A is a superset of B, you gotta agree on what you mean by A. If I have one definition of A and you have another, then we could seem to disagree on whether it's a superset of B but actually be agreeing.
Also, do you agree or disagree that "pure" implies a subset of something?


On Wed, Nov 17, 2010 at 5:39 PM, Tony Morris <tonymorris [at] gmail [dot] com> wrote:
On 18/11/10 07:49, Luc Duponcheel wrote:
A few minor remarks Tony,

let me first say that, deep in my heart, I am a pure functional programmer

we can, of course, have endless discussions about vaguely defined vocabulary
and sentences produced with it, and, I have to confess, I'm also not fully defining
my vocabulary and the sentences that I produce with it

> Functional programming is programming with functions. This has nothing
> to do with anything being "first-class."

maybe, in the sense that functions are values, the are "first class" in, afaik,
all mainstream languages that, by most programmers, are called functional
languages

as far as Haskell is all about programming with functions, it certainly benefits
from 'this functions being "first class" aspect' [ higher order functions, ... ]

> A pure functional language like Haskell does
> imperative programming *a whole lot better than most imperative
> languages*. In other words, there is an embedded "DSL" in Haskell
> that is an imperative language.

by the way, now you suddenly talk about pure functional languages, but,
aside of that, what exactly do you mean by imperative,

I think you refer to Haskell's monad based do syntax (similar
to Scala's for loop syntax), but, if you write something like

tick :: State Int Int
tick = do n <- get
          put (n+1)
          return n

this code may look imperative (especially because of the do keyword),
but, behind the scenes it does not do the same imperative thing as as, say,
an assignment in Java (in Haskell everything is final)

... and this discussion can go on and on ...

Hi Luc,
I believe you are restating my point, but a little differently and perhaps even more succinctly for some. Specifically, it raises the question, "just what is imperative programming?" While important to some, I personally find it an uninteresting question and prefer to restate the question to provoke an examination of the practical benefits. I'm hoping to appease the audience for which this is an important question, while alluding to the practical implications as you have done in your "imperative looking" example.

I wish to emphasise that "imperative programming is a superset of functional programming" is not only a fallacy, but a very destructive one in that it can impair potential for understanding.


-- 
Tony Morris
http://tmorris.net/


Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question

On Wed, Nov 17, 2010 at 4:14 PM, Tony Morris <tonymorris [at] gmail [dot] com> wrote:
PS: I note an earlier statement that "the real world has state." This
fallacy is of a similar ilk and ironically, departs from anything
resembling the real world.


What is your definition of state, Tony? I'm not so confident it's the same as that of the one who made the above statement.
Also, you've made statements several times about what the essence of the "real world" is. Tell me, how is it possible for a human being to know what the essence of the real world is?
Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: functional/immutable programming question


On Wed, Nov 17, 2010 at 4:14 PM, Tony Morris <tonymorris [at] gmail [dot] com> wrote:
There you have it -- a pure functional
programming construct embedded in an imperative language such as Scala.


There you have it -- exactly what Raoul was trying to say! It's possible for an imperative language to have functional constructs used in it!
Perhaps the wording was not mathematically precise, how sad.

channingwalton
Joined: 2008-09-27,
User offline. Last seen 2 weeks 1 day ago.
Re: Funtional programming reading

On 17 Nov 2010, at 17:43, Jan Goyvaerts wrote:
Hello,

Can somebody guide me to an accessible introduction in functional
programming ? Something a Scala newbie should have read at least ! :-)

I've found http://learnyouahaskell.com/ to be useful.
The concepts introduced there apply to scala.
In fact, perhaps it would be useful to have a Learn you a Scala for even greater good ;)

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland