Linguistic Support for Large-Scale Distributed Programming

Patrick Eugster, Christian Heide Damm, Rachid GuerraouiInfoscience 2001

Abstract

This paper presents linguistic primitives for publish/subscribe programming using events and objects. We integrate our primitives into a strongly typed object-oriented language through four mechanisms: (1) serialization, (2) multiple subtyping, (3) closures, and (4) deferred code evaluation. We illustrate our primitives through Java, showing how we have overcome its respective lacks. A precompiler transforms statements based on our publish/subscribe primitives into calls to specifically generated typed adapters, which resemble the typed stubs and skeletons generated by the rmic precompiler for remote method invocations in Java.

Introduction

Distributed programming has traditionally relied on Remote Procedure Calls (RPC), which attempt to make network communication look like local function calls. While intuitive, RPC is inherently synchronous and requires tight coupling between participants—both parties must be online and know each other's locations.

The publish/subscribe (pub/sub) model offers a more flexible alternative by decoupling participants in time, space, and flow. However, most current pub/sub implementations exist as external libraries or APIs (such as JMS or CORBA). This "library-only" approach suffers from several drawbacks:

  • Type Safety: Compilers cannot verify type correctness for messages at compile-time.
  • Boilerplate: Developers must write significant "glue code" for registration and callbacks.
  • Optimization Gaps: The underlying system cannot easily optimize message filtering because it lacks visibility into the application logic inside library calls.

Type-Based Publish/Subscribe Model

To address these issues, the authors propose moving pub/sub primitives directly into the syntax of object-oriented languages. They introduce a model called Type-Based Publish/Subscribe, implemented for Java via a precompiler named psc.

In this model, events are treated as first-class citizens called Obvents (Object Events). These are essentially objects that can be serialized and distributed. The language is extended with two primary keywords:

  • publish o;: Handles the distribution of an event object o.
  • subscribe (T t) {filter} {handler};: Allows a user to listen for any object of type T (including its subtypes), using a closure for filtering and another for processing.
Type-based subscription hierarchy in a stock market application.

As illustrated in Figure 1, the type hierarchy itself serves as the subscription logic. Instead of subscribing to arbitrary string "topics" (like "stocks.tech"), users subscribe to Java types like StockQuote. This allows the language's native inheritance tree to manage message routing naturally and safely.

The Four Pillars of Integration

The integration into a strongly typed language relies on four key mechanisms:

  1. Serialization: Converting objects into wire-compatible data formats.
  2. Multiple Subtyping: Allowing events to carry complex traits simultaneously.
  3. Closures: Defining event handlers and filters succinctly within subscription expressions.
  4. Deferred Code Evaluation: This is the "secret sauce" of the model. By capturing filter logic in a closure, the system can ship that code to a remote broker or publisher. This "smart filtering" minimizes network traffic by discarding unwanted messages before they ever reach the subscriber's network interface.

Quality of Service (QoS) through Subtyping

A significant advantage of this approach is the ability to map complex distributed systems properties to language-level interfaces through multiple subtyping.

Hierarchy of Quality of Service (QoS) traits.

Figure 2 shows how delivery guarantees—such as reliability, total ordering, and causal ordering—can be represented as a hierarchy of Java interfaces. Developers can "request" specific delivery guarantees simply by ensuring their event objects implement the corresponding interface. The psc precompiler then generates the appropriate "typed adapters" to handle the underlying network protocols.

Discussion and Future Work

While the type-based approach offers significant benefits in terms of safety and optimization, it introduces new challenges. Shipping executable filter code to remote hosts raises security and trust concerns. Furthermore, the current implementation is Java-centric, suggesting a need for a neutral "Event Description Language" (similar to CORBA's IDL) for cross-language interoperability.

Despite these limitations, the integration of pub/sub primitives into the language syntax represents a major step forward in simplifying the development of large-scale distributed systems. By leveraging the existing type system, developers can build more robust, efficient, and maintainable applications.

Summary updated

Abstract

This paper presents linguistic primitives for publish/subscribe programming using events and objects. We integrate our primitives into a strongly typed objectoriented language through four mechanisms: (1) serialization, (2) multiple subtyping, (3) closures, and (4) deferred code evaluation. We illustrate our primitives through Java, showing how we have overcome its respective lacks. A precompiler transforms statements based on our publish/subscribe primitives into calls to specifically generated typed adapters, which resemble the typed stubs and skeletons generated by the rmic precompiler for remote method invocations in Java.
BibTeX
@inproceedings{eugster2001linguistic,
  author = {Patrick Eugster and Christian Heide Damm and Rachid Guerraoui},
  title = {{Linguistic Support for Large-Scale Distributed Programming}},
  booktitle = {Infoscience},
  year = {2001},
}
Figure