Scala Next SF Scala meetup Dec 8 th, 2011. 2 Scala Today

  • View

  • Download

Embed Size (px)

Text of Scala Next SF Scala meetup Dec 8 th, 2011. 2 Scala Today

  • Slide 1

Scala Next SF Scala meetup Dec 8 th, 2011 Slide 2 2 Scala Today Slide 3 3 Some adoption vectors: Web platforms Trading platforms Financial modeling Simulation Fast to first product, scalable afterwards Slide 4 Github vs. Stack Overflow RedMonk: Revisiting the Dataists Programming Language Rankings 4 Typesafe Confidential Slide 5 Commercial Adoption Scala jobs tripled in last year Now at estimated 100,000 developers 5 Typesafe Confidential Slide 6 6 Scala 2.8: (Only 17 months ago!) New collections Package objects Context bounds Better implicits... Slide 7 7 Scala 2.9: Parallel collections DelayedInit and App Faster REPL Progress on IDEs: Eclipse, IntelliJ, Neatbeans, ENSIME Better docs Lots of bug fixes Slide 8 Parallel Collections Use Java 7 Fork Join framework Split work by number of Processors Each Thread has a work queue that is split exponentially. Largest on end of queue Granularity balance against scheduling overhead On completion threads work steals from end of other thread queues 8 Slide 9 9... and its usage import java.util.ArrayList;... Person[] people; Person[] minors; Person[] adults; { ArrayList minorsList = new ArrayList (); ArrayList adultsList = new ArrayList (); for (int i = 0; i < people.length; i++) (people[i].age < 18 ? minorsList : adultsList).add(people[i]); minors = minorsList.toArray(people); adults = adultsList.toArray(people); }... in Java:... in Scala: val people: Array[Person] val (minors, adults) = people partition (_.age < 18) A simple pattern match An infix method call A function value Slide 10 10 Going Parallel ?... in Java:... in Scala: val people: Array[Person] val (minors, adults) = people.par partition (_.age < 18) Slide 11 General Collection Hierarchy GenTraversable GenIterable GenSeq Traversable Iterable Seq ParIterable ParSeq 11 Remove this layer in 2.10? Slide 12 Going Distributed Can we get the power of parallel collections to work on 10000s of computers? Hot technologies: MapReduce (Googles and Hadoop) But not everything is easy to fit into that mold Sometimes 100s of map-reduce steps are needed. Distributed collections retain most operations, provide a powerful frontend for MapReduce computations. Scalas uniform collection model is designed to also accommodate parallel and distributed. Projects at Google (Cascade), Berkeley (Spark), EPFL. 12 Slide 13 13 Scala next: Eclipse IDE Play web framework 2.0 Akka 2.0 Scala 2.10 Slide 14 14 Scala Eclipse IDE Now in RC2 Final expected before the end of the year. Slide 15 Goals reliable (no crashes/lock ups) responsive (never wait when typing) work with large projects/files Scala compiler (80k LOC), 4-5000 LOC/file advanced use of the type system: path-dependent types, self-types, mix-ins Slide 16 Features Keep it simple highlight errors as you type completions (including implicits) hyperlinking project builder (+ dependent projects) Support mixed Java-Scala projects all features should work between Java/Scala sources JUnit Test Runner should pick up tests More stuff based on external libraries (some) refactoring, code formatter, mark occurrences, structured selections, show inferred semi-colons Slide 17 Features (3) based on external libraries (some) refactoring code formatter mark occurrences structured selections show inferred semi-colons Slide 18 @jonifreeman Joni Freeman Latest Scala Eclipse plugin works surprisingly well! Even manages our mixed Java/Scala project. Kudos to the team! #scala @esorribas Eduardo Sorribas The latest beta of the Scala IDE for eclipse is much better. I'm starting to like it. @jannehietamaki Janne Hietamki After years of misery, the Eclipse Scala plugin actually seems to work quite well. Slide 19 Architecture Use the full-blown Scala compiler for: interactive error highlight, completion, hyperlinking turning Scala symbols into Java model elements Weave the JDT compiler when it needs help JDT was NOT meant to be extended Slide 20 Why rely on scalac? reuse (type-checker == 1-2 person years) consistency compiler plugins Why not? SPEED (very) tight dependency on the Scala version Slide 21 Presentation Compiler asynchronous interruptible targeted stop after type-checking Slide 22 Slide 23 Slide 24 Result is communicated through a SyncVar Slide 25 All compiler activity happens on PC thread compile loaded files when work queue is empty (in the background) Check work queue when type checker reaches safe-points in the AST Drop everything when a file is changed (AskReload) Slide 26 26 Implementation Slide 27 1 type-checker run / instance --> 100s of type-check runs / minute memory leaks side-effects/state out-of-order and targeted type-checking needed to improve the compiler 2.9.x, 2.10 (trunk) what about 2.8? 2.8.2, 2.8.3-SNAPSHOT Slide 28 New: Play Framework 2.0 Play Framework is an open source web application framework, inspired by Ruby on Rails, for Java and Scala Play Framework 2.0 retains full Java support while moving to a Scala core and builds on key pieces of the Typesafe Stack, including Akka middleware and SBT Play will be integrated in TypeSafe stack 2.0 Typesafe will contribute to development and provide commercial support and maintenance. Slide 29 Roadmap Typesafe Stack 1.0 Typesafe Stack 1.1 Typesafe Stack 2.0 Typesafe Stack 2.x May 2011Oct 2011Q1 2012Q3 2012 Scala 2.9.0 Akka 1.1 Scala 2.9.1 Akka 1.2 Scala 2.9.x Akka 2.0 Play 2.0 Scala 2.10 Akka 2.x Play 2.x Slick (DB) Slide 30 30 Scala 2.10: 1.New reflection framework 2.Reification 3.type Dynamic 4.More IDE improvements: find- references, debugger, worksheet. 5.Faster builds 6.SIPs: string interpolation, simpler implicits. ETA: Early 2012. Slide 31 New in Scala 2.10: Dynamic Type Dynamic bridges the gap between static and dynamic typing. Method calls get translated to applyDynamic Great for interfacing with dynamic languages (e.g. JavaScript) 31 class JS extends Dynamic { def applyDynamic(methName: String, args: Any*): Any = { println("apply dynamic "+methName+args.mkString("(", ",", ")")) } val x = new JS // x.applyDynamic(foo, 1) // x.applyDynamic(bar) Slide 32 Proposed for Scala 2.10: SIP 11: String interpolation Idea: Instead of Bob is + n + years old write: sBob is $n years old which gets translated to new StringContext(Bob is, years old).s(n) Here, s is a library-defined method for string interpolation. 32 Slide 33 This can be generalized to other string processors besides s : xml ${linktext} scala scala.concurrent.transaction.withinTransaction { (implicit currentTransaction: Transaction) => $expr } 33 Slide 34 Proposed for Scala 2.10: SIP 12: Uncluttering control Should be able to write: if x < 0 then x else x while x > 0 do { println(x); x -= 1 } for x