SlideShare a Scribd company logo
Caprese
AdG project presentation
Martin Odersky
EPFL
Capabilities for Resources and Effects
Two areas where static typing has lagged behind
• Resources
• Effects
100’s of papers over 40 years, no large scale adoption yet.
Capabilities for Resources and Effects
Two areas where static typing has lagged behind
• Resources
• Effects
100’s of papers over 40 years, no large scale adoption yet.
Core Insights
• Resources and effects can be expressed as capabilities.
• Retained capabilities should be be tracked in types.
Resources
Values that are available only with
certain restrictions, such as
• lifetime
• sharing
• quantity
Examples
• regions of memory
• file handles
• channels
• database and network connections
...
Aspects of the computation beyond
shapes of inputs and outputs that we
want to track in types.
Examples
• updating variables
• throwing exceptions
• I/O
• suspending a computation
...
Effects
Resources and Effects in Programming
abstraction
compile-time tracking
?
20+M investment
Mozillla, ERC, …
?
Resources and Effects in Programming
abstraction
compile-time tracking
Linear Haskell
Singularity
Mezzo
Alias types
Algebraic effects
20+M investment
Mozillla, ERC, …
?
Resources and Effects in Programming
abstraction
compile-time tracking
Caprese
20+M investment
Mozillla, ERC, …
?
The Effect Polymorphism Problem
Unlike other types, effects are transitive:
The effects of f1 include the effects of the functions it calls, transitively.
How to describe the effects of f1 the call graph is dynamic?
 Effect polymorphism problem
I/O
f1 f2 … fn throw Exc
x := y
await f()
Capabilities to the Rescue
Effects can be modeled with capabilities
For instance, the following are equivalent:
def f(): T throws E
def f()(using CanThrow[E]): T
Effect
Capability
Capabilities Solve Effect Polymorphism
For instance, consider map on List[A]:
def map[B](f: A => B): List[B]
Capabilities Solve Effect Polymorphism
For instance, consider map on List[A]:
def map[B](f: A => B): List[B]
With traditional effect systems:
def map[B, E](f: A -> B eff E): List[B] eff E
Capabilities Solve Effect Polymorphism
For instance, consider map on List[A]:
def map[B](f: A => B): List[B]
With traditional effect systems:
def map[B, E](f: A -> B eff E): List[B] eff E
With capabilities:
def map[B](f: A => B): List[B]
Here A => B is the type of impure functions that can capture
any capability as a free variable. Compare with A -> B for pure functions.
Capabilities are Resources
A CanThrow[E] capability is generated by a try that catches E.
Example
class TooLarge extends Exception
def f(x: Int): Int throws TooLarge =
if x < limit then x * x else throw TooLarge()
val xs: List[Int] = …
try xs.map(f) // generates ct: CanThrow[TooLarge]
catch case ex: TooLarge => Nil
The capability has limited lifetime: When the try exits, the capability can no
longer be used.
Capabilities are Resources
A CanThrow[E] capability is generated by a try that catches E.
Example
class TooLarge extends Exception
def f(x: Int)(using CanThrow[TooLarge]): Int
if x < limit then x * x else throw TooLarge()
val xs: List[Int] = …
try xs.map(f(_)(using CanThrow[TooLarge]))
catch case ex: TooLarge => Nil
The capability has limited lifetime: When the try exits, the capability can no
longer be used.
Scoped Capabilities
The following program still throws an unhandled exception:
val it =
try xs.iterator.map(f)
catch case TooLarge => Iterator.empty
it.next()
To rule out this program statically, we need ways to enforce resource
restrictions in the type system.
Core idea: Track in a type which capabilities can be captured
by its instances.
Capabilities and Capturing Types
Definition: A capturing type {c1,...,cn}T consists of a type T and a capture set of
capabilities {c1,...,cn}that tracks references retained by values of type T.
Definition: A capability is a reference of a capturing type with a non-empty
capture set.
• Every capability gets its authority from some other, more sweeping
capability which it captures.
• There is a root capability from which ultimately all others are derived.
Type-systematic description of the object-capability model.
Details in: Odersky, Boruch Gruszecki, Lee, Brachthäuser, Lhotak: Scoped
Capabilities for Polymorphic Effects, Arxiv 2207.03402
Capture Calculus:
A formalization of a
minimal core language
with statically tracked
capabilities
Point of Departure
Capture Calculus:
A formalization of a
minimal core language
with statically tracked
capabilities
Capture checker
prototype for a slightly
larger language subset
Point of Departure
Capture Calculus:
A formalization of a
minimal core language
with statically tracked
capabilities
Capture checker
prototype for a slightly
larger language subset
Point of Departure
Very promising in
the small, but can
we scale it up?
Project Structure
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
Project Structure Challenges: Core
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
• Can we extend the theory to
more language constructs that
are important in practice?
• Can we extend the theory to
resource restrictions other
than lifetime?
• Can we find sound and
effective inference algorithms?
Project Structure Challenges: Extensions
• Is capture checking expressive
enough to model a large range
of effect and resource usage
patterns?
• Can static checking help in
designing efficient and safe
memory systems and
concurrent runtimes?
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
Project Structure Challenges: Infrastructure
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
• Are capture annotations
lightweight enough to be used
widely in practice?
• Can capture checking be made
efficient enough to be always
on?
• Can error diagnostics be made
clear enough to be intelligible
for non-experts?
• How to migrate and
interoperate with existing
code?
Project Structure Challenges: Applications
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
Can we validate the applicability
of the research in selected
application domains?
Language-based security
Project Structure Challenges: Applications
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
Can we validate the applicability
of the research in selected
application domains?
Efficient computing
Project Structure Challenges: Applications
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
Can we validate the applicability
of the research in selected
application domains?
Distributed systems
Project Structure Challenges: Applications
Caprese
Core
• Foundations
• Capture checking
Infrastructure
• Language integration
• Libraries
Applications
• Formal methods
• Efficient computing
• Distributed
• Security
Extensions
• Effect Domains
• Memory Safety
• Concurrency
Can we validate the applicability
of the research in selected
application domains?
Formal methods
Why Us?
To succeed, the project needs
• strong theoretical foundations,
• solid language implementation and tooling,
• a large educated user base for empirical evaluations.
Scala is unique in that it combines all three aspects.
Outlook
If successful, this work will solve several long-standing problems in programming:
• Effect polymorphism - getting flexibility without the overhead
• Mixing synchronous and asynchronous code
• Combining manual allocation and automatic GC
• Fearless concurrency, excluding data races and other hazards
It will lead to exciting new ways to model functional and imperative programming
as two ends of a spectrum.
It will be the key to combining without compromises
productivity, safety and performance.

More Related Content

What's hot

Scala Intro
Scala IntroScala Intro
ZIO Queue
ZIO QueueZIO Queue
ZIO Queue
John De Goes
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
7mind
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1
Philip Schwarz
 
Boost your productivity with Scala tooling!
Boost your productivity  with Scala tooling!Boost your productivity  with Scala tooling!
Boost your productivity with Scala tooling!
MeriamLachkar1
 
Domain Modeling in a Functional World
Domain Modeling in a Functional WorldDomain Modeling in a Functional World
Domain Modeling in a Functional World
Debasish Ghosh
 
Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorld
Jorge Vásquez
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
Philip Schwarz
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Jorge Vásquez
 
Taking your side effects aside
Taking your side effects asideTaking your side effects aside
Taking your side effects aside
💡 Tomasz Kogut
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
Jorge Vásquez
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
José Paumard
 
Algebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsAlgebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain Models
Debasish Ghosh
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
Martin Odersky
 
07 java collection
07 java collection07 java collection
07 java collection
Abhishek Khune
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query Language
Julian Hyde
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Philip Schwarz
 
Applicative style programming
Applicative style programmingApplicative style programming
Applicative style programming
José Luis García Hernández
 

What's hot (20)

Scala Intro
Scala IntroScala Intro
Scala Intro
 
ZIO Queue
ZIO QueueZIO Queue
ZIO Queue
 
Izumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala StackIzumi 1.0: Your Next Scala Stack
Izumi 1.0: Your Next Scala Stack
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1
 
Boost your productivity with Scala tooling!
Boost your productivity  with Scala tooling!Boost your productivity  with Scala tooling!
Boost your productivity with Scala tooling!
 
Domain Modeling in a Functional World
Domain Modeling in a Functional WorldDomain Modeling in a Functional World
Domain Modeling in a Functional World
 
Functional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorldFunctional Programming 101 with Scala and ZIO @FunctionalWorld
Functional Programming 101 with Scala and ZIO @FunctionalWorld
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in Scala
 
Taking your side effects aside
Taking your side effects asideTaking your side effects aside
Taking your side effects aside
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
 
Algebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain ModelsAlgebraic Thinking for Evolution of Pure Functional Domain Models
Algebraic Thinking for Evolution of Pure Functional Domain Models
 
Spring boot
Spring bootSpring boot
Spring boot
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
07 java collection
07 java collection07 java collection
07 java collection
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query Language
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 1
 
Applicative style programming
Applicative style programmingApplicative style programming
Applicative style programming
 

Similar to Capabilities for Resources and Effects

Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKenna
openseesdays
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
InfinIT - Innovationsnetværket for it
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in Scala
Roberto Casadei
 
Software variability management - 2017
Software variability management - 2017Software variability management - 2017
Software variability management - 2017
XavierDevroey
 
Parsl: Pervasive Parallel Programming in Python
Parsl: Pervasive Parallel Programming in PythonParsl: Pervasive Parallel Programming in Python
Parsl: Pervasive Parallel Programming in Python
Daniel S. Katz
 
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a serviceCOMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
Antonio García-Domínguez
 
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習 Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
Herman Wu
 
Software variability management - 2019
Software variability management - 2019Software variability management - 2019
Software variability management - 2019
XavierDevroey
 
Exploring Elixir Codebases with Archeometer
Exploring Elixir Codebases with ArcheometerExploring Elixir Codebases with Archeometer
Exploring Elixir Codebases with Archeometer
Agustin Ramos
 
"Data Provenance: Principles and Why it matters for BioMedical Applications"
"Data Provenance: Principles and Why it matters for BioMedical Applications""Data Provenance: Principles and Why it matters for BioMedical Applications"
"Data Provenance: Principles and Why it matters for BioMedical Applications"
Pinar Alper
 
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
Jose Quesada (hiring)
 
Source-to-source transformations: Supporting tools and infrastructure
Source-to-source transformations: Supporting tools and infrastructureSource-to-source transformations: Supporting tools and infrastructure
Source-to-source transformations: Supporting tools and infrastructure
kaveirious
 
Generative Software Development. Overview and Examples
Generative Software Development. Overview and ExamplesGenerative Software Development. Overview and Examples
Generative Software Development. Overview and Examples
Eelco Visser
 
Software Abstractions for Parallel Hardware
Software Abstractions for Parallel HardwareSoftware Abstractions for Parallel Hardware
Software Abstractions for Parallel Hardware
Joel Falcou
 
Scalable and Cost-Effective Model-Based Software Verification and Testing
Scalable and Cost-Effective Model-Based Software Verification and TestingScalable and Cost-Effective Model-Based Software Verification and Testing
Scalable and Cost-Effective Model-Based Software Verification and Testing
Lionel Briand
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
InfinIT - Innovationsnetværket for it
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
Joel Falcou
 
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Manuel Bernhardt
 
From Pipelines to Refineries: Scaling Big Data Applications
From Pipelines to Refineries: Scaling Big Data ApplicationsFrom Pipelines to Refineries: Scaling Big Data Applications
From Pipelines to Refineries: Scaling Big Data Applications
Databricks
 
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data PlatformsCassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
DataStax Academy
 

Similar to Capabilities for Resources and Effects (20)

Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKenna
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
 
Aggregate Programming in Scala
Aggregate Programming in ScalaAggregate Programming in Scala
Aggregate Programming in Scala
 
Software variability management - 2017
Software variability management - 2017Software variability management - 2017
Software variability management - 2017
 
Parsl: Pervasive Parallel Programming in Python
Parsl: Pervasive Parallel Programming in PythonParsl: Pervasive Parallel Programming in Python
Parsl: Pervasive Parallel Programming in Python
 
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a serviceCOMMitMDE'18: Eclipse Hawk: model repository querying as a service
COMMitMDE'18: Eclipse Hawk: model repository querying as a service
 
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習 Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
Azure 機器學習 - 使用Python, R, Spark, CNTK 深度學習
 
Software variability management - 2019
Software variability management - 2019Software variability management - 2019
Software variability management - 2019
 
Exploring Elixir Codebases with Archeometer
Exploring Elixir Codebases with ArcheometerExploring Elixir Codebases with Archeometer
Exploring Elixir Codebases with Archeometer
 
"Data Provenance: Principles and Why it matters for BioMedical Applications"
"Data Provenance: Principles and Why it matters for BioMedical Applications""Data Provenance: Principles and Why it matters for BioMedical Applications"
"Data Provenance: Principles and Why it matters for BioMedical Applications"
 
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
 
Source-to-source transformations: Supporting tools and infrastructure
Source-to-source transformations: Supporting tools and infrastructureSource-to-source transformations: Supporting tools and infrastructure
Source-to-source transformations: Supporting tools and infrastructure
 
Generative Software Development. Overview and Examples
Generative Software Development. Overview and ExamplesGenerative Software Development. Overview and Examples
Generative Software Development. Overview and Examples
 
Software Abstractions for Parallel Hardware
Software Abstractions for Parallel HardwareSoftware Abstractions for Parallel Hardware
Software Abstractions for Parallel Hardware
 
Scalable and Cost-Effective Model-Based Software Verification and Testing
Scalable and Cost-Effective Model-Based Software Verification and TestingScalable and Cost-Effective Model-Based Software Verification and Testing
Scalable and Cost-Effective Model-Based Software Verification and Testing
 
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...Trends in Programming Technology you might want to keep an eye on af Bent Tho...
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
 
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
 
From Pipelines to Refineries: Scaling Big Data Applications
From Pipelines to Refineries: Scaling Big Data ApplicationsFrom Pipelines to Refineries: Scaling Big Data Applications
From Pipelines to Refineries: Scaling Big Data Applications
 
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data PlatformsCassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
 

More from Martin Odersky

Simplicitly
SimplicitlySimplicitly
Simplicitly
Martin Odersky
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
Martin Odersky
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
Martin Odersky
 
From DOT to Dotty
From DOT to DottyFrom DOT to Dotty
From DOT to Dotty
Martin Odersky
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in Dotty
Martin Odersky
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
Martin Odersky
 
Compilers Are Databases
Compilers Are DatabasesCompilers Are Databases
Compilers Are Databases
Martin Odersky
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
Martin Odersky
 
Scalax
ScalaxScalax
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
Martin Odersky
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slidesMartin Odersky
 
Devoxx
DevoxxDevoxx
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
Martin Odersky
 
Scala eXchange opening
Scala eXchange openingScala eXchange opening
Scala eXchange opening
Martin Odersky
 

More from Martin Odersky (15)

Simplicitly
SimplicitlySimplicitly
Simplicitly
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
 
From DOT to Dotty
From DOT to DottyFrom DOT to Dotty
From DOT to Dotty
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in Dotty
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
Compilers Are Databases
Compilers Are DatabasesCompilers Are Databases
Compilers Are Databases
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
 
Scalax
ScalaxScalax
Scalax
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Flatmap
FlatmapFlatmap
Flatmap
 
flatMap Oslo presentation slides
flatMap Oslo presentation slidesflatMap Oslo presentation slides
flatMap Oslo presentation slides
 
Devoxx
DevoxxDevoxx
Devoxx
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
 
Scala eXchange opening
Scala eXchange openingScala eXchange opening
Scala eXchange opening
 

Recently uploaded

ESR_factors_affect-clinic significance-Pathysiology.pptx
ESR_factors_affect-clinic significance-Pathysiology.pptxESR_factors_affect-clinic significance-Pathysiology.pptx
ESR_factors_affect-clinic significance-Pathysiology.pptx
muralinath2
 
Penicillin...........................pptx
Penicillin...........................pptxPenicillin...........................pptx
Penicillin...........................pptx
Cherry
 
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCINGRNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
AADYARAJPANDEY1
 
erythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptxerythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptx
muralinath2
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
ossaicprecious19
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
DiyaBiswas10
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
Scintica Instrumentation
 
Hemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptxHemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptx
muralinath2
 
In silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptxIn silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptx
AlaminAfendy1
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
muralinath2
 
insect taxonomy importance systematics and classification
insect taxonomy importance systematics and classificationinsect taxonomy importance systematics and classification
insect taxonomy importance systematics and classification
anitaento25
 
NuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final versionNuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final version
pablovgd
 
Large scale production of streptomycin.pptx
Large scale production of streptomycin.pptxLarge scale production of streptomycin.pptx
Large scale production of streptomycin.pptx
Cherry
 
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
muralinath2
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
YOGESH DOGRA
 
Richard's entangled aventures in wonderland
Richard's entangled aventures in wonderlandRichard's entangled aventures in wonderland
Richard's entangled aventures in wonderland
Richard Gill
 
platelets- lifespan -Clot retraction-disorders.pptx
platelets- lifespan -Clot retraction-disorders.pptxplatelets- lifespan -Clot retraction-disorders.pptx
platelets- lifespan -Clot retraction-disorders.pptx
muralinath2
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
silvermistyshot
 
Structures and textures of metamorphic rocks
Structures and textures of metamorphic rocksStructures and textures of metamorphic rocks
Structures and textures of metamorphic rocks
kumarmathi863
 
The ASGCT Annual Meeting was packed with exciting progress in the field advan...
The ASGCT Annual Meeting was packed with exciting progress in the field advan...The ASGCT Annual Meeting was packed with exciting progress in the field advan...
The ASGCT Annual Meeting was packed with exciting progress in the field advan...
Health Advances
 

Recently uploaded (20)

ESR_factors_affect-clinic significance-Pathysiology.pptx
ESR_factors_affect-clinic significance-Pathysiology.pptxESR_factors_affect-clinic significance-Pathysiology.pptx
ESR_factors_affect-clinic significance-Pathysiology.pptx
 
Penicillin...........................pptx
Penicillin...........................pptxPenicillin...........................pptx
Penicillin...........................pptx
 
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCINGRNA INTERFERENCE: UNRAVELING GENETIC SILENCING
RNA INTERFERENCE: UNRAVELING GENETIC SILENCING
 
erythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptxerythropoiesis-I_mechanism& clinical significance.pptx
erythropoiesis-I_mechanism& clinical significance.pptx
 
Lab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerinLab report on liquid viscosity of glycerin
Lab report on liquid viscosity of glycerin
 
extra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdfextra-chromosomal-inheritance[1].pptx.pdfpdf
extra-chromosomal-inheritance[1].pptx.pdfpdf
 
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
(May 29th, 2024) Advancements in Intravital Microscopy- Insights for Preclini...
 
Hemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptxHemostasis_importance& clinical significance.pptx
Hemostasis_importance& clinical significance.pptx
 
In silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptxIn silico drugs analogue design: novobiocin analogues.pptx
In silico drugs analogue design: novobiocin analogues.pptx
 
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptxBody fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
Body fluids_tonicity_dehydration_hypovolemia_hypervolemia.pptx
 
insect taxonomy importance systematics and classification
insect taxonomy importance systematics and classificationinsect taxonomy importance systematics and classification
insect taxonomy importance systematics and classification
 
NuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final versionNuGOweek 2024 Ghent - programme - final version
NuGOweek 2024 Ghent - programme - final version
 
Large scale production of streptomycin.pptx
Large scale production of streptomycin.pptxLarge scale production of streptomycin.pptx
Large scale production of streptomycin.pptx
 
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
Circulatory system_ Laplace law. Ohms law.reynaults law,baro-chemo-receptors-...
 
Mammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also FunctionsMammalian Pineal Body Structure and Also Functions
Mammalian Pineal Body Structure and Also Functions
 
Richard's entangled aventures in wonderland
Richard's entangled aventures in wonderlandRichard's entangled aventures in wonderland
Richard's entangled aventures in wonderland
 
platelets- lifespan -Clot retraction-disorders.pptx
platelets- lifespan -Clot retraction-disorders.pptxplatelets- lifespan -Clot retraction-disorders.pptx
platelets- lifespan -Clot retraction-disorders.pptx
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
 
Structures and textures of metamorphic rocks
Structures and textures of metamorphic rocksStructures and textures of metamorphic rocks
Structures and textures of metamorphic rocks
 
The ASGCT Annual Meeting was packed with exciting progress in the field advan...
The ASGCT Annual Meeting was packed with exciting progress in the field advan...The ASGCT Annual Meeting was packed with exciting progress in the field advan...
The ASGCT Annual Meeting was packed with exciting progress in the field advan...
 

Capabilities for Resources and Effects

  • 2. Capabilities for Resources and Effects Two areas where static typing has lagged behind • Resources • Effects 100’s of papers over 40 years, no large scale adoption yet.
  • 3. Capabilities for Resources and Effects Two areas where static typing has lagged behind • Resources • Effects 100’s of papers over 40 years, no large scale adoption yet. Core Insights • Resources and effects can be expressed as capabilities. • Retained capabilities should be be tracked in types.
  • 4. Resources Values that are available only with certain restrictions, such as • lifetime • sharing • quantity Examples • regions of memory • file handles • channels • database and network connections ... Aspects of the computation beyond shapes of inputs and outputs that we want to track in types. Examples • updating variables • throwing exceptions • I/O • suspending a computation ... Effects
  • 5. Resources and Effects in Programming abstraction compile-time tracking ? 20+M investment Mozillla, ERC, … ?
  • 6. Resources and Effects in Programming abstraction compile-time tracking Linear Haskell Singularity Mezzo Alias types Algebraic effects 20+M investment Mozillla, ERC, … ?
  • 7. Resources and Effects in Programming abstraction compile-time tracking Caprese 20+M investment Mozillla, ERC, … ?
  • 8. The Effect Polymorphism Problem Unlike other types, effects are transitive: The effects of f1 include the effects of the functions it calls, transitively. How to describe the effects of f1 the call graph is dynamic?  Effect polymorphism problem I/O f1 f2 … fn throw Exc x := y await f()
  • 9. Capabilities to the Rescue Effects can be modeled with capabilities For instance, the following are equivalent: def f(): T throws E def f()(using CanThrow[E]): T Effect Capability
  • 10. Capabilities Solve Effect Polymorphism For instance, consider map on List[A]: def map[B](f: A => B): List[B]
  • 11. Capabilities Solve Effect Polymorphism For instance, consider map on List[A]: def map[B](f: A => B): List[B] With traditional effect systems: def map[B, E](f: A -> B eff E): List[B] eff E
  • 12. Capabilities Solve Effect Polymorphism For instance, consider map on List[A]: def map[B](f: A => B): List[B] With traditional effect systems: def map[B, E](f: A -> B eff E): List[B] eff E With capabilities: def map[B](f: A => B): List[B] Here A => B is the type of impure functions that can capture any capability as a free variable. Compare with A -> B for pure functions.
  • 13. Capabilities are Resources A CanThrow[E] capability is generated by a try that catches E. Example class TooLarge extends Exception def f(x: Int): Int throws TooLarge = if x < limit then x * x else throw TooLarge() val xs: List[Int] = … try xs.map(f) // generates ct: CanThrow[TooLarge] catch case ex: TooLarge => Nil The capability has limited lifetime: When the try exits, the capability can no longer be used.
  • 14. Capabilities are Resources A CanThrow[E] capability is generated by a try that catches E. Example class TooLarge extends Exception def f(x: Int)(using CanThrow[TooLarge]): Int if x < limit then x * x else throw TooLarge() val xs: List[Int] = … try xs.map(f(_)(using CanThrow[TooLarge])) catch case ex: TooLarge => Nil The capability has limited lifetime: When the try exits, the capability can no longer be used.
  • 15. Scoped Capabilities The following program still throws an unhandled exception: val it = try xs.iterator.map(f) catch case TooLarge => Iterator.empty it.next() To rule out this program statically, we need ways to enforce resource restrictions in the type system. Core idea: Track in a type which capabilities can be captured by its instances.
  • 16. Capabilities and Capturing Types Definition: A capturing type {c1,...,cn}T consists of a type T and a capture set of capabilities {c1,...,cn}that tracks references retained by values of type T. Definition: A capability is a reference of a capturing type with a non-empty capture set. • Every capability gets its authority from some other, more sweeping capability which it captures. • There is a root capability from which ultimately all others are derived. Type-systematic description of the object-capability model. Details in: Odersky, Boruch Gruszecki, Lee, Brachthäuser, Lhotak: Scoped Capabilities for Polymorphic Effects, Arxiv 2207.03402
  • 17. Capture Calculus: A formalization of a minimal core language with statically tracked capabilities Point of Departure
  • 18. Capture Calculus: A formalization of a minimal core language with statically tracked capabilities Capture checker prototype for a slightly larger language subset Point of Departure
  • 19. Capture Calculus: A formalization of a minimal core language with statically tracked capabilities Capture checker prototype for a slightly larger language subset Point of Departure Very promising in the small, but can we scale it up?
  • 20. Project Structure Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency
  • 21. Project Structure Challenges: Core Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency • Can we extend the theory to more language constructs that are important in practice? • Can we extend the theory to resource restrictions other than lifetime? • Can we find sound and effective inference algorithms?
  • 22. Project Structure Challenges: Extensions • Is capture checking expressive enough to model a large range of effect and resource usage patterns? • Can static checking help in designing efficient and safe memory systems and concurrent runtimes? Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency
  • 23. Project Structure Challenges: Infrastructure Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency • Are capture annotations lightweight enough to be used widely in practice? • Can capture checking be made efficient enough to be always on? • Can error diagnostics be made clear enough to be intelligible for non-experts? • How to migrate and interoperate with existing code?
  • 24. Project Structure Challenges: Applications Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency Can we validate the applicability of the research in selected application domains? Language-based security
  • 25. Project Structure Challenges: Applications Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency Can we validate the applicability of the research in selected application domains? Efficient computing
  • 26. Project Structure Challenges: Applications Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency Can we validate the applicability of the research in selected application domains? Distributed systems
  • 27. Project Structure Challenges: Applications Caprese Core • Foundations • Capture checking Infrastructure • Language integration • Libraries Applications • Formal methods • Efficient computing • Distributed • Security Extensions • Effect Domains • Memory Safety • Concurrency Can we validate the applicability of the research in selected application domains? Formal methods
  • 28. Why Us? To succeed, the project needs • strong theoretical foundations, • solid language implementation and tooling, • a large educated user base for empirical evaluations. Scala is unique in that it combines all three aspects.
  • 29. Outlook If successful, this work will solve several long-standing problems in programming: • Effect polymorphism - getting flexibility without the overhead • Mixing synchronous and asynchronous code • Combining manual allocation and automatic GC • Fearless concurrency, excluding data races and other hazards It will lead to exciting new ways to model functional and imperative programming as two ends of a spectrum. It will be the key to combining without compromises productivity, safety and performance.

Editor's Notes

  1. Hello