Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Coursera Functional Programming Principles in Scala
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 38 of 38 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tony Morris  
View profile  
 More options Sep 30 2012, 11:01 pm
From: Tony Morris <tonymor...@gmail.com>
Date: Mon, 1 Oct 2012 13:00:57 +1000
Local: Sun, Sep 30 2012 11:00 pm
Subject: Re: Coursera Functional Programming Principles in Scala

I am only a teacher to the extent that I have done teaching. I remember
believing that hiding terminology from students was a good idea. I was
partly influenced by students themselves. Some students still insist. We
were all wrong and not just a bit. I must remember to dismiss their
demands, for everyone's benefit.
On Oct 1, 2012 9:10 AM, "Toby Corkindale" <t...@dryft.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dean Budd  
View profile  
 More options Oct 1 2012, 6:57 pm
From: Dean Budd <dean.b...@gmail.com>
Date: Mon, 1 Oct 2012 15:57:42 -0700 (PDT)
Local: Mon, Oct 1 2012 6:57 pm
Subject: Re: Coursera Functional Programming Principles in Scala

(Un)fortunately I've been reading *Structure and Interpretation of Computer
Programs* in parallel with the course (*highly recommended!*) and saw
(and analysed) the algorithm before I saw the problem in the course :(

The Scala Course is pretty much a mirror of the book. I find it very
valuable. My problem is now juggling two new languages in my head.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
King Lung Chiu  
View profile  
 More options Oct 10 2012, 3:44 am
From: King Lung Chiu <kinglung.c...@gmail.com>
Date: Wed, 10 Oct 2012 18:43:22 +1100
Local: Wed, Oct 10 2012 3:43 am
Subject: Re: Coursera Functional Programming Principles in Scala
Just to say I've been following the course too and it's been
interesting to have to think purely recursively and forego mutable
values.

As a personal exercise, I've also been trying out the assignments
before watching the videos to see how much I already know - both Scala
syntax and data structures / algorithms - so far so good, though not
sure how long this will last :-)

On 2 October 2012 08:57, Dean Budd <dean.b...@gmail.com> wrote:

> (Un)fortunately I've been reading Structure and Interpretation of Computer
> Programs in parallel with the course (highly recommended!) and saw (and
> analysed) the algorithm before I saw the problem in the course :(

> The Scala Course is pretty much a mirror of the book. I find it very
> valuable. My problem is now juggling two new languages in my head.

Could be interesting to try out the exercises in Scala, and use the
book just for the generic concepts.

cheers,

King


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Hutchison  
View profile  
 More options Oct 10 2012, 8:38 am
From: Ben Hutchison <brhutchi...@gmail.com>
Date: Wed, 10 Oct 2012 23:37:59 +1100
Local: Wed, Oct 10 2012 8:37 am
Subject: Re: Coursera Functional Programming Principles in Scala

Speaking of the course, I feel that last week and this week have drifted
towards "Object-oriented Programming Principles in Scala".

For example, last week's Rational example demonstrated a textbook OO
implementation. You could just use a tuple containing a Numerator and a
Denominator field to model a rational, alias it as Rational, and write a
bunch of functions that worked over Rationals. That would be simpler, in
the sense that you wouldn't need to invent/understand classes or OO at all.

My impressions is that the course is more about teaching Scala than
teaching functional programming, which is a slight surprise because I'd
been expecting the opposite emphasis. But for a lot of people this could be
ideal.

-Ben

On Wed, Oct 10, 2012 at 6:43 PM, King Lung Chiu <kinglung.c...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Travis Dixon  
View profile  
 More options Oct 10 2012, 3:39 pm
From: Travis Dixon <the.t...@gmail.com>
Date: Thu, 11 Oct 2012 06:39:57 +1100
Local: Wed, Oct 10 2012 3:39 pm
Subject: Re: Coursera Functional Programming Principles in Scala

I got the impression that Martin was going with the line that OO is not
mutually exclusive with FP

Didn't he use the first lecture to describe FP as being primarily about
immutable variables and contrasted with imperative style, which is a
sequence of machine instructions that update state?

On Wed, Oct 10, 2012 at 11:37 PM, Ben Hutchison <brhutchi...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Travis Dixon  
View profile  
 More options Oct 10 2012, 3:40 pm
From: Travis Dixon <the.t...@gmail.com>
Date: Thu, 11 Oct 2012 06:40:49 +1100
Local: Wed, Oct 10 2012 3:40 pm
Subject: Re: Coursera Functional Programming Principles in Scala

it just occurred to me that immutable variable is a total oxymoron, but I
think you get what I mean :P


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Hutchison  
View profile  
 More options Oct 10 2012, 6:48 pm
From: Ben Hutchison <brhutchi...@gmail.com>
Date: Thu, 11 Oct 2012 09:48:18 +1100
Local: Wed, Oct 10 2012 6:48 pm
Subject: Re: Coursera Functional Programming Principles in Scala

Hi Travis,

Yeah, you remind me that there are 2 different spectrums or axes where the
word "Functional" is used. They are often mixed up, because it *is*
confusing to have one word mean at least two different things

One is the mutable <-> immutable axis (aka imperative<-> declarative) axis,
and this is probably the one where Martin uses the word Functional to
describe the immutable/declarative direction. Fair enough.

A somewhat orthogonal axis is the Object-oriented <-> uh, "Functional"
(maybe "Type Class"?) spectrum. At the OO end, the data is tightly bound to
related behavior  and polymoprhic dispatch is implemented by heap pointers
to method vtables, associated with the first special "self" parameter to
each function.

At the , er "functional" end, data and behavior are kept separate.
Polymoprhic dispatch is implemented via type-classes, which use the
compile-time type system to invoke the appropriate type-class instance for
the data types in context. Obviously, this paradigm requires a static type
system to get past Go.

Support for the typeclass model is not "native" to scala, the way OO is. It
was kind of engineered post-hoc, as people (a) understood
the capabilities of implicits, (b) ported Haskell code over and
(c) recognized how powerful it was.

The big "wins" of the typeclass model vs the OO model are:

- It doesn't require the asymmetry of dispatching purely on the first
"self" parameter to the method. This asymmetry looks to me like an
artificial implementation-artefact when critically examined, and has lots
of negative consequences, eg implementing Object.equals(other) [
http://www.artima.com/lejava/articles/equality.html].

- It allows the behavior to vary in different contexts. Look at
java.util.Comparable as example of why you need this; you just cannot just
weld one ordering onto a piece of data and expect this to suffice for all
clients. Hence, java.util.Comparator came into being, which
is essentially a type class, except in Java you must do the dispatch
manually by hand.

-Ben


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Conway  
View profile  
 More options Oct 10 2012, 7:42 pm
From: Andrew Conway <agoo...@greatcactus.org>
Date: Wed, 10 Oct 2012 16:42:58 -0700 (PDT)
Local: Wed, Oct 10 2012 7:42 pm
Subject: Re: Coursera Functional Programming Principles in Scala

At the risk of getting into a debate about the meaning of words...

When one talks about a "pure" functional language, it means (to me)
referential transparency.

So I think of the mutable/immutable axis you were talking about as the
functional style, especially in Scala where you have options. To me, OO and
type class dispatch are "merely" convenient ways of doing various things in
the mutable / immutable styles.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ishaaq Chandy  
View profile  
 More options Oct 10 2012, 10:14 pm
From: Ishaaq Chandy <ish...@gmail.com>
Date: Thu, 11 Oct 2012 13:14:36 +1100
Local: Wed, Oct 10 2012 10:14 pm
Subject: Re: Coursera Functional Programming Principles in Scala

well, without proper value data types in the JVM if you lived solely on
Ben's non-OO orthogonal axis you'd be relegated to resorting to use tuples
for everything - which would feel clunky IMO. I guess you could still
declare classes as purely data structures and not give them any methods at
all - I guess you throw away traits then as well?

Ishaaq

On 11 October 2012 10:42, Andrew Conway <agoo...@greatcactus.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Morris  
View profile  
 More options Oct 10 2012, 11:48 pm
From: Tony Morris <tonymor...@gmail.com>
Date: Thu, 11 Oct 2012 13:48:18 +1000
Local: Wed, Oct 10 2012 11:48 pm
Subject: Re: Coursera Functional Programming Principles in Scala

Immutable variables are common. Many people, especially logicians, use
the term variable to mean "free variable." It has been argued that using
the term variable to imply an updating register should be discouraged.
http://existentialtype.wordpress.com/2012/02/01/words-matter/

I have no idea what OO is (and as an aside, I argue, nobody does), but
imperative programming is not in conflict with functional programming.
Indeed, Haskell is a purely functional language that does imperative
programming extremely well.
http://apocalisp.wordpress.com/2011/05/30/imperative-vs-functional-pr...

On 11/10/12 05:40, Travis Dixon wrote:

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Hutchison  
View profile  
 More options Oct 11 2012, 10:00 am
From: Ben Hutchison <brhutchi...@gmail.com>
Date: Fri, 12 Oct 2012 01:00:16 +1100
Local: Thurs, Oct 11 2012 10:00 am
Subject: Re: Coursera Functional Programming Principles in Scala

On Thu, Oct 11, 2012 at 1:14 PM, Ishaaq Chandy <ish...@gmail.com> wrote:
> well, without proper value data types in the JVM if you lived solely on
> Ben's non-OO orthogonal axis you'd be relegated to resorting to use tuples
> for everything - which would feel clunky IMO. I guess you could still
> declare classes as purely data structures and not give them any methods at
> all

I think you answered your own concern here :)  - yes, use case classes
without methods for data, which are relatives of tuple in that they share a
common superclass Product.

But to put it another way: ignoring inheritance, any class def can be
mechanically transformed into 2 classes: one pure data, one
pure behaviour that operates over the data class, with any significant
performance impacts.

> - I guess you throw away traits then as well?

I don't think type-class style amount to a deprecation of traits. They can
still be used to compose either the behaviour classes ("modules") or less
commonly the data classes. Unless it's changed radically in 7, type-class
library Scalaz uses traits extensively.

Finally, I don't think the typeclass style can address all the use-cases
for OO-style dispatch, and hence some kind of OO-like mechanism will always
be needed. In Haskell, a similar effect is achieved with Existential Types,
which are the underpinnings for OO.

For example: Imagine I have a TrafficLight type with Red and Green
subtypes, and I want to dispatch to different methods per color,
light.speedOfACarAt perhaps. If I throw a heterogeneous collection of light
colors together in a List[TrafficLight], I've lost the specific type
information I'll need to dispatch typeclass-style over the elements.

You can do this, trivially, using OO. But you can also do this by pairing
Existential Types + Typeclasses. I'll try to express the idea in english,
since my Scala existential syntax is too rusty: a List of pairs, each
containing a value of some hidden (existential) type, paired with a
CanFindSpeedOf instance for that same hidden type.

I asked Simon Peyton-Jones about this topic at YOW last year. His reply was
that this encoding was essentially objects, but that "you only pay for
objects when you need them", rather than being on-by-default. Makes sense
to me...

-Ben


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bernie Pope  
View profile  
 More options Oct 11 2012, 8:31 pm
From: Bernie Pope <bjp...@unimelb.edu.au>
Date: Fri, 12 Oct 2012 11:31:22 +1100
Local: Thurs, Oct 11 2012 8:31 pm
Subject: Re: Coursera Functional Programming Principles in Scala
On 12/10/2012, at 1:00 AM, Ben Hutchison wrote:

> I asked Simon Peyton-Jones about this topic at YOW last year. His reply was that this encoding was essentially objects, but that "you only pay for objects when you need them", rather than being on-by-default. Makes sense to me...

This relates to my biggest complaint about OOP is that it conflates too many semantic features (each potentially useful in their own right) into one conglomeration.

Cheers,
Bernie.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Morris  
View profile  
 More options Oct 12 2012, 4:34 am
From: Tony Morris <tonymor...@gmail.com>
Date: Fri, 12 Oct 2012 18:34:34 +1000
Local: Fri, Oct 12 2012 4:34 am
Subject: Re: Coursera Functional Programming Principles in Scala
On 12/10/12 00:00, Ben Hutchison wrote:
> Unless it's changed radically in 7, type-class
> library Scalaz uses traits extensively.

It still uses traits heavily. To some extent, you don't have to.

case class Semigroup[A](op: (A, A) => A)
case class Monoid[A](id: A, Semigroup[A])
case class Reducer[X, M](unit: X => M, m: Semigroup[M])
...

You run into problems though, in the absence of rank-2:

case class Functor[F[_]](fmap: [A, B](A => B) => F[A] => F[B]) // No.

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »