News for hackers. Stuff that matters.
Re:Hello Haskell, Goodbye Scala by rauljara on Tuesday January 22, 2013 @09:15AM (#5097158)
If anyone wants an introduction to functional programming using Scala, I really recommend Martin Odersky's coursera course (https://class.coursera.org/progfun-2012-001/class). He restricts you to functional Scala; there isn't a mutated variable in the whole course. It isn't officially a course right now. You won't get a certificate for taking it, and I don't think the grader is turned on, but the other materials are still there.

In my mind, the really mind altering thing was seeing not just that Object Oriented and Functional programming styles could be compatible, but that they were in many ways complementary. Good OO design, particularly the idea of small single responsibility classes, is kind of enforced by functional style. If you need to pass around fifty variables just to increment a counter, you'd go crazy. So writing functionally forces you to figure out ways to split things up. Similarly, its easy to convert well small, single responsibility OO objects into functional ones, and just a nightmare otherwise.

I was just blown away at how much a course on functional programming helped me to understand OO design.

Re:Hello Haskell, Goodbye Scala by danneu on Tuesday January 22, 2013 @01:45PM (#5098809)

    > In my mind, the really mind altering thing was seeing
    > not just that Object Oriented and Functional 
    > programming styles could be compatible, but that they
    > were in many ways complementary. 
I recently had this same a-ha moment listening to Gary Bernhardt (destroyallsoftware.com) talk about the functional core with an imperative shell.

In screencast #81 (Nov '12), he starts with code that looks like what most people would write if we wanted to write a script that compiles every .markdown file in the current directory to .html. It's an imperative loop that File.reads each path, compiles the file, determines the new filename, and File.writes the result.

Then he refactors away everything except the file I/O into a Page class with immutable methods. In other words, the only mutation that goes on in the end is in that loop (where it can't be avoided). And the result is a Page class that is effortless to test.

Something immediately snapped when I saw that even though it seems so obvious in retrospect. The boundaries of responsibilities in a system became incredibly apparent.

I don't know quite where it happened, but between Martin Odersky's course and idly watching Bernhardt's screencasts, I gained like 10 levels.

Re:Hello Haskell, Goodbye Scala by metaguri on Tuesday January 22, 2013 @10:40AM (#5097579)
Does the course cover Functors, Applicatives, Monoids, and Monads? What about other higher-level functional constructs (Arrows, Zippers...)?

From what I've seen, I think Scala is a nice language. One thing I don't like is particularly that it's a bit kitchen-sink-ish: there's a whole lot of syntax and semantics to learn, seemingly due to the OO side of the language. By comparison Haskell is quite simple. All the higher-level constructs are implemented in plain Haskell, so you can easily understand them but thanks to a flexible, uniform syntax, using them doesn't feel clunky.

To me the main reason for not learning FP through Scala, however, is that the community isn't organized around teaching FP in the same way that Haskell is. It sounds like this course is an exception. But otherwise, I found that trying to learn about Monads from the scalaz documentation was not satisfying, and we all know that "A Monad is a Sheep with Curly Hair" blog posts are a dime a dozen (in Haskell and Scala). Learn You a Haskell made the concepts, and also their benefits, clear to me for the first time. Now I'm working through Real World Haskell to build my chops and reinforce my understanding.

While trying out both languages and picking which one to learn, I came across an interesting post on Gilad Bracha's blog which had a lively discussion including a comment by the [claimed] original author of Scalaz [1], which made it clear to me that it would be easier to start in Haskell and move to Scala than vice versa. I think I (and the OP) are both seeking to gain a strong foundation in FP concepts. To summarize, in my experience most Scala resources on the internet (blog posts that come up, etc.) aren't quite as good in this regard; at this point a lot of the Scala programmers using these techniques are probably Haskell programmers anyway.

That being said, the internet is a huge place. If there's a Scala equivalent of this post [2] please do share it! I agree with other posters here that Scala has quickly gained a significant amount of industrial acceptance. I'd imagine that I'm more likely to write Scala professionally in my lifetime than Haskell. But I also believe I'll be better off approaching it having learned the FP concepts in Haskell first.

[1] http://gbracha.blogspot.com/2011/01/maybe-monads-might-not-m...

[2] http://stackoverflow.com/questions/1012573/getting-started-w...

Re:Hello Haskell, Goodbye Scala by rauljara on Tuesday January 22, 2013 @11:26AM (#5097844)
>Does the course cover Functors, Applicatives, Monoids, and Monads? What about other higher-level functional constructs (Arrows, Zippers...)?

Nope. It's very intro level, though the students basically begged Odersky for a part II, and he seemed very open to it.

And I totally didn't mean to imply that I thought people should learn Scala instead of Haskell. I was just sharing a FP resource I found helpful.

Not actually having mastered the higher level functional constructs yet myself, I really don't have a firm opinion about which is the "better" approach. Personally, I've looked at both languages and I know that each helped me understand the other. So if I have any opinion, it's that if you get stuck, it's probably a good idea to approach it from another angle, like the author is doing.

Re:Hello Haskell, Goodbye Scala by mapleoin on Tuesday January 22, 2013 @10:31AM (#5097513)
If anyone wants an introduction to functional programming using Scala, I really recommend Martin Odersky's coursera course (https://class.coursera.org/progfun-2012-001/class). He restricts you to functional Scala; there isn't a mutated variable in the whole course. It isn't officially a course right now. You won't get a certificate for taking it, and I don't think the grader is turned on, but the other materials are still there.

That course does not allow registration right now.

Re:Hello Haskell, Goodbye Scala by rauljara on Tuesday January 22, 2013 @11:34AM (#5097896)
Really? Normally you can enroll for old courses that have completed and view the old material. I've done it before, but you do need a coursera account. Is that not working in this case?
Re:Hello Haskell, Goodbye Scala by mapleoin on Tuesday January 22, 2013 @11:51AM (#5098016)
Exactly:

Enrollment is Closed

We are sorry, but the enrollment for Functional Programming Principles in Scala is currently closed. We will inform you via email when new Coursera classes are launched, so stay tuned for more.

Meanwhile, check out some of our other classes here!

The Coursera Team

Re:Hello Haskell, Goodbye Scala by VLM on Tuesday January 22, 2013 @01:12PM (#5098591)
"Enrollment is Closed We are sorry"

Yeah me too. Coursera = MCOC = Massively Closed Offline Course.

Imagine wikipedia only allowing people to view the "Scala" page between the hours of 7:30 and 8:30 on alternate tuesdays, otherwise you're outta luck, for completely arbitrary reason.

Very unimpressed with the MOOC trend. Bring back MIT OCW where I can download and watch video lectures whenever I want, forever.

Re:Hello Haskell, Goodbye Scala by ilmare on Tuesday January 22, 2013 @01:49PM (#5098830)
You can't compare time-based courses to general information provider like wikipedia. Providing content of previously offered courses is controlled by colleges/instructors [1]

[1] http://help.coursera.org/customer/portal/articles/572218-can...

Re:Hello Haskell, Goodbye Scala by patmcguire on Tuesday January 22, 2013 @01:26PM (#5098688)
When did they take that down? Thankfully I got the material for the course I was working through downloaded. Why would they do that?
Re:Hello Haskell, Goodbye Scala by ilmare on Tuesday January 22, 2013 @01:51PM (#5098845)
If you were enrolled before just go to your courses page, find fp course and go to archive of your class (with all the content, problem sets, forums, etc).
Re:Hello Haskell, Goodbye Scala by myko on Tuesday January 22, 2013 @03:12PM (#5099294)
Would it be okay/possible to post the materials online? I'd be interested in going through the course.
Re:Hello Haskell, Goodbye Scala by nullobject on Tuesday January 22, 2013 @05:31PM (#5100051)
The course material is still available, although you'll need to sign up for a Coursera account. It also looks like they're running another course in March 2013.

https://class.coursera.org/progfun-2012-001/class/index

Re:Hello Haskell, Goodbye Scala by myko on Wednesday January 23, 2013 @11:21AM (#5103700)
Weird, when I click that link I'm asked to login. When I login it says to check out other courses.
Re:Hello Haskell, Goodbye Scala by kyllo on Tuesday January 22, 2013 @09:30AM (#5097220)
Not to mention, functional programming forces you to grok recursion and higher-order functions. Huge side benefit of learning FP that you can also implement in your OOP to write more elegant methods. Never write "for int i..." again.
Re:Hello Haskell, Goodbye Scala by danieldk on Tuesday January 22, 2013 @12:10PM (#5098155)
And hope that your imperative language supports tail call optimization? ;)
Re:Hello Haskell, Goodbye Scala by kyllo on Wednesday January 23, 2013 @12:59AM (#5101702)
Ah. Well, yes, you wouldn't want a call stack overflow.

I am starting to realize why people who know functional languages despise Java. I first started programming in Java, but now the more FP I learn, the uglier Java gets.