Live data from Hacker News

How Do I Learn Some Functional Programming?

fse.guru

11–17 of 17 posts

Re: How Do I Learn Some Functional Programming?

#11

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 lear…

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.

Re: How Do I Learn Some Functional Programming?

#12
post #7

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.

Re: How Do I Learn Some Functional Programming?

#13
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.

Re: How Do I Learn Some Functional Programming?

#14
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.

Re: How Do I Learn Some Functional Programming?

#15
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.

Re: How Do I Learn Some Functional Programming?

#17
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.

Post reply on HN