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

More Decks by Dmitry Ivanov

Other Decks in Programming


  1. 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-
  2. An Example • global protocol (a asks b to calculate

    "x / y"): a -> b: <number>. a -> b: <number> . b -> a: { ok: b -> a: <number>. end, fail: end } • local projection for a: [b]!<number>. [b]!<number>. [b]? { ok: [b]?<number>. end, fail: end } • local projection for b: [a]?<number>. [a]?<number>. [a]! { ok: [a]!<number>. end, fail: end }
  3. 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
  4. 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
  5. 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
  6. 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)))
  7. Example: Discrimitator fields support in DSL (int32 :+: bool(8) :+:

    variableSizeBytes(uint8, ascii)) .discriminatedByIndex(uint8)
  8. Need for Async by Konrad Malawski @ktosopl • Tail latency:

    measure the right thing • Always bench, don't assume • Check the SLA for all percentiles
  9. 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
  10. 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#/
  11. * 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.
  12. * 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
  13. * 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
  14. * 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 { .... }]
  15. 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(?), ...
  16. 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
  17. Heuristics for approachable, modular and functional libraries by Erik Osheim

    @d6 Slides: http://plastic-idolatry.com/erik/sw2015.pdf
  18. 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"
  19. 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.
  20. Modular Strive for modularity. Move small & useful utilities to

    standalone projects. Use & support other libraries. Platform independent by default. Case: cats.JVM / cats.JS.
  21. 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
  22. 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.
  23. 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)