Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive...

21
Implementation of Programming Languages Guido Salvaneschi Jurgen Van Ham

Transcript of Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive...

Page 1: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Implementation of Programming Languages

Guido Salvaneschi

Jurgen Van Ham

Page 2: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Outline

• Administrivia

• Intro

• Schedule

• Topics

Page 3: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

GENERAL INFORMATION

Page 4: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Administrivia

• Guido Salvaneschi, Jurgen van Ham

– Find us by email

[email protected]

[email protected]

– Office A213 / A207

– Group of Prof. Mira Mezini (STG)

Page 5: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Intro

• Implement a software artifact according to a given specification.

• General scope: programming languages:

– Extensions, code generators

– Tools, IDEs

– Analysis techniques

– Performance assessments

– Prototypes with innovative abstractions

Page 6: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Timeline

• Periodic discussions/meetings.

• Presentation and delivery of the artifact and the documentation: end of the semester.

Page 7: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Guidelines and Suggestions

• Depending on the goal of the project

• In general:

– Deliver RUNNING code

– Deliver some documentation

– Optional: final presentation / demo to discuss your work

• Teamworking is good!

– Organize a team even with people you don’t know (yet)

Page 8: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Grades

• Depending on the project

• Some guidelines:

– How much of the specification was implemented?

– Is the code working (the answer is YESOFCOURSE)

– What is the overall quality of the code?• E.g. is it painful to modify/extend it ?

• Is it self-documenting ?

– What is the quality of the documentation ?

Page 9: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Where to start

• Send me an email with your name and a list of 3 topics in order of preference.

• Or arrange an appointment:

– Ask clarifications if needed

– Discuss possible customizations

– Discuss the projects in more detail

– Consider your programming skills

• Topics will be assigned

• Discuss the project in detail with the instructor

Page 10: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Getting Widespread…

• Reactive programming in JavaScript– Flapjax, Bacon.js, Reactive.js, React.js, …

• Microsoft reactive extensions (Rx)

• REScala– www.rescala-lang.com

• Principles of Reactive Programming– Martin Odersky, Erik Meijer and Roland Kuhn

– https://www.coursera.org/course/reactive

Page 11: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

RP in a Nutshell

• Reactivity in OO apps: Observer pattern

• In RP you can define constraints

– The framework enforces them for you

– Changes are automatically propagated

VIEWX Y Z

DATAX Y Z

val a = 3val b = 7val c := a + bval d := 2 * ca=4 println(c) // c==11 a b

c

d

Page 12: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

TOPICS

Page 13: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Collection of examples for RP

• Create a suite of examples that cover the basics of reactive programming

• (Small!) Simulations

• Graphical interfaces

Enter a 3 character string:<input id="textField1"

style={! {borderColor: (extractValueB('textField1').length === 3 ? 'green' : 'red')}

!}/>

Page 14: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Scala Interface for Distributed RP

• DREAM: Distributed REActive PrograMming

• Provide a Scala reactive interface for DREAM !

– Analysis of Signal expressions

– Binding with remote objects

val a = Signal{ a() + b() }

Remote<Int> a = new Remote(“a + b”) DREAM

RESCALA

Page 15: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Case study for Join Languages

• Joins make concurrency easier!

– Wait for the second event

• Several proposals

– Polyphonic C# (Microsoft)

– Scala Joins

– JoCaml

• Evaluate this solution with a case study

Page 16: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Case study on efficient reactive programming

• Example from Simulink/Labview

• Implement the example using RP

• Compare performance and expressivity

Page 17: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

RP in Java - DREAM

• Java 8 (finally!) has lambdas

• Extend Java to support signals and RP

– Polyglot/JustAdd extensible compilers

– Functional flavor + reactivity

Stream<Student> map = persons.stream().filter(p -> p.getAge() > 18).map(person -> new Student(person));

people.stream().

filter(p -> p.getGender() == Person.Gender.FEMALE).mapToInt(p -> p.getSalary()).

sum();

select sum(salary)from people

where gender = 'FEMALE'

SQL JAVA 8

Page 18: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Twitter Client

• Develop a simple twitter client with reactive programming

– Simple GUI

– Reactive abstractions• XML parsing

• Network communication

• User interaction

• Evaluate the use of reactive abstractions in the project

• Just an example, other case studies are possible

Page 19: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Session types in Scala

• Session types support static check of protocols correctness

• Steps

– Study session types

– Reuse existing library

– Small case study

Page 20: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

Reactive Programming and OO Languages

• Reactive programming has been developed in the functional programming community

– How reactive abstractions, e.g. signals, behaviors, …, interact with OO features ?

• Develop a set of small examples/studies that investigate reactive programming in the OO domain

– Encapsulation

– Inheritance

– Information hiding

– ..

Page 21: Implementation of Programming Languages · Reactive Programming and OO Languages •Reactive programming has been developed in the functional programming community –How reactive

QUESTIONS?