Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ScalaWorld 2015 Recap

ScalaWorld 2015 Recap

Some highlights of ScalaWorld 2015 conference (https://scala.world) that was held on September 20-22 in Lake District, UK.

Dmitry Ivanov

October 01, 2015
Tweet

More Decks by Dmitry Ivanov

Other Decks in Programming

Transcript

  1. ScalaWorld 2015
    Recap
    Joost Heijkoop
    Dmitry Ivanov (@idajantis)
    Amsterdam.Scala meetup
    1st October 2015

    View Slide

  2. View Slide

  3. The Newest in Session Types
    by Roland Kuhn @rolandkuhn
    From Data Types to Session Types
    Session - a unit of conversation.
    Session Type - the structure of a conversation, a sequence of
    interactions in a communication-centric program model.
    Primitives: sending, receiving, sequence, choice, recursion
    Scribble language.
    Slides: http://www.slideshare.net/rolandkuhn/the-newest-in-

    View Slide

  4. An Example
    • global protocol (a asks b to calculate "x / y"):
    a -> b: . a -> b: .
    b -> a: { ok: b -> a: . end, fail: end }
    • local projection for a:
    [b]!. [b]!.
    [b]? { ok: [b]?. end, fail: end }
    • local projection for b:
    [a]?. [a]?.
    [a]! { ok: [a]!. end, fail: end }

    View Slide

  5. Use Cases
    • Real-world internet protocols (e.g. POP3 example, SMTP)
    • Multi-party concurrency problems (e.g. dining philosophers)
    https://github.com/epsrc-abcd/session-types-use-cases

    View Slide

  6. Beyond Scala Lens
    by Julien Truffaut @julientruffaut
    Slides http://www.slideshare.net/JulienTruffaut/beyond-scala-lens

    View Slide

  7. Optics overview
    Nice explanation of how Iso, Prism,
    Lens work.
    • Iso
    f: S => A, g: A => S
    • Prism
    f: S => Option[A], g: A => S
    • Lens
    f: S => A, g: (A, S) => S
    Introduced a new Optic type: Optional
    • Optional
    f: S => Option[A], g: (A, S) => S

    View Slide

  8. Practical Binary with Scodec
    by Michael Pilquist @mpilquist
    Scodec - a Shapeless-powered library for working with binary
    protocols.
    Codec = serializer + deserializer
    Via Shapeless: automatic codec derivation, cached implicit
    instances, etc.
    Slides: https://speakerdeck.com/mpilquist/practical-binary-
    with-scodec-and-shapeless

    View Slide

  9. Automatic case class binding (via Shapeless HLists)
    case class Point(x: Int, y: Int, z: Int)
    val pointCodec = (int8 :: int8 :: int8).as[Point]
    val encoded: Attempt[BitVector] = pointCodec.encode(Point(-5, 10, 1))
    // Successful(BitVector(24 bits, 0xfb0a01))
    val decoded: Attempt[DecodeResult[Point]] = pointCodec.decode(hex"0xfb0a01".bits)
    // Successful(DecodeResult(Point(-5,10,1),BitVector(empty)))

    View Slide

  10. Example: Discrimitator fields support in DSL
    (int32 :+: bool(8) :+: variableSizeBytes(uint8, ascii))
    .discriminatedByIndex(uint8)

    View Slide

  11. Need for Async
    by Konrad Malawski @ktosopl
    • Tail latency: measure the right thing
    • Always bench, don't assume
    • Check the SLA for all percentiles

    View Slide

  12. Need for Async
    • Lock-free and Wait-free algorithms:
    "concurrent < lock-free < wait-free"
    • "Functional outside, Intel inside: Sorting"
    • JMH sbt plugin in action: perf_events, perf_asm integration
    • Flame graphs
    • Slides: http://www.slideshare.net/ktoso/the-need-for-async-
    scalaworld

    View Slide

  13. Implicits 2.0 / Levelling UP Scala
    by Adriaan Moors @adriaanm
    • Lift Literal Values to Types
    • Opaque Type Members
    • Implicit Types
    • Matching on Types
    Slides: http://adriaanm.github.io/reveal.js/levelup.html#/

    View Slide

  14. * Lift Literal Values to Types
    scala> val x: 3 = 1 + 2
    x: 3 = 3
    SIP-23: http://docs.scala-lang.org/sips/pending/42.type.html.
    Still WIP.

    View Slide

  15. * Opaque Type Members
    Bringing val and type a bit closer
    class C { type T <: Int = 1 ; def foo(x: T) }
    class D { override type T <: Int = 2 } extends C
    Before: type alias is implicitly final

    View Slide

  16. * Implicit Types
    "let's not identify types from witnesses"
    class C { implicit type T <: Int = 1 }
    Then:
    def foo(x: C)(implicit w: x.T) = println(w)
    foo(new C) // prints 1
    foo(new D) // prints 2

    View Slide

  17. * Matching on Types
    class Set[T] {
    type BuilderFor[U] <: SetBuilder[U] =
    DefaultSetBuilder[U]
    }
    class BitSet extends Set[Int] {
    type BuilderFor[U] <: SetBuilder[U] =
    U match {
    case Int => BitSetBuilder
    case t => super.BuilderFor[t]
    }
    }
    What is
    valueOf[T match { .... }]

    View Slide

  18. Type-driven Development in Idris
    by Edwin Brady @edwinbrady
    • Idris (http://www.idris-lang.org)
    A Language with Dependent Types.
    • Dependent Types
    Value-level constructions ~= Type-level constructions
    • Haskell-like syntax
    • Code generators: Java, JavaScript, PHP (o_O), C(?), ...

    View Slide

  19. Idris Dependent Types
    app : Vect n a -> Vect m a -> Vect (n + m) a
    app Nil ys = ys
    app (x :: xs) ys = x :: app xs ys

    View Slide

  20. Heuristics for approachable,
    modular and functional libraries
    by Erik Osheim @d6
    Slides: http://plastic-idolatry.com/erik/sw2015.pdf

    View Slide

  21. Things learned from Spire
    • Always benchmark new features
    • Property-based testing FTW: scalacheck, scalaprops
    • "If you care about testing, measure code coverage"
    • Mistake: making a monolithic project
    • Enforce consistency: scalastyle (http://www.scalastyle.org)
    • Type Classes shouldn't have default implementation.
    "Avoid inefficient default implementations"

    View Slide

  22. Use Eval[T] for laziness
    Three branches: eager val, lazy val and def
    Advantage of Eval[T]: you can return a lazy value.
    By-name params: no memoization, type system doesn't
    distinguish A and (=> A), (=> A) unconditionally allocates a
    Function0[A]
    Abstracting over laziness and eagerness using Type
    Constructors.

    View Slide

  23. Modular
    Strive for modularity.
    Move small & useful utilities to standalone projects.
    Use & support other libraries.
    Platform independent by default. Case: cats.JVM / cats.JS.

    View Slide

  24. Constraints Liberate, Liberties Constrain
    by Rúnar Bjarnason @runarorama
    Type constraints: Actors vs Futures for concurrency
    Premature:
    Loss of precision, Concretisation, Folding, Compilation,
    Optimisation.
    • Reach for the least powerful abstraction
    • Detonate as late as possible
    • Premature loss of precision is the root of all evil

    View Slide

  25. Other Notes
    Awesome conf report from Guardian:
    https://www.theguardian.com/info/developer-blog/live/2015/
    sep/21/conference-report-scala-world-2015
    My talks TODO list:
    • "A Deep Dive into Scalac...", Chris Birchal.
    • "Typelevel Programming 101", Joe Barnes.
    • "Reactive Streams / Akka Stream", Mathias Doenitz &
    Johannes Rudolph.

    View Slide

  26. SIP-2712
    SIP-2712: "Implement higher-order unification for type
    constructor inference"*
    object Test {
    def meh[M[_], A](x: M[A]): M[A] = x
    meh{(x: Int) => x} // should solve ?M = [X] X => X and ?A = Int ...
    }
    console>:9: error: no type parameters for method meh: (x: M[A])M[A] exist
    so that it can be applied to arguments (Int => Int)
    Workaround from Miles Sabin: continuation passing style on
    a type level!
    (check "Kittens - Shapeless Typeclass Derivation for Cats" talk)

    View Slide

  27. Questions? :)

    View Slide

  28. Naming things and finding cothings
    .

    View Slide