scala past, present & future

29
Scala PasT, Present & Future @mircodotta

Upload: mircodotta

Post on 16-Apr-2017

122 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Scala Past, Present & Future

Scala PasT, Present &

Future @mircodotta

Page 2: Scala Past, Present & Future

Who am I?• Felt in love with Scala in 2005

• Open Source contributor: Scala compiler & IDE, Lagom, Play, etc.

• Recently co-founded a Scala tooling company!

• Available for trainings (Akka/Play/Scala/Spark) and consulting.

Page 3: Scala Past, Present & Future

Whoever wishes to foresee the future must

consult the past Macchiavelli

Page 4: Scala Past, Present & Future

Scala: The Past

• Scala first release in 2003

• But, what’s the story before Scala?

Page 5: Scala Past, Present & Future
Page 6: Scala Past, Present & Future

Pizza

• 1995-19981

• Superset of Java with generics, first-class functions, case classes and patter matching.

• Why the name?

• Java was hacker’s drink

• Hacker’s food was needed ;-)1. www.slideshare.net/Odersky/scala-evolution/3-Pre_History1980s_Modula2_Oberon199095_Functional

Page 7: Scala Past, Present & Future
Page 8: Scala Past, Present & Future

Java 1.5

• Pizza led to Martin Odersky working on the Java compiler (javac).

• Martin co-designed the first version of generics in Java, and has written the recent javac.

Page 9: Scala Past, Present & Future

Scala origins

• Goal: unify object-oriented and functional paradigms.

• Java was too constraining, hence the motivation to start fresh.

Page 10: Scala Past, Present & Future

2003

Page 11: Scala Past, Present & Future

Scala Martin’s mantra

• A language with a small core, few constructs but high abstraction power.

• Fact: Scala has less keywords than Java!

Page 12: Scala Past, Present & Future

Scala evolution

First release

2003

Twitter adoption

Scala 2.0released

2006

Akkafirst release

2009

Lightbend(formerly Typesafe)

commercialsupport

Scala 2.9released

&Scala project

movedto GitHub

2011

Page 13: Scala Past, Present & Future

Scala evolution

2012

Scala 2.10released

Scala Actordeprecated

and replacedby Akka

2013

Scala.JSreleased

2014

Scala 2.11released

2016

Scala 2.12(currently RC2)

Scala CentreFoundation

created!

Page 14: Scala Past, Present & Future

Scala 2.9 to 2.11

• Releases are mainly about stability.

• Only new features:

• Value classes

• Implicit classes

• String interpolation

• macros (experimental)

Page 15: Scala Past, Present & Future
Page 16: Scala Past, Present & Future

Scala 2.12

• No additions to the language.

• So… ?

Page 17: Scala Past, Present & Future
Page 18: Scala Past, Present & Future

Scala 2.12• Scala 2.12 requires Java8.

• trait compiled to Java8 interface.

• Binary compat & reduced bytecode!

• scalac λ bytecode mimics javac’s.

• scala.FunctionN compiles to SAM type (Java8 λ).

• New backend & optimiser11. https://dl.dropboxusercontent.com/u/4881107/website/scala-user-group-2016.pdf

Page 19: Scala Past, Present & Future

New trait encoding

trait PriceAlgorithm[Item] { def apply(item: Item): Double = ??? }

Let’s compare Scala 2.11 vs 2.12 bytecode

Page 20: Scala Past, Present & Future

trait PriceAlgorithm[Item] { def apply(item: Item): Double = ??? }

Compiled with Scala 2.11

interface PriceAlgorithm<Item> { abstract double apply(Item); }

abstract class PriceAlgorithm$class { static double apply(PriceAlgorithm, java.lang.Object);

static void $init$(PriceAlgorithm); }

Two classfiles

Page 21: Scala Past, Present & Future

trait PriceAlgorithm[Item] { def apply(item: Item): Double = ??? }

Compiled with Scala 2.12

interface PriceAlgorithm<Item> { public double apply(Item);

static double apply$(PriceAlgorithm, java.lang.Object);

static void $init$(PriceAlgorithm); }

Only one classfile!

Page 22: Scala Past, Present & Future

Java8 API from Scala

Scala λ assignable to Java 8 λ

scala> import java.util.stream.{Stream, IntStream} scala> import java.util.{Arrays, List}

scala> val myList = Arrays.asList("a1", "a2", "b1", "c2", "c1") myList: java.util.List[String] = [a1, a2, b1, c2, c1]

scala> myList.stream. filter(_.startsWith("c")). map(_.toUpperCase). sorted. forEach(println) C1 C2

Page 23: Scala Past, Present & Future

Why an optimiser?

• Some well-known patterns are not optimised by HotSpot (Oracle JIT).

• Transform the code to please HotSpot.

• Inlining vs binary resilience.

• Optimiser is not a magic wand, but rather a tool for experts.

• Compile with the -optimise flag.

Page 24: Scala Past, Present & Future
Page 25: Scala Past, Present & Future
Page 26: Scala Past, Present & Future

Scala future

2016

Scala 2.12 Scala 2.13 (Aida)Improve the

library!Smaller core & stabilise

Q1 2018

(Don Giovanni)Faster compilerImprove binary

compatibility (TASTY)

2020?

Page 27: Scala Past, Present & Future

Dotty?

• Dotty is the new Scala compiler Martin is working on with his group at EPFL.

• It’s research work, but a first release should be available soon.

• https://github.com/lampepfl/dotty

• Goal is to simplify the language.

Page 28: Scala Past, Present & Future

The future of Scala

on a A4 paper

Credit goes to @malweene

https://twitter.com/malweene/status/743117270948274176

Page 29: Scala Past, Present & Future

Questions?

@mircodotta