This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Functional Programming Books to read from O'Reilly ( or others )  RSS feed

 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen the topic of functional programming in several threads but don't know much about it. This week O'Reilly is having a 50% off sale on their latest functional programming books but none of the books have been reviewed on the ranch yet. Does anyone have any recommendations or suggestions about reading these books?

Here is the link from O'Reilly

O'Reilly functional programming books and videos on sale 50% off

Since I am a bookworm ALL of them look good to me !

T.I.A.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's not from ORA, but if you want a general introduction to functional programming, then SICP by Abelson/Sussman is the gold standard, IMO.
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link, Ulf, it looks interesting. Since the SICP (Structure and Interpretation of Computer Programs , MIT, 2nd ed) book has a date of 1996 functional programming has been around for awhile. To me it seems that we have just started talking about it in the last few years. Am I out-of-date and it has been around for awhile?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Functional programming goes back to Lisp -which got started in 1958 according to Wikipedia- so the functional idea is a lot older than the idea of object-orientation. What is new in the Java space is the wide-spread use of JVM-based functional languages like Scala and Clojure. But something like Kawa -a JVM-based implementation of Scheme, the language used in SICP- has been around a lot longer than either of those. It just wasn't cool, apparently :-)
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is new in the Java space is the wide-spread use of JVM-based functional languages like Scala and Clojure. Ulf.


I have noticed that some of the newer functional books give examples in Java as well as in Scala and Clojure. Is functional programming something that would be used with OOP in a Java project or would the project use one or the other?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll leave that question to folks who use those languages more than I do :-)

What is possible in all the dialects I mentioned -Scala, Clojure, Kawa- is that the functional code can make use of the Java class libraries. If you read SICP, you may get the idea that only command-line stuff and file I/O is possible -which is all that Scheme defines, after all- but Kawa can make use of everything the Java class libraries offer, so you're not starting from zero.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16007
87
Android IntelliJ IDE Java Scala Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
margaret gillon wrote:I have noticed that some of the newer functional books give examples in Java as well as in Scala and Clojure. Is functional programming something that would be used with OOP in a Java project or would the project use one or the other?

You don't have to choose between object-oriented or functional programming, and a language such as Scala is designed to support both object-oriented and functional programming, and you can (and many people do) use both styles at the same time. Ofcourse you can choose how far you want to go with either style.

About the O'Reilly 50% off offer: I see there are only three books, two of which aren't even released yet (you can get an early access version); one book about functional JavaScript, and a video about Java, Clojure and Scala. I don't have those books / video myself so I can't say anything about them.

A book that I like about Scala is this one: Scala for the Impatient

I learned Scala a few years ago from Programming in Scala, by Martin Odersky (the inventor of Scala) but that book is fom 2011 and it's several versions behind on the current version of Scala.

If you really want to dive into functional programming, then have a look at the language Haskell. A good free, online book about Haskell is this one: Learn You a Haskell. Haskell is purely functional, not OO.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a load of introductory stuff about FP at the JavaRanch Functional Programming forum, so that should help to get you started. There is also some stuff on Clojure and Scala in the excellent book The Well Grounded Java Developer by Ben Evans and Martijn Verburg, which is worth buying anyway, regardless of your interest in FP.

You're right that there is a lot more talk about FP this days, and I'm seeing a real growth in Scala job ads in particular. I think this is partly because Scala is a little easier for Java developers to get started with and you can use it as a "better Java" or you can go FP all the way. It has a number of significant corporate backers/users e.g. Twitter, LinkedIn, etc, and is being heavily promoted as the tool of choice for concurrency, Big Data (Apache Spark is written in Scala) and "enterprise-y" stuff in general. However, many of the same arguments apply for FP generally, not just Scala.

There are quite a few Scala books out there now, although the language has been developing fast so some of the older ones may be a little out of date. There are free samples of some of these (and others) on the Typesafe website, as well as lots of other Scala-related resources. My O'Reilly tips are in bold.

  • Programming In Scala by Martin Odersky. Odersky invented Scala, so this is probably the best general reference book on the language to keep on your shelf, but I found his style a bit academic if you're mainly interested in getting started with the language.
  • Scala For The Impatient by Cay Horstmann is much better as a learning resource in terms of structure, and Horstmann's experience of writing tech books clearly shows.
  • Scala In Action by Nilanjan Raychaudhuri is quite a good tutorial and all-round look at Scala in the classic Manning "XXX In Action" style, and you get a free ebook if you buy the print edition.
  • Testing In Scala by Daniel Hinojosa might be an easy place to start, because Scala has some really nice testing tools that you use in Java as well. However, this book is pretty light, and you can get a lot of this stuff elsewhere online e.g. check out Kip Sigman's nice 15 minute video on Scala testing if you're curious.
  • The excellent Scala Cookbook by Alvin Alexander assumes you know a little Scala and is an outstanding collection of tips, tricks and techniques to make your Scala shine. I can see this being the most useful book in my Scala collection.
  • Another interesting book for OO people coming to FP is Functional Programming Patterns in Scala and Clojure by Michael Bevilacqua-Linn, which looks at how various classic OO patterns are expressed in FP (many are no longer needed), and also at specifically functional patterns.

  • Talking of going from OO to FP:

  • Functional Programming for the Object-Oriented Programmer by Brian Marick is a clever tutorial approach to help OO developers learn FP in Clojure.

  • Clojure is basically a Lisp language for the JVM, with various modern features added and some work-arounds for limitations of the JVM, and like Scala it has excellent interoperability with Java i.e. you can call Java from Clojure etc. It was created by Rich Hickey, who has a very strong (and IMO very persuasive) concept of "simplicity" in programming, which really shines through all of Clojure. So Clojure is very different from Scala both in form and underlying philosophy. I really like what I've seen of Clojure (not much!) and it's fun to work with, but right now it probably has less take-up in the "enterprise" than Scala, partly because of its Lisp origins which put some people off, and perhaps partly because it looks too "simple": I think some people still seem to feel their "enterprise" software has to look like Java EE!

    I haven't seen so many Clojure books, but they include:

  • Clojure Programming by Chas Emerick, Brian Carper and Christopher Grand, which is easily the most comprehensive Clojure programming book I've seen. It's full of good stuff on a wide range of topics, from FP basics to web and database programming, including some tips on "Introducing Clojure into Your Workplace (or, Sneaking Clojure Past the Boss)"!
  • The second edition of The Joy Of Clojure by Michael Fogus is about to be released. The first edition was a good intro to FP in Clojure, but not as thorough as the "Clojure Programming" book.
  • Web Development With Clojure by Dmitri Sotnikov is a quick practical intro to web application development in Clojure, which is fun and nicely illustrates how much you can do with just a few lines of code in Clojure.
  • There's also an interesting little book Clojure Data Analysis Cookbook by Eric Rochester which is not an O'Reilly "cookbook" but has lots of practical ides for using Clojure for data science.

  • And if learning Lisp feels too daunting, you could prepare by working through The Little Schemer by Daniel Friedman and Matthias Felleisen, which is a strange but effective introduction to the basics of Scheme (a Lisp language) that may help you to get your head into the FP mindset. And it's fun, in a weird, central-European-animated-films-of-the-1960s kind of a way!

    Finally, you've no doubt seen that Java is starting to take up some of the ideas that have been around in FP for decades e.g. lambdas, so FP techniques will become more relevant to Java developers in future. There are books and other materials around for learning how to do FP in Java. But to be honest, I think it's much easier to learn FP in a language that's actually designed for it - e.g. Scala and Clojure on the JVM, or Haskell, Scheme/Racket etc outside the JVM. If you subsequently find yourself having to do FP in Java in a legacy environment, then at least you'll know how functional techniques are supposed to work, and maybe you'll even be able to sneak some real FP past the boss!
     
    margaret gillon
    Ranch Hand
    Posts: 335
    6
    Linux Tomcat Server Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Jesper, Ulf, and Chris,
    Thanks to all of you for the book recommendations and for the links to online references. This material will keep me busy for awhile. Margaret.
     
    margaret gillon
    Ranch Hand
    Posts: 335
    6
    Linux Tomcat Server Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    A good free, online book about Haskell is this one: Learn You a Haskell. Haskell is purely functional, not OO. Jesper.

    I am going to start with the online book that Jesper posted and see how I do . . .
     
    chris webster
    Bartender
    Posts: 2407
    33
    Linux Oracle Postgres Database Python Scala
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    margaret gillon wrote:
    A good free, online book about Haskell is this one: Learn You a Haskell. Haskell is purely functional, not OO. Jesper.

    I am going to start with the online book that Jesper posted and see how I do . . .

    You might be interested in this 8-week Functional Programming course from EdX, which will be using Haskell as the teaching language:

    https://www.edx.org/course/delftx/delftx-fp101x-introduction-functional-2126

    It's taught by Erik Meijer who's a big cheese in the world fo FP.

     
    margaret gillon
    Ranch Hand
    Posts: 335
    6
    Linux Tomcat Server Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Chris,
    Thanks for the course information! It does look interesting and I like having a structured learning path from a class.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!