Top Banner
Intro to scala Ignasi Marimon-Clos (@ignasi35) IronHack
114

Intro scala for rubyists (ironhack)

Apr 14, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intro scala for rubyists (ironhack)

Intro to scala

Ignasi Marimon-Clos (@ignasi35)

IronHack

Page 2: Intro scala for rubyists (ironhack)

@ignasi35

thanks!

Page 3: Intro scala for rubyists (ironhack)

@ignasi35

about you

Page 4: Intro scala for rubyists (ironhack)

@ignasi35

about me

@ignasi35

1) problem solver, Garbage Collector, scala, java8

2) kayaker

3) under construction

4) all things JVM

Page 5: Intro scala for rubyists (ironhack)

@ignasi35

Page 6: Intro scala for rubyists (ironhack)

@ignasi35

ruby vs scala

more similar than you think

Page 7: Intro scala for rubyists (ironhack)

@ignasi35

ruby vs scala

√ Lambda + closures + currying

√ Collection manipulation (via lambdas)

√ traits (similar to modules)

√ No monkey patching

Page 8: Intro scala for rubyists (ironhack)

@ignasi35

ruby vs scala

https://twitter.com/raichoo/status/692089108022312960

Page 9: Intro scala for rubyists (ironhack)

@ignasi35

mri v jvm

http://www.slideshare.net/CharlesNutter/over-9000-jruby-in-2015

Page 10: Intro scala for rubyists (ironhack)

@ignasi35

mri v jvm

http://www.slideshare.net/CharlesNutter/over-9000-jruby-in-2015

Page 11: Intro scala for rubyists (ironhack)

@ignasi35

mri v jvm

http://jruby.org/bench9000/

Page 12: Intro scala for rubyists (ironhack)

@ignasi35

mri v jvm

http://jruby.org/bench9000/

Page 13: Intro scala for rubyists (ironhack)

@ignasi35

also: invoke scala from ruby !!

mri v jvm

Page 16: Intro scala for rubyists (ironhack)

@ignasi35 End of presentation

Page 17: Intro scala for rubyists (ironhack)

@ignasi35

Page 18: Intro scala for rubyists (ironhack)

@ignasi35

Page 19: Intro scala for rubyists (ironhack)

@ignasi35

Page 20: Intro scala for rubyists (ironhack)

@ignasi35

Page 21: Intro scala for rubyists (ironhack)

@ignasi35

Page 22: Intro scala for rubyists (ironhack)

@ignasi35

Page 23: Intro scala for rubyists (ironhack)

@ignasi35

Page 24: Intro scala for rubyists (ironhack)

@ignasi35

Page 25: Intro scala for rubyists (ironhack)

@ignasi35

Page 26: Intro scala for rubyists (ironhack)

@ignasi35

Page 27: Intro scala for rubyists (ironhack)

@ignasi35

Page 28: Intro scala for rubyists (ironhack)

@ignasi35

Page 29: Intro scala for rubyists (ironhack)

@ignasi35

Page 30: Intro scala for rubyists (ironhack)

@ignasi35

Types

class PersonBuilder {

Person build(String name, String surname) { … }

}

Page 31: Intro scala for rubyists (ironhack)

@ignasi35

Page 32: Intro scala for rubyists (ironhack)

@ignasi35

Page 33: Intro scala for rubyists (ironhack)

@ignasi35

Types

class PersonBuilder {

Person build(Name name, Surname surname) { … }

}

Page 34: Intro scala for rubyists (ironhack)

@ignasi35

Page 35: Intro scala for rubyists (ironhack)

@ignasi35

Page 36: Intro scala for rubyists (ironhack)

@ignasi35

Case Classes

Page 37: Intro scala for rubyists (ironhack)

@ignasi35

Case Classes

Equality

Copy

Pattern Matching

Immutable

Syntactic Sugar

Page 38: Intro scala for rubyists (ironhack)

@ignasi35

Page 39: Intro scala for rubyists (ironhack)

@ignasi35

Case Classes

Equality

Copy

Pattern Matching

Immutable

Syntactic Sugar

º

Page 40: Intro scala for rubyists (ironhack)

@ignasi35

Page 41: Intro scala for rubyists (ironhack)

@ignasi35

Page 42: Intro scala for rubyists (ironhack)

@ignasi35

Page 43: Intro scala for rubyists (ironhack)

@ignasi35

Page 44: Intro scala for rubyists (ironhack)

@ignasi35

Page 45: Intro scala for rubyists (ironhack)

@ignasi35

Page 46: Intro scala for rubyists (ironhack)

@ignasi35

Func Prog

Pure Functions

no side effects

if not used, remove it

fixed in — fixed out

Page 47: Intro scala for rubyists (ironhack)

@ignasi35

filter

f

Page 48: Intro scala for rubyists (ironhack)

@ignasi35

map

f

Page 49: Intro scala for rubyists (ironhack)

@ignasi35

fold

f

f

f

Page 50: Intro scala for rubyists (ironhack)

@ignasi35

fold

aka reduce

Page 51: Intro scala for rubyists (ironhack)

@ignasi35

map revisited

f

Page 52: Intro scala for rubyists (ironhack)

@ignasi35

f

map revisited

Page 53: Intro scala for rubyists (ironhack)

@ignasi35

map

f

Page 54: Intro scala for rubyists (ironhack)

@ignasi35

flatMap

f

Page 55: Intro scala for rubyists (ironhack)

@ignasi35

Page 56: Intro scala for rubyists (ironhack)

@ignasi35

Page 57: Intro scala for rubyists (ironhack)

@ignasi35

recap

filter

map

fold

flatMap

Page 58: Intro scala for rubyists (ironhack)

@ignasi35

Page 59: Intro scala for rubyists (ironhack)

@ignasi35

Page 60: Intro scala for rubyists (ironhack)

@ignasi35

Null Dealing

Page 61: Intro scala for rubyists (ironhack)

@ignasi35

Page 62: Intro scala for rubyists (ironhack)

@ignasi35

Null Dealing

class PersonBuilder {

Person build(Name name, Option[Surname] surname) { … }

}

Page 63: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

replaces null completely

Page 64: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

replaces null completelyforever

Page 65: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

replaces null completelyforever

and ever

Page 66: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

replaces null completelyforever

and everand ever

Page 67: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

replaces null completelyforever

and everand everand ever

Page 68: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

replaces null completelyforever

and everand everand everand ever

Page 69: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

replaces null completelyforever

and everand everand everand everand ever

Page 70: Intro scala for rubyists (ironhack)

@ignasi35

filter

f f f

Page 71: Intro scala for rubyists (ironhack)

@ignasi35

map

f f

Page 72: Intro scala for rubyists (ironhack)

@ignasi35

fold

f f

Page 73: Intro scala for rubyists (ironhack)

@ignasi35

Maybe (aka Option)

filter: applies predicate and Returns input or Nonemap: converts contentfold: returns Some(content) or Some(zero)flatMap: see list

get: returns content or throws ExceptiongetOrElse: returns content or defaultValue

Page 74: Intro scala for rubyists (ironhack)

@ignasi35

recap

filter

map

fold

flatMap

Page 75: Intro scala for rubyists (ironhack)

@ignasi35

Page 76: Intro scala for rubyists (ironhack)

@ignasi35

Page 77: Intro scala for rubyists (ironhack)

@ignasi35

Page 78: Intro scala for rubyists (ironhack)

@ignasi35

Page 79: Intro scala for rubyists (ironhack)

@ignasi35

Page 80: Intro scala for rubyists (ironhack)

@ignasi35

Page 81: Intro scala for rubyists (ironhack)

@ignasi35

Page 82: Intro scala for rubyists (ironhack)

@ignasi35

Page 83: Intro scala for rubyists (ironhack)

@ignasi35

Page 84: Intro scala for rubyists (ironhack)

@ignasi35

W T F ! ? ! ?

Page 85: Intro scala for rubyists (ironhack)

@ignasi35

Page 86: Intro scala for rubyists (ironhack)

@ignasi35

Page 87: Intro scala for rubyists (ironhack)

@ignasi35

railway programming

https://fsharpforfunandprofit.com/posts/recipe-part2/

Page 88: Intro scala for rubyists (ironhack)

@ignasi35

INPUT

FAILURE SUCCESS

Page 89: Intro scala for rubyists (ironhack)

@ignasi35

REQUEST

401

RESPONSE

404

400

Page 90: Intro scala for rubyists (ironhack)

@ignasi35

Page 91: Intro scala for rubyists (ironhack)

@ignasi35

railway programming

Page 92: Intro scala for rubyists (ironhack)

@ignasi35

Page 93: Intro scala for rubyists (ironhack)

@ignasi35

Live Live coding

Page 94: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

Page 95: Intro scala for rubyists (ironhack)

@ignasi35

Page 96: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

Read books

Page 97: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

Read teh bookz ! ! !

Page 98: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

because there’s no

One Tool To Rule Them All

Page 99: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

Use Types

Page 100: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

and immutabilty

Page 101: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

prepare for failures

Page 102: Intro scala for rubyists (ironhack)

@ignasi35

Conclusions

but don’t let it clutter your code

Page 103: Intro scala for rubyists (ironhack)

@ignasi35

Page 104: Intro scala for rubyists (ironhack)

@ignasi35

Page 105: Intro scala for rubyists (ironhack)

@ignasi35

Page 106: Intro scala for rubyists (ironhack)

@ignasi35

Page 107: Intro scala for rubyists (ironhack)

@ignasi35

Page 108: Intro scala for rubyists (ironhack)

@ignasi35

Page 109: Intro scala for rubyists (ironhack)

@ignasi35

Page 110: Intro scala for rubyists (ironhack)

@ignasi35

Page 111: Intro scala for rubyists (ironhack)

@ignasi35

Page 112: Intro scala for rubyists (ironhack)

@ignasi35

Arigató

Page 113: Intro scala for rubyists (ironhack)

@ignasi35

Questions

Page 114: Intro scala for rubyists (ironhack)

@ignasi35End of presentation