Re:Mostly Adequate Guide to Functional Programming in JavaSc...
by ignoramous on Tuesday July 14, 2015 @04:19PM
(#9887742)
You might already be using certain functional programming constructs without being aware of them. Contrary to popular misconception, OOP and functional programming don't have to be mutually exclusive. "Pure" functional programming (ala Haskell) and OOP most certainly are to an extent non-overlapping (since OOP has state+behaviour at its core), and pure fn-languages have no side-effects.
High-order function in java don't exist, so one would do :
new Thread(new Runnable() { ... }).start();
A builder pattern can be distilled down as a form of partial application (or, currying, if you like. They aren't the same thing, but are very similar):
Functors (in OCaml) can be viewed as Java's abstract-generic-classes with dependency injection [0]. Note that functors in different languages mean different things.
Monads are tricky to understand [1], I have been led to believe. But if you use the promises API in javascript, then you're using a form of monad [2].
If you're familiar with javascript, have a look at: https://www.youtube.com/watch?v=m3svKOdZijA (Hey Underscore, you're doing it wrong!) I think the best way is to read a book on fn-programming. I've heard most people recommend these (pick a language, and choose a book; you cannot go wrong with any of these):
High-order function in java don't exist, so one would do :
A builder pattern can be distilled down as a form of partial application (or, currying, if you like. They aren't the same thing, but are very similar): Functors (in OCaml) can be viewed as Java's abstract-generic-classes with dependency injection [0]. Note that functors in different languages mean different things.Monads are tricky to understand [1], I have been led to believe. But if you use the promises API in javascript, then you're using a form of monad [2].
If you're familiar with javascript, have a look at: https://www.youtube.com/watch?v=m3svKOdZijA (Hey Underscore, you're doing it wrong!) I think the best way is to read a book on fn-programming. I've heard most people recommend these (pick a language, and choose a book; you cannot go wrong with any of these):
Functional DS: http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf
Real World Haskell: http://book.realworldhaskell.org/read/
Real World OCaml: https://realworldocaml.org/v1/en/html/index.html The Joy of Clojure: http://www.manning.com/fogus2/
Learn You a Haskell for Greater Good: http://learnyouahaskell.com/chapters
Learn You some Erlang for Greater Good: http://learnyousomeerlang.com/content
Systems Programming in OCaml: https://ocaml.github.io/ocamlunix/
[0] https://monadmadness.wordpress.com/2015/01/02/monoids-functo...
[1] https://realworldocaml.org/v1/en/html/functors.html
[2] https://news.ycombinator.com/item?id=4189082