Slide 1

Slide 1 text

Conservative Mark Hibberd Scala

Slide 2

Slide 2 text

You can make better use of tools by having deep knowledge of a tool, but only applying a specialised subset of its features. Claim #1

Slide 3

Slide 3 text

You can’t effectively control your use of tools to a specialised subset unless you have very deep knowledge of the tool. Claim #2

Slide 4

Slide 4 text

Programming languages are just tools. Claim #3

Slide 5

Slide 5 text

Conservative usage patterns generalise to lots of tools not just languages. Claim #4

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

SCALA a primer

Slide 8

Slide 8 text

1 scala> val x = List("1", "2", "3", "4").toSet() + "5" 2 3 scala> println(x) 4 5 output: 6 7 ???

Slide 9

Slide 9 text

1 scala> val x = List("1", "2", "3", "4").toSet() + "5" 2 3 scala> println(x) 4 5 output: 6 7 false5

Slide 10

Slide 10 text

1 scala> println({} + "") 2 3 output: 4 5 ???

Slide 11

Slide 11 text

1 scala> println({} + "") 2 3 output: 4 5 ()

Slide 12

Slide 12 text

1 scala> val x = Option(1).zip(Option(1)) == 2 Option((1, 1)) 3 4 scala> println(x) 5 6 output: 7 8 ???

Slide 13

Slide 13 text

1 scala> val x = Option(1).zip(Option(1)) == 2 Option((1, 1)) 3 4 scala> println(x) 5 6 output: 7 8 false

Slide 14

Slide 14 text

1 scala> val x = Option(1).zip(Option(1)) == 2 List((1, 1)) 3 4 scala> println(x) 5 6 output: 7 8 ???

Slide 15

Slide 15 text

1 scala> val x = Option(1).zip(Option(1)) == 2 List((1, 1)) 3 4 scala> println(x) 5 6 output: 7 8 true

Slide 16

Slide 16 text

1 scala> val x = Option(1).zip(Option(1)) == 2 Vector((1, 1)) 3 4 scala> println(x) 5 6 output: 7 8 true

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

scalac thinks your code is bad

Slide 19

Slide 19 text

1 List("1", "2", "3", "4").toSet() + “5"

Slide 20

Slide 20 text

1 List("1", "2", "3", "4").toSet() + "5" 2 3 // example.scala:1: error: not enough arguments for 4 // method apply: (elem: Any)Boolean in trait GenSet. 5 // Unspecified value parameter elem. -Yno-adapted-args

Slide 21

Slide 21 text

1 def update(data: String): Future[Unit] = for { 2 n <- get 3 _ <- save(n, data) 4 } yield set(n + 1) 5 6 def get: Future[Int] = 7 ??? 8 9 def set(n: Int): Future[Int] = 10 ??? 11 12 def save(n: Int, data: String): Future[Unit] = 13 ???

Slide 22

Slide 22 text

1 def update(data: String): Future[Unit] = for { 2 n <- get 3 _ <- save(n, data) 4 } yield set(n + 1) 5 6 //example.scala:4: warning: discarded non-Unit value -Ywarn-value-discard

Slide 23

Slide 23 text

-Xlint / -Ywarn-all https://github.com/scala/scala/blob/v2.10.3/src/compiler/scala/tools/nsc/settings/ Warnings.scala#L18-L44

Slide 24

Slide 24 text

-Xfatal-warnings

Slide 25

Slide 25 text

-Yno-predef

Slide 26

Slide 26 text

scala scala vs

Slide 27

Slide 27 text

Lets reduce the surface area of the language we have to worry about

Slide 28

Slide 28 text

Lets not save characters by risking correctness

Slide 29

Slide 29 text

Lets not make it “easy” by building APIs using ever scala feature ever

Slide 30

Slide 30 text

Lets do more with less

Slide 31

Slide 31 text

Syntax

Slide 32

Slide 32 text

Types & Inference

Slide 33

Slide 33 text

Closed better than Open

Slide 34

Slide 34 text

Don’t confuse Types and Data

Slide 35

Slide 35 text

Scala does not have Type Inference

Slide 36

Slide 36 text

Variance or Not

Slide 37

Slide 37 text

Any is the same as not having Types

Slide 38

Slide 38 text

Implicits

Slide 39

Slide 39 text

Type Classes vs Global Mutable HashMaps

Slide 40

Slide 40 text

Syntactic Extensions

Slide 41

Slide 41 text

Scala is just a Tool

Slide 42

Slide 42 text

Performance vs Correctness

Slide 43

Slide 43 text

Concurrent Scala is not a Win

Slide 44

Slide 44 text

Integration not Ecosystem

Slide 45

Slide 45 text

End Game