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

Scala Roadmap (as of April 2012)

boia01
June 12, 2012

Scala Roadmap (as of April 2012)

A Bizo-internal presentation made on the state of Scala and a completely unofficial roadmap (as of April 2012) which was more a brain-dump of everything I had noted was happening in Scala-land at the time.

boia01

June 12, 2012
Tweet

More Decks by boia01

Other Decks in Programming

Transcript

  1. * Scala Improvement Process (SIPs) * Scala 2.10 (shiny!) *

    Things pushed to Scala 2.11 * Scala 3.0 and beyond
  2. Process * Send your idea(s) and discuss on scala-debate@ mailing

    list. * If it's popular enough, write a SIP document + send pull request * SIP committee may accept SIP and attribute it a number. * Implement it! * At major Scala release, committed will accept / delay / reject
  3. And pattern-matching friendly, too. fragment match { case xml””” <body>

    <a href = “some link”> $linktext </a> </body> “”” => … // linktext is bound }
  4. implicit class RichInt(n: Int) extends Ordered[Int] { def min(m: Int):

    Int = if (n <= m) n else m ... } /* desugars to ... */ class RichInt(n: Int) extends Ordered[Int] { def min(m: Int): Int = if (n <= m) n else m ... } implicit final def RichInt(n: Int): RichInt = new RichInt(n)
  5. Value classes get completely inlined (zero overhead compared to external

    methods) * Inlined implicit wrappers (extension methods) * New numeric classes (e.g. unsigned ints) * Units of measure (ahem!)
  6. Restrictions * Exactly one parameter (treated as val) * No

    members * No initialization statements * No equals() or hashCode() * Top-level or statically reachable
  7. Self-cleaning Macros (SIP-16) “Unicorns! LOLCats! Rainbows! Bacon! Jet Packs! Fried

    dough with sugar on top! Possibly the greatest step in computing in the past decade.” – Self-delusional @boia01
  8. * Actually in 'Postponed' SIP status * Experimental implementation available

    in 2.10. * Macros are actually 3 things, + Code reification + Reflection (via mirrors) + Compile-time AST transformation (CATs)
  9. val foo: Dynamic = … // 4 types of dynamic

    invocations foo.method[Ts](args...) // foo.applyDynamic[Ts](“method”)(args...) foo.method[Ts](name = expr, …) // foo.applyDynamicNamed[Ts](“method”)(name expr, …) → foo.method = expr // foo.updateDynamic(“method”)(expr) foo.method // foo.selectDynamic(“method”)
  10. Modularizing Language Features (SIP-18) “The curse of a very powerful

    and regular language is that it provides no barriers against over-abstraction.” – Martin Odersky
  11. “The big problem with this proposal is that it threatens

    to add a bunch of boilerplate to every single existing Scala file, program and REPL session.” – Rex Kerr
  12. * Scheme where some of the more advanced and contentious

    language features have to be enabled explicitly; * Typically using an import from a new language enumeration object. * Depending on feature, may be required at the definition site or usage site.
  13. object languageFeature { trait dynamics trait postfixOps trait reflectiveCalls trait

    implicitConversions trait higherKinds trait existentials object experimental { trait macros } }
  14. Also possible to enable language features in all compiled files

    by specifying command line options: scalac -language:implicitConversions -language:higherKinds Or wholesale, scalac -language:_
  15. Possible future uses: * language.future to control features to be

    introduced in future releases * language.deprecated to control features no longer officially supported * language.plugin to control plugin activation
  16. Future and Promises (SIP-14) “[...] redesign of scala.concurrent into a

    unified substrate for a variety of parallel frameworks.”
  17. * No more ScalaObject trait * Floating point and octal

    literal syntax deprecated * Type arguments don't need a dot anymore (e.g. foo asInstanceOf[Int]) * Optimized for loops (Range#foreach) * Runtime compiler toolbox
  18. * Separated scala actors from the main library jar *

    Scala actors deprecated (replaced by Akka actors after 2.10) * scala.dbc package removed. * Added ??? and NotImplementedError e.g. def fib = ??? * Reduced size of PartialFunctions
  19. * Added collection.mutable.TreeSet * Added collection.concurrent.TrieMap (scalable, thread-safe & lock-free)

    * Updated Fork-Join implementation * Miscelaneous collection performance improvements * DelayedInit trait deprecated
  20. * View bounds deprecated (subsumed by implicit params and context

    bounds) e.g. def f[A <% B](a: A) = a.bMethod * Virtual pattern matcher (virtpatmat)
  21. Examples if x < y then x else y while

    x >= y do x /= 2 for x <- 1 to 10; y <- 1 to 10 do println(x * y) for x <- 0 until N y <- 0 until N if isPrime(x + y) yield (x, y)
  22. Scala has a simple and consistent core ... but ...

    some more specialized features are not yet as unified with the rest as they could be.
  23. Remove XML literals (duh!) New string interpolation scheme allows putting

    everything in libraries. Bonus: Swappable implementations
  24. Simplify Type System (re-duh!) “Ideally, Scala's types will be built

    from just traits, mixin composition, refinements, and paths, and nothing else.” – Martin Odersky (talking about dependent-object type formalism)
  25. But ... need classes for Java compatibility. Scala needs to

    remain a practical programming language, compatible with what Scala currently is.
  26. The idea is to treat the following two types as

    equivalent trait Seq[type Elem] and trait Seq { type Elem }
  27. The definition trait Seq[Elem] could still be kept and be

    interpreted as a type that has an inaccessible member Elem, similar to the distinction between class C(x: T) and class C(val x: T)
  28. The big simplifications are then: (1) Any type can be

    written without its parameters. (2) Any type that has abstract type members can be retroactively parameterized. (3) Type parameters can be unified by name.
  29. Gains - eliminate two classes of types - more expressive

    power through unification of concepts - avoid unnecessary repetition of parameters in mixin compositions and extends clauses - strengthen the analogies between type parameters and value parameters.
  30. “Scala 3 does not have an arrival date. It's not

    even sure that it will ever arrive.” – Martin Odersky
  31. THE END. “You’ll learn more about a road by traveling

    it than be consulting all the maps in the world.”