EScala is an extension of Scala programming language with support for events as attributes of objects. The support for events in EScala, combine the ideas of event-driven, aspect-oriented and functional-reactive programming.
Events are natural abstractions for describing interactive behavior, and the interfaces of objects. In conventional object-oriented languages events are usually modelled indirectly using some form of the Observer or the Publish-Subscribe pattern. For example, in Java libraries an object exposes events by providing a possibility to register so-called listener objects. In C# such pattern is supported directly in the language, by allowing to declare events as special class members. Despite their differences, in all these approaches the occurrences of events are defined imperatively by triggering them at the corresponding locations within the program.
EScala extends the idea of events as object members, as realized by C# events, with the possibility to define events declaratively by expressions over other events. The occurrences of an event can be defined by various set operations, such as union, intersection and difference, applied on the occurrences of other events. Events can be filtered by arbitrary conditions, the data attached to the events can be transformed by arbitrary functions. Event expressions make it possible to define events in terms of other events, at the lowest level relying on primitive events.
There are two kinds of primitive events in EScala: In addition to imperative events, which are defined by triggering, EScala also supports implicit events, which mark language-specific actions during the execution of a program, such as the beginning or the end of the execution of a method. Implicit events in ESCALA are analogous to join points in aspect-oriented languages.
EScala events are fully integrated with object-oriented features. An events is defined in the context of its owner object and can use their state and functionality in their definition. Events are inherited in subclasses, and the access to events is late-bound. Unlike typical aspect-oriented languages, EScala preserves object-oriented encapsulation and modular reasoning. Like in Java, classes can be compiled and loaded independently.
Software applications must react to external changes such as the input from the user and network messages. Traditionally, object-oriented software adopts the Observer pattern to implement reactivity and decouple the observers from the observables. Whereas researchers have highlighted the drawbacks of this style for a long time, alternatives struggle to be widely accepted. In particular, functional reactive programming and dataflow programming – which aim to represent time-changing values as first class abstractions – are promising, but hardly escape the functional setting. On the other hand, event-based languages directly support events but do not achieve the declarative style of more functional approaches.
REScala is a reactive language which integrates concepts from event-based and functional-reactive programming into the object-oriented world. REScala supports the development of reactive applications by fostering a functional and declarative style which complements the advantages of object-oriented design.
Advanced concurrency abstractions overcome the drawbacks of low-level techniques such as locks and monitors, freeing programmers that implement concurrent applications from the burden of concentrating on low-level details. However, with current approaches the coordination logic involved in complex coordination schemas is fragmented into several pieces including join patterns, data emissions triggered in different places of the application, and the application logic that implicitly creates dependencies among channels, hence indirectly among joins.
JEScala captures coordination schemas in a more expressive and modular way by leveraging a seamless integration of an advanced event system with join abstractions. JEScala is validated with case studies and provide a first performance assessment.