Statically typed • Lightweight syntax (via type inference) • Compilation targets: JVM, JavaScript • Fully interoperable with Java and JavaScript (no glue code) • As fast as Java • Open source development backed by: EPFL, Lightbend Inc., and Scala Center (non-profit) 3
Statically typed • Lightweight syntax (via type inference) • Compilation targets: JVM, JavaScript • Fully interoperable with Java and JavaScript (no glue code) • As fast as Java • Open source development backed by: EPFL, Lightbend Inc., and Scala Center (non-profit) 3 Advisory board members include Goldman Sachs, IBM, SAP, and Verizon
.. val futImgDataOut1 = applyFilter(imgData, filter1) val futImgDataOut2 = futImgDataOut1.flatMap { imgDataOut1 => applyFilter(imgDataOut1, filter2) } futImgDataOut2.foreach { imgDataOut2 => // .. } How to process many images efficiently?
Actor { def receive = { case Process(imgData) => val imgDataOut = filter.applyTo(imgData) next ! Process(imgDataOut) case Stop() => context.stop(self) } }
Actor { def receive = { case Process(imgData) => val imgDataOut = filter.applyTo(imgData) next ! Process(imgDataOut) case Stop() => context.stop(self) } } Pattern matching
Actor { def receive = { case Process(imgData) => val imgDataOut = filter.applyTo(imgData) next ! Process(imgDataOut) case Stop() => context.stop(self) } } Pattern matching Case class
Actor { def receive = { case Process(imgData) => val imgDataOut = filter.applyTo(imgData) next ! Process(imgDataOut) case Stop() => context.stop(self) } } Pattern matching Infix call of “!” method Case class
• cf. Guy Steele. Growing a Language. OOPSLA ’98 keynote • Concurrent programming models as libraries • Based on shared-memory threads built into underlying virtual machine • Flexible extension and adaptation • Reuse of compilers, debuggers, and IDEs 17
• cf. Guy Steele. Growing a Language. OOPSLA ’98 keynote • Concurrent programming models as libraries • Based on shared-memory threads built into underlying virtual machine • Flexible extension and adaptation • Reuse of compilers, debuggers, and IDEs 17 Do not have to guess the answer to the question: Which concurrency model is going to “win”?
Scala Joins (2008) • Scala futures (2012) • FlowPools (2012) • Scala Async (2013) • Contributions to Akka, Akka.js projects at Typesafe 18 Haller and Sommers Artima Press, 2012 Production use at Twitter, The Guardian and others
Scala Joins (2008) • Scala futures (2012) • FlowPools (2012) • Scala Async (2013) • Contributions to Akka, Akka.js projects at Typesafe 18 Haller and Sommers Artima Press, 2012 Production use at Twitter, The Guardian and others Production use at LinkedIn, The Huffington Post and others
Scala Joins (2008) • Scala futures (2012) • FlowPools (2012) • Scala Async (2013) • Contributions to Akka, Akka.js projects at Typesafe 18 Haller and Sommers Artima Press, 2012 Production use at Twitter, The Guardian and others Production use at Morgan Stanley, Gawker and others Production use at LinkedIn, The Huffington Post and others
Scala Joins (2008) • Scala futures (2012) • FlowPools (2012) • Scala Async (2013) • Contributions to Akka, Akka.js projects at Typesafe 18 Haller and Sommers Artima Press, 2012 Production use at Twitter, The Guardian and others Production use at Morgan Stanley, Gawker and others Production use at LinkedIn, The Huffington Post and others The programming-models-as-libraries approach has been successful in Scala!
1 sends a reference to a buffer to stage 2 2. Following the send, both stages have a reference to the same buffer 3. Stages can concurrently access the buffer 22
Sending stage loses ownership • Type system prevents sender from accessing transferred objects • Advantages: • No run-time overhead • Errors caught at compile time 23
safety statically via lightweight types • Sound integration with full Scala language • Minimize effort to reuse existing code: binary conformance check (yes/no) 28
safety statically via lightweight types • Sound integration with full Scala language • Minimize effort to reuse existing code: binary conformance check (yes/no) • Recent paper: Haller and Loiko. LaCasa: Lightweight Affinity and Object Capabilities in Scala. OOPSLA 2016 28
safety statically via lightweight types • Sound integration with full Scala language • Minimize effort to reuse existing code: binary conformance check (yes/no) • Recent paper: Haller and Loiko. LaCasa: Lightweight Affinity and Object Capabilities in Scala. OOPSLA 2016 • Ongoing: Empirical study on open source code corpus 28
safety statically via lightweight types • Sound integration with full Scala language • Minimize effort to reuse existing code: binary conformance check (yes/no) • Recent paper: Haller and Loiko. LaCasa: Lightweight Affinity and Object Capabilities in Scala. OOPSLA 2016 • Ongoing: Empirical study on open source code corpus 28 Open source implementation: https://github.com/phaller/lacasa
enables library extensions providing new concurrent programming models • Building on concurrency support of underlying runtime platform • Scalability and performance enable wide use in large- scale production systems 29
enables library extensions providing new concurrent programming models • Building on concurrency support of underlying runtime platform • Scalability and performance enable wide use in large- scale production systems • Lightweight type system extensions are being developed to ensure concurrency safety 29
enables library extensions providing new concurrent programming models • Building on concurrency support of underlying runtime platform • Scalability and performance enable wide use in large- scale production systems • Lightweight type system extensions are being developed to ensure concurrency safety 29 Thank you!