Presentation is loading. Please wait.

Presentation is loading. Please wait.

Implementation of Programming Languages 17 October 2015 | Software Technology Group | 1 Topics on EScala Vaidas Gasiunas, Lucas Satabin.

Similar presentations


Presentation on theme: "Implementation of Programming Languages 17 October 2015 | Software Technology Group | 1 Topics on EScala Vaidas Gasiunas, Lucas Satabin."— Presentation transcript:

1 Implementation of Programming Languages 17 October 2015 | Software Technology Group | 1 Topics on EScala Vaidas Gasiunas, Lucas Satabin

2 Importance of Events  Events – key element of reactive and interactive software  Graphical user interface  Embedded software  Complex event processing  …  Important for software design  Implicit invocation/Inversion of control - ”don't call us, we'll call you”  Essential for reducing coupling in software  Natural abstraction in OO  Attributes – access state  Operations – modify state  Events – observe state changes 17 October 2015 | Software Technology Group | 2

3 Goals of EScala  Support events as attributes of objects  Describe changes of object’s state  Part of the interface of an object  Objects react to events of other objects  Support different kinds of events  Explicitly triggered (imperative)  Intercepted events (joinpoints ala AOP)  Declarative events – as expressions over other events 3

4 Imperative Events class TemperatureSensor { imperative evt tempChanged[Int]... def run() { var currentTemp = measureTemp() while (true) { val newTemp = measureTemp() if (newTemp != currentTemp) { tempChanged(newTemp) currentTemp = newTemp } sleep(100) }... } Imperative events can be used for events that are not available as joinpoints or need to collect local state

5 Declarative and Implicit Events abstract class Figure { evt geomChanged[Unit] = afterExec(moveBy) || afterExec(resize) evt changed[Unit] = geomChanged || afterExec(setColor) evt invalidated[Rectangle] = changed.map(_ => getBounds())... def moveBy(dx: Int, dy: Int) { position.move(dx, dy) } def resize(size: Size) { this.size = size } def setColor(col: Color) { color = col } def getBounds(): Rectangle... }

6 Using Events class Drawing(val figures: List[Figure]) { evt invalidated = figures.any(_.invalidated)... } class DrawingView(val drawing : Drawing) { drawing.invalidated += redraw def invalidate(area : Rectangle) {... }... } At the end the events lead to reactions Events can be used to define higher level events

7 Topic #1: Convenient Event Expression Language  Problem: encoding event expressions by closures and higher order functions is not always concise and intuitive.  Solution: a dedicated event expression language with explicit event parameters, local variables and their explicit binding April 14, 2010 | Software Technology Group | 7 abstract class Figure { evt changed = geomChanged(_) || colorChanged(_) evt invalidated(r: Rectangle) = changed && (r = getBounds) evt colorChanged(c: Int) = beforeExec(setColor(c)) && (c != color)... }

8 Topic #2 Events as Intervals in Time  Current state:  The current model supports events as points in time  No support for relating multiple events  Goal:  Support events as intervals in time  Define operations allowing to related such event in different ways e2 = before(e1)e3 = after(e1) e1 = between(e2, e3)

9 Topic #2 Events as Intervals in Time  Considering events as intervals of time we eliminate boundary between events and states 17 October 2015 | Software Technology Group | 9 abstract class Alarm { evt isArmed = between(exec(arm), exec(disarm)) evt isDisarmed = between(exec(disarm), exec(arm)) imperative evt intrusionDetected evt alarm = intrusionDetected && within(isArmed) evt isAlarmed = between(alarm, exec(disarm)) def arm() {... } def disarm() {... } }

10 Topic #3 Changing Values in Event Definitions  Problem: Each time event source changes, the developer must manually register for the events of the new source. April 14, 2010 | Software Technology Group | 10 abstract class Connector { var from, to : Figure (from.changed || to.changed) += update def setFrom(f : Figure) { if (from != null) from.changed -= update from = f from.changed += update } def update {... } }

11 Topic #3 Changing Values in Event Definitions  Solution: Automatically update of events depending on changing values (behaviors) April 14, 2010 | Software Technology Group | 11 abstract class Connector { val from, to : Behavior[Figure] (from.changed || to.changed) += update def setFrom(f : Figure) { from = f } def update {... } } Behaviors are already available in Functional Reactive Programming (FRP) library of Scala, but need to be integrated with EScala’s events

12 Technical Perspective  Scala  A modern language combining ideas from object-oriented and functional programming  Academic and industrial interest steadily increasing  Runs on JVM, integrated in Eclipse and other Java IDE’s  Compiler implemented in Scala itself  EScala  Majority of functionality implemented as a pure Scala library  Scala compiler extended to support interception of events 17 October 2015 | Software Technology Group | 12

13 What will you gain?  Learn about reactive programming techniques: events, behaviors, reactors, aspects  Learn about compiler technology  Get acquainted with Scala and a variety of novel language features that are slowly finding their way into Java and C#  Get in touch with large-scale software development using advanced language features  Contribute to a new, dynamically evolving language 17 October 2015 | Software Technology Group | 13


Download ppt "Implementation of Programming Languages 17 October 2015 | Software Technology Group | 1 Topics on EScala Vaidas Gasiunas, Lucas Satabin."

Similar presentations


Ads by Google