{"title":"Lightweight Session Programming in Scala","authors":"A. Scalas, N. Yoshida","doi":"10.4230/LIPIcs.ECOOP.2016.21","DOIUrl":null,"url":null,"abstract":"Designing, developing and maintaining concurrent applications is an \nerror-prone and time-consuming task; most difficulties arise because \ncompilers are usually unable to check whether the inputs/outputs \nperformed by a program at runtime will adhere to a given protocol \nspecification. To address this problem, we propose lightweight session programming in Scala: we leverage the native features of the Scala \ntype 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.","PeriodicalId":172012,"journal":{"name":"European Conference on Object-Oriented Programming","volume":"33 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2016-07-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"73","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"European Conference on Object-Oriented Programming","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.4230/LIPIcs.ECOOP.2016.21","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 73
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.