5 ms·
If anyone wants an introduction to functional programming using Scala, I really recommend Martin Odersky's coursera course (https://class.coursera.org/progfun-2
by rauljara 14y ago
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 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.
- kyllo 14y agoNot 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.
- danieldk 14y agoAnd hope that your imperative language supports tail call optimization? ;)
- kyllo 14y agoAh. 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.
- mapleoin 14y agoIf 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 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.
- rauljara 14y agoReally? 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?
- mapleoin 14y agoExactly: 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
- VLM 14y ago"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.
- patmcguire 14y agoWhen did they take that down? Thankfully I got the material for the course I was working through downloaded. Why would they do that?
- metaguri 14y agoDoes 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-matter.html?showComment=1295940865245#c7260381172547454562 http://gbracha.blogspot.com/2011/01/maybe-monads-might-not-m... [2] http://stackoverflow.com/questions/1012573/getting-started-with-haskell http://stackoverflow.com/questions/1012573/getting-started-w...
- rauljara 14y ago>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.
- danneu 14y ago> 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.