PiLib: A Hosted Language for Pi-Calculus Style Concurrency Vincent Cremet, Martin Odersky ´ Ecole Polytechnique F´ ed´ erale de Lausanne 1015 Lausanne, Switzerland {vincent.cremet, martin.odersky}@epfl.ch Abstract. PiLib is a library written in Scala that implements the con- currency constructs of the π-calculus. Some features of the programming language Scala, examined in the paper, make it possible to use almost the same syntax as in the π-calculus. The advantages of this library with respect to a simple π-calculus interpreter are that we can transmit any value along names, we can get control over them using the type system, and we have access to the full power of Scala in terms of expressiveness and libraries. 1 Introduction Support for concurrency is now almost universal in general purpose program- ming languages. But the supported concepts vary widely from one language to the next. For example, Concurrent ML [1] is based on an event-based model for process synchronization. Occam [2] is a programming language based on CSP [3]. In a similar way, Pict [4] is based on the π-calculus [5]. Facile [6] also uses π-calculus style channel-based communication. JoCaml [7], Funnel [8], and Polyphonic C# [9] use synchronization patterns from join calculus [10]. Er- lang [11] is based on an actor model where processes interpret messages in their mailboxes by pattern matching. Oz [12] uses logic variables for process commu- nication. Id [13] and Concurrent Haskell [14] use a form of mutable variables called M-structures [15]. In contrast, most mainstream languages are based on a shared memory thread model. Recent popular languages such as Java [16] or the .NET common lan- guage runtime [17] augment this model with thread synchronization based on the Monitor concept [18,19]. In spite of this confusing variety, some trends can be observed. A large body of theoretical research in concurrency is based on CCS or its successor, the π-calculus. The same holds for many specifications of concurrent systems. A π-calculus specification can be an executable program. Nevertheless, most con- current systems are still implemented with shared-memory threads, which are synchronized with semaphores or monitors. Such programs are often much harder to reason about and verify than π-calculus specifications. But they are also often more efficient to implement.