Lightweight session programming in scala
File(s)DTR15-7.pdf (1.46 MB)
Published version
Author(s)
Scalas, Alceste
Yoshida, Nobuko
Type
Report
Abstract
Designing, developing and maintaining concurrent applications is an error-prone and time-consuming
task; most difficulties arise because compilers are usually unable to check whether the
inputs/outputs performed by a program at runtime will adhere to a given protocol specification.
To address this problem, we propose lightweight session programming in Scala: we leverage the
native features of the Scala type system and standard library, to introduce (1) a representation
of session types as Scala types, and (2) a library, called lchannels, with a convenient API for
session-based programming, supporting local and distributed communication. We generalise the
idea of Continuation-Passing Style Protocols (CPSPs), studying their formal relationship with
session types. We illustrate how session programming can be carried over in Scala: how to
formalise a communication protocol, and represent it using Scala classes and lchannels, letting
the compiler help spotting protocol violations. We attest the practicality of our approach with a
complex use case, and evaluate the performance of lchannels with a series of benchmarks.
task; most difficulties arise because compilers are usually unable to check whether the
inputs/outputs performed by a program at runtime will adhere to a given protocol specification.
To address this problem, we propose lightweight session programming in Scala: we leverage the
native features of the Scala type system and standard library, to introduce (1) a representation
of session types as Scala types, and (2) a library, called lchannels, with a convenient API for
session-based programming, supporting local and distributed communication. We generalise the
idea of Continuation-Passing Style Protocols (CPSPs), studying their formal relationship with
session types. We illustrate how session programming can be carried over in Scala: how to
formalise a communication protocol, and represent it using Scala classes and lchannels, letting
the compiler help spotting protocol violations. We attest the practicality of our approach with a
complex use case, and evaluate the performance of lchannels with a series of benchmarks.
Date Issued
2015-01-01
Citation
Departmental Technical Report: 15/7, 2015, pp.1-45
Publisher
Department of Computing, Imperial College London
Start Page
1
End Page
45
Journal / Book Title
Departmental Technical Report: 15/7
Copyright Statement
© 2015 The Author(s). This report is available open access under a CC-BY-NC-ND (https://creativecommons.org/licenses/by-nc-nd/4.0/)
Publication Status
Published
Article Number
15/7