Multitier programming languages reduce the complexity of developing distributed software by developing the distributed system within a single coherent code base. In multitier languages, the compiler or the runtime takes care of separating the code into the components of the distributed system. This approach enables abstraction over low level implementation details such as data representation, serialization and network protocols. The ScalaLoci programming language allows developers to declare the components of the system and their architectural relation at the type level, enabling static reasoning about distribution and remote communication and guaranteeing static type safety for data transfer across components. As the compiler automatically generates the communication boilerplate among components, data transfer among components can be modeled declaratively, by specifying the data flows in the reactive programming style.In this paper, we report on the ScalaLoci implementation and on our experience with embedding ScalaLoci's language features into Scala as a host language. We show how a combination of Scala's advanced type level programming and of Scala's macro system enable enriching the language with new abstractions for distributed systems. We describe the challenges we encountered for the implementation and report on the solutions we developed. Finally, we outline suggestions for improving the Scala macro system to better support embedding domain-specific abstractions.
ACM CCS 2012The design of ScalaLoci unfolds around three major ideas. First, the distributed topology (i.e., separate locations that execute code) is explicit and specified by the programmer, who assigns code to each system component. Second, remote communication within the distributed system (i.e., with performance and failure characteristics different from local communication) is explicit and supports event-based interaction between components. Third, ScalaLoci abstractions are embedded as domain-specific features into an existing general purpose language. We lay out the design space for our language implementation and derive concrete design requirements.Explicit Specification of Distribution and Topology Some languages for distributed systems abstract over the topology, i.e., code is agnostic to the system's components and their connections. Such approach is often chosen for highly specialized programming models, e.g., streaming systems [16,62], intentionally hiding distribution. On the other end lie approaches where developers specify the topology. Distribution unavoidably becomes apparent when implementing different components, e.g., in actor systems [1]. While actor systems encapsulate components into actors, topological information is not encoded at the language level but managed explicitly by the developer.Clearly, a multitier programming model for developing generic distributed systems -similar to what the actor model offers -cannot abstract over distribution completely. To decide on the component that executes a specific part of the cod...