4. Java and FP Agenda
•Intro & Context
•Non-FP features
•Lambdas
•Streams
5. Big Points
• Pragmatically speaking, FP helps you do efficient things with
collections, taking advantage of multi-core or distributed
systems
• Lambdas are small functions that you implement that extend
SAM Interfaces, likely the ones found in java.util.function.*
• Streams are where collections and lambdas come together, you
want to get familiar with java.util.stream.*
7. Background
• Java8 delayed for security improvements
and lambdas
• Brian Goetz is lead on lambdas
• Java8 released March 2014
• next release will feature Jigsaw
(modularity)
49. Interfaces vs Abstract Classes
feature interface abstract class
method definitions yes yes
method
implementations
yes with default yes
state no yes
have a constructor no yes
use synchronized
on methods
no yes
103. So is Java8 a Functional Language?
Not at all a purely functional language.
104. What Next?
• Goetz talked about adding case classes
• I’d like matchers
• for comprehensions
!
def findChannelsForUser(id: Int): Option[List[String]] = {
for {
user <- userManager.findUserById(id)
account <- accountManager.findAccountForUser(user)
channels <- channelManager.findChannelsForAccount(account)
} yield (channels)
}
105. Big Points
• Pragmatically speaking, FP helps you do efficient things with
collections, taking advantage of multi-core or distributed
systems
• Lambdas are small functions that you implement that extend
SAM Interfaces, likely the ones found in java.util.function.*
• Streams are where collections and lambdas come together, you
want to get familiar with java.util.stream.*