Hacker News new | past | comments | ask | show | jobs | submit login
How Do I Learn Some Functional Programming? (fse.guru)
53 points by mr_mig on June 18, 2016 | hide | past | favorite | 15 comments



I can't recommend CIS 194 (http://www.seas.upenn.edu/~cis194/) enough. After a first weak attempt at learning haskell, following this course did it for me, and I've managed to write some significant haskell programs.

It covers all the fundamental abstractions found in functional programming, and the homework has some close-to-real-life examples that students must do.

5 stars.


I am not sure if this article was a joke or somebody seriously think that functional programming should be learnt by Ruby, JS and Scala. I have learnt much more by using Erlang, Clojure and some parts of OCaml. Learning for just learning programming in general and getting into the most popular languages is a different subject though. If I was to learn FP I would start with Elixir and probably with Racket just to learn a LISP dialect. It is much fun.


The book Functional Programming in Scala is widely regarded as one of the best books on functional programming in any language. It has very little to do with the Scala language and everything to do with how you would write purely functional programs for the real world (file systems, concurrency, etc).


Sadly you did not reflect to anything I wrote. I bet the Scala book is pretty good, however I would still learn programming from SICP if I just wanted to learn how to write purely functional programs. This is just a matter of taste.


As most professional programmers do not get to choose which language to use the best way to learn functional programming that you can actually use is to implement pure functions in the language that you are required to use. Look at classic texts like Structure and Interpretation of Computer Programs for guidance on the abstractions rather than on the specific implementations.

I write as much as I can in functional style even though I have to use VB.Net.


Considering the popularity of JS and Ruby as a first language for many new programmers, I could see the argument that it would be useful in the sense of getting them to understand basic functional concepts in a more familiar environment.

Although, I agree with you: a Lisp (probably Racket or Scheme) is a much better bet for learning the functional style.


And SICP is a great book. :)


Learning through reading is one thing, but I've found that I never truly understand the concepts until I begin to write some code in a functional way.

We have some Scala in my work environment. I had taken the course, read the book, and spent a little time writing some code, though as deadlines got tight, I would revert back to Java.

It wasn't until I forced myself to write everything in Scala that some of the idiomatic patterns started to make sense. For example, an export job was timing out due to numerous synchronous calls to external services. I rewrote it using async Futures with flatmap and collect, and it was much faster.

Even though I had read about Futures and their functional use a dozen different times, I realized I truly didn't understand them 'till I could apply them to a concrete problem I had. Also, Twitter puts out a lot of really good Scala stuff: Twitter school, Effective Scala, Finagle and Finatra, etc.

TLDR; read the books while writing some code.


I can recommend reading Practical Object-Oriented Design in Ruby by Sandi Metz to every programmer out there. This is so much important to understand basics of Code Design. Even if you think you will not be doing any functional or object-oriented programming, still, go ahead and read it.


The book that helped me the most in terms of pragmatic use of functional concepts in real world applications was Higher Order Perl. The examples have been translated into several other languages, if Perl gives you hives (I quite like Perl, but I know it is scary for some folks). It really does a great job of demonstrating from the lowest levels of a functional system (closures, recursion, first class functions, etc.) on up to actually doing things with those basic building blocks.

It is certainly not "pure", but if you're coming from a procedural/OO world mindset, it's a fantastic bridge. That said, it doesn't cover some of the newer features of some modern FP languages, and won't necessarily directly apply to writing in Haskell or ML.


Realm of Racket is a fun and engaging book. It will guide you through making successively more complex and interesting games using a Racket, which is modern and fairly widely used type of Scheme.


The React and Redux community is heavily influenced by Functional Programming. Because of that, I've collected a number of friendlier / easier-to-read articles on understanding FP as part of my React/Redux links list: https://github.com/markerikson/react-redux-links/blob/master... . Some pretty good articles in there.


Depends a bit on how deep you want to learn but I found using underscore in javascript helpfull https://smthngsmwhr.wordpress.com/2014/02/02/eloquent-javasc...

The problem I had with full on functional stuff was seeing what the point is - ok you could replace your for loop with some weird recursive stuff which the compiler will turn back to imperative behind the scenes so it will run quick but I had a trouble seeing why. However replacing some javascript loops with underscore stuff I was able to see how it was more compact and less bug prone. Also it doesn't take long to get.


There is this free ebook on functional programming in Python by O'Reilly: http://www.oreilly.com/programming/free/functional-programmi...


Apparently it's been 'open sourced'

https://archive.org/details/functional-programming-python

ps: once upon a time I stumbled upon a FP article in python dealing with designing (not applying known patterns) function call protocols to solve aritmethic problems. Asked on HN already but nobody could help. So just in case it rings someone else's bell .. feel free to reply.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: