+ All Categories
Home > Software > 10 good reasons to invest your time in FP

10 good reasons to invest your time in FP

Date post: 27-Jun-2015
Category:
Upload: joel-correa
View: 293 times
Download: 0 times
Share this document with a friend
Description:
http://www.thedevelopersconference.com.br/tdc/2014/portoalegre/trilha-linguagens-funcionais
Popular Tags:
54
#10 good reasons to invest your time in FP Humberto Streb @humbertostreb Joel Corrêa @joelcorrea_
Transcript
Page 1: 10 good reasons to invest your time in FP

#10 good reasons to invest your time in FP

Humberto Streb @humbertostreb

Joel Corrêa @joelcorrea_

Page 2: 10 good reasons to invest your time in FP
Page 3: 10 good reasons to invest your time in FP

#1 Learn

Page 4: 10 good reasons to invest your time in FP
Page 5: 10 good reasons to invest your time in FP

#2 Parallel collections

Page 6: 10 good reasons to invest your time in FP

Multicore powered Parallel collections

F#

Page 7: 10 good reasons to invest your time in FP

Collection operations: Map - Reduce

Page 8: 10 good reasons to invest your time in FP

Map –> Applies a given fn to each element

Reduce –> Combine / Accumulate /

fold / compress results though combining operation

Higher order functions

Page 9: 10 good reasons to invest your time in FP

Sample

Page 10: 10 good reasons to invest your time in FP

Map

20 18 41 25 29 32 30 38

age

Map

Page 11: 10 good reasons to invest your time in FP

Reduce

20 18

236

25 44 29 32 …

Combining fn: a+b (operation = +)

Page 12: 10 good reasons to invest your time in FP

+ Data

Map age Map age Map age Map age

Page 13: 10 good reasons to invest your time in FP

map in parallel

Page 14: 10 good reasons to invest your time in FP

reduce in parallel

Page 15: 10 good reasons to invest your time in FP

filter in parallel

Page 16: 10 good reasons to invest your time in FP

#3 Focus

Page 17: 10 good reasons to invest your time in FP

Boilerplate code

Page 18: 10 good reasons to invest your time in FP
Page 19: 10 good reasons to invest your time in FP
Page 20: 10 good reasons to invest your time in FP

REPL

Page 21: 10 good reasons to invest your time in FP

#4 Troubleshooting

Page 22: 10 good reasons to invest your time in FP

Same result value given the same

arguments

Page 23: 10 good reasons to invest your time in FP

Troubleshooting in FP

Consistency

Once wrong, always wrong

Arguments only

No global state

Referential transparency

Page 24: 10 good reasons to invest your time in FP

#5 State discipline

Page 25: 10 good reasons to invest your time in FP

Side effects…

Page 26: 10 good reasons to invest your time in FP

Pure function

Page 27: 10 good reasons to invest your time in FP

Immutable It is highly recommended that value objects be immutable. They are created with a constructor, and never modified during their life time. Eric Evans

Page 28: 10 good reasons to invest your time in FP

Immutable

Page 29: 10 good reasons to invest your time in FP

Immutable

Page 30: 10 good reasons to invest your time in FP

#6 Built-ins

Page 31: 10 good reasons to invest your time in FP

Non-Blocking

Futures

Parallel

Page 32: 10 good reasons to invest your time in FP

Null checks

Optionals

Explicit

Page 33: 10 good reasons to invest your time in FP

Interoperability

Page 34: 10 good reasons to invest your time in FP

#8 Simplicity

#7 Simplicity

Page 35: 10 good reasons to invest your time in FP
Page 36: 10 good reasons to invest your time in FP

#8 Simplicity

Salesmen…

Page 37: 10 good reasons to invest your time in FP

#8 Simplicity

Page 38: 10 good reasons to invest your time in FP

#8 Composition

Page 39: 10 good reasons to invest your time in FP

# Building blocks

Inheritance

Polymorphism

HOFs

Composition

OOP = Objects

FP = Functions

Real world / Complex scenarios  

Page 40: 10 good reasons to invest your time in FP

# HOFs

Receives fn

Page 41: 10 good reasons to invest your time in FP

# Partially applied

Returns fn

Page 42: 10 good reasons to invest your time in FP

# Composition

Page 43: 10 good reasons to invest your time in FP

#9 Testability

Page 44: 10 good reasons to invest your time in FP

if($player->getScore() > 0) {!!$player->setSwizzle(7);!

} else {!!$player->setSwizzle(!! !$player->getSwizzle() + 1;!!);!

}!

Hard to test

Page 45: 10 good reasons to invest your time in FP
Page 46: 10 good reasons to invest your time in FP
Page 47: 10 good reasons to invest your time in FP

#10 Principles

Page 48: 10 good reasons to invest your time in FP

FP in non-FP languages

Guidelines

Side effects

Immutability

Referen'al  transparency  

Page 49: 10 good reasons to invest your time in FP

FP in non-FP languages

functools

LuaFun

Page 50: 10 good reasons to invest your time in FP

# Challenges ahead

Page 51: 10 good reasons to invest your time in FP

Readability / Expressiveness

Page 52: 10 good reasons to invest your time in FP

Learning curve

Page 53: 10 good reasons to invest your time in FP
Page 54: 10 good reasons to invest your time in FP

Samples

https://github.com/jjcorrea/TenGoodReasonsToInvestYourTimeInFP

Resources

http://twitter.github.io/scala_school/ http://twitter.github.io/effectivescala http://coursera.org/course/progfun


Recommended