jan pascal maas - uni-luebeck.de · seminar concepts of programming languages. introduction...

45
Synchronous vs. Asynchronous Programming Jan Pascal Maas Institute for Software Engineering and Programming Languages University of Luebeck 25. January 2016 Seminar Concepts of Programming Languages

Upload: others

Post on 17-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Synchronous vs. Asynchronous Programming

Jan Pascal Maas

Institute for Software Engineering and Programming LanguagesUniversity of Luebeck

25. January 2016Seminar Concepts of Programming Languages

Page 2: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Agenda

1 Introduction

2 ClassificationSynchronous ProgrammingAsynchronous Programming

3 ApproachesSynchronousAsynchronous

4 Conclusion

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 2/ 30

Page 3: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Introduction

programs rely on multiple constraintsespecially concurrency and communication increase complexity

concurrency is largely exploredgeneral programming paradigms can be usedmultiple approaches exist

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 3/ 30

Page 4: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Introduction—Communication

increases complexity largely

Example (Air Traffic Control System)information is known beforehand

all tasks can run independentlylow complexity

information and communication during executionsystem needs to be capable of accepting and processing informationrequires high amount of synchronized communication

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 4/ 30

Page 5: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Introduction—Communication

increases complexity largely

Example (Air Traffic Control System)information is known beforehand

all tasks can run independentlylow complexity

information and communication during executionsystem needs to be capable of accepting and processing informationrequires high amount of synchronized communication

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 4/ 30

Page 6: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Introduction—Paradigms to Synchronize

blocking (scheduler-based): block task to use resources differentlyblocked task ensures resuming of computationspecific synchronization condition required

busy-waiting: use of an evaluation loopreevaluated specific condition till it becomes true

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 5/ 30

Page 7: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Synchronous Programming

applies scheduler-based synchronizationblocks a task if it is necessaryresources can be used for a different taskif needed resources are available, computation continues

ensures correctness of the system

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 6/ 30

Page 8: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Figure: Synchronous blocking model [1].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 7/ 30

Page 9: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Figure: Asynchronous model [1].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 8/ 30

Page 10: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchronous Programming

uses busy-waitingre-evaluation of a specific conditionif true, condition depends on an external systemactions to compute are specified before execution

main thread continues runningactions that depend on external system(s) are executed on differentthread

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 9/ 30

Page 11: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Synchronous Approaches—LUSTRE

data-flow oriented languagefocussed on temporal correctnessvariables are treated as infinite sequences

(x0 = e0, x1 = e1, . . . , xn = en, . . . )

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 10/ 30

Page 12: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

LUSTRE—Operators

Let X = (x0, x1, . . . , xn, . . . ) and Y = (y0, y1, . . . , yn, . . . ).pre(X) = (nil, x0, x1, . . . , xn−1, . . . )X −> Y = (x0, y1, . . . , yn, . . . )

E =( e0 e1 e2 e3 e4 e5 . . . )B =( tt ff tt tt ff ff . . . )

X = E when B =( x0 = e0 x1 = e2 x2 = e3 . . . )Y = current(X) =( e0 e0 e2 e3 e3 e3 . . . )

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 11/ 30

Page 13: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

LUSTRE—Operators

Let X = (x0, x1, . . . , xn, . . . ) and Y = (y0, y1, . . . , yn, . . . ).pre(X) = (nil, x0, x1, . . . , xn−1, . . . )X −> Y = (x0, y1, . . . , yn, . . . )

E =( e0 e1 e2 e3 e4 e5 . . . )B =( tt ff tt tt ff ff . . . )

X = E when B =( x0 = e0 x1 = e2 x2 = e3 . . . )Y = current(X) =( e0 e0 e2 e3 e3 e3 . . . )

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 11/ 30

Page 14: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

LUSTRE—Synchronization

when is used to create streamsstreams allow synchronization of the programto synchronize differently clocked streams, current is used

assertions generalize equations → facts to synchronize program

assert not (x and y)

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 12/ 30

Page 15: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

LUSTRE—Synchronization

when is used to create streamsstreams allow synchronization of the programto synchronize differently clocked streams, current is used

assertions generalize equations → facts to synchronize program

assert not (x and y)

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 12/ 30

Page 16: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

SIGNAL

concept similar to LUSTREallows explicit synchronization using synchromerging of two signals with default

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 13/ 30

Page 17: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

ESTEREL

imperative languagevariables are called signalsreaction: process of computing output based on inputfixed status and current value (initially �) in the same reaction

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 14/ 30

Page 18: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

ESTEREL—Synchronization

emit: sending output signalswatching: await specific signalpresent: detects for presence of a signal

doI 1 −> O1

watch ing I 2 ;emit O2

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 15/ 30

Page 19: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

ESTEREL—Synchronization

emit: sending output signalswatching: await specific signalpresent: detects for presence of a signal

doI 1 −> O1

watch ing I 2 ;emit O2

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 15/ 30

Page 20: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchrony through Concurrency

multiple threads used to perform IO-bound tasks

Problem: Scalability is limited

requirement of different approaches

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 16/ 30

Page 21: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchrony through Concurrency

multiple threads used to perform IO-bound tasksProblem: Scalability is limited

requirement of different approaches

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 16/ 30

Page 22: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchronous Approaches—Event Loop

inversion of controlefficiency and scalabilitycontrol over switching between application activitiesrelies on notification facilitiesapplication handles occurrence of eventscommonly used: Node.js

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 17/ 30

Page 23: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Client 1

Client 2

Client n

Request 1Request 2. . .Request n

Request 1

Request 2

Request nRequest 1

Request 2

Request n

T1 T2 . . . Tm

Thread T1

Database

File System

handled by

Blocking IO?

Event Loop

Send Responses

non-blocking isprocessed here

Event Queue Internal Thread Pool

Blocking IO handler

⇐Ô

Request-1

Request-2

Request-n

Response-1

Response-2

Response-n

Pick up Requests from Queue

no

no

yes

non-blocking IO

non-blocking IO

blocking IO

pickup oneThread

Figure: Node.js processing model [2].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 18/ 30

Page 24: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Client 1

Client 2

Client n

Request 1Request 2. . .Request n

Request 1

Request 2

Request nRequest 1

Request 2

Request n

T1 T2 . . . Tm

Thread T1

Database

File System

handled by

Blocking IO?

Event Loop

Send Responses

non-blocking isprocessed here

Event Queue Internal Thread Pool

Blocking IO handler

⇐Ô

Request-1

Request-2

Request-n

Response-1

Response-2

Response-n

Pick up Requests from Queue

no

no

yes

non-blocking IO

non-blocking IO

blocking IO

pickup oneThread

Figure: Node.js processing model [2].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 18/ 30

Page 25: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Client 1

Client 2

Client n

Request 1Request 2. . .Request n

Request 1

Request 2

Request n

Request 1

Request 2

Request n

T1 T2 . . . Tm

Thread T1

Database

File System

handled by

Blocking IO?

Event Loop

Send Responses

non-blocking isprocessed here

Event Queue Internal Thread Pool

Blocking IO handler

⇐Ô

Request-1

Request-2

Request-n

Response-1

Response-2

Response-n

Pick up Requests from Queue

no

no

yes

non-blocking IO

non-blocking IO

blocking IO

pickup oneThread

Figure: Node.js processing model [2].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 18/ 30

Page 26: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Client 1

Client 2

Client n

Request 1Request 2. . .Request n

Request 1

Request 2

Request nRequest 1

Request 2

Request n

T1 T2 . . . Tm

Thread T1

Database

File System

handled by

Blocking IO?

Event Loop

Send Responses

non-blocking isprocessed here

Event Queue Internal Thread Pool

Blocking IO handler

⇐Ô

Request-1

Request-2

Request-n

Response-1

Response-2

Response-n

Pick up Requests from Queue

no

no

yes

non-blocking IO

non-blocking IO

blocking IO

pickup oneThread

Figure: Node.js processing model [2].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 18/ 30

Page 27: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Client 1

Client 2

Client n

Request 1Request 2. . .Request n

Request 1

Request 2

Request nRequest 1

Request 2

Request n

T1 T2 . . . Tm

Thread T1

Database

File System

handled by

Blocking IO?

Event Loop

Send Responses

non-blocking isprocessed here

Event Queue Internal Thread Pool

Blocking IO handler

⇐Ô

Request-1

Request-2

Request-n

Response-1

Response-2

Response-n

Pick up Requests from Queue

no

no

yes

non-blocking IO

non-blocking IO

blocking IO

pickup oneThread

Figure: Node.js processing model [2].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 18/ 30

Page 28: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Client 1

Client 2

Client n

Request 1Request 2. . .Request n

Request 1

Request 2

Request nRequest 1

Request 2

Request n

T1 T2 . . . Tm

Thread T1

Database

File System

handled by

Blocking IO?

Event Loop

Send Responses

non-blocking isprocessed here

Event Queue Internal Thread Pool

Blocking IO handler

⇐Ô

Request-1

Request-2

Request-n

Response-1

Response-2

Response-n

Pick up Requests from Queue

no

no

yes

non-blocking IO

non-blocking IO

blocking IO

pickup oneThread

Figure: Node.js processing model [2].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 18/ 30

Page 29: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Client 1

Client 2

Client n

Request 1Request 2. . .Request n

Request 1

Request 2

Request nRequest 1

Request 2

Request n

T1 T2 . . . Tm

Thread T1

Database

File System

handled by

Blocking IO?

Event Loop

Send Responses

non-blocking isprocessed here

Event Queue Internal Thread Pool

Blocking IO handler

⇐Ô

Request-1

Request-2

Request-n

Response-1

Response-2

Response-n

Pick up Requests from Queue

no

no

yes

non-blocking IO

non-blocking IO

blocking IO

pickup oneThread

Figure: Node.js processing model [2].

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 18/ 30

Page 30: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Continuations

Examplepub l i c i n t Div ide ( i n t top , i n t bottom ){

i f ( bottom==0){

throw new Inva l i dOperat ionExcept ion ( ” d iv ␣by␣0” ) ;}e l s e{

return top/bottom ;}

}

pub l i c bool IsEven ( i n t aNumber){

var i sEven = (aNumber % 2 == 0 ) ;return i sEven ;

}

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 19/ 30

Page 31: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Continuations

Examplepub l i c T Divide<T>(i n t top , i n t bottom , Func<T> i fZe ro , Func<int ,T> i f S u c c e s s ){

i f ( bottom==0){

return i f Z e r o ( ) ;}e l s e{

return i f S u c c e s s ( top/bottom ) ;}

}

pub l i c T IsEven<T>(i n t aNumber , Func<int ,T> ifOdd , Func<int ,T> i fEven ){

i f (aNumber % 2 == 0){

return i fEven (aNumber ) ;}e l s e{

return i fOdd (aNumber ) ;}

}

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 20/ 30

Page 32: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchrony in F#

also implementing event-based paradigmlibrary with new syntactic category aexpruse capability of language to handle different contextasynchronous operations are capable of binding core language results

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 21/ 30

Page 33: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchrony in F#—Task Generators

sometimes functions need task generatorscan run asynchronous computations synchronouslycan be run as a co-routine if it does not produce a result

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 22/ 30

Page 34: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Example (Task Generators)

let sleepThenReturnResult =async { printfn "before␣sleep"do! Async.Sleep 5000return 1000

}

let res = Async.RunSynchronously sleepThenReturnResultprintfn "result␣=␣%d" res

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 23/ 30

Page 35: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Where is the callback run?

in .NET any computation has access to synchronization contextany callback is running “somewhere”

can be abused to run callbacks based on function closures

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 24/ 30

Page 36: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Where is the callback run?

in .NET any computation has access to synchronization contextany callback is running “somewhere”

can be abused to run callbacks based on function closures

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 24/ 30

Page 37: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchronous Resource Clean-Up

language feature: use!allows to directly dispose resourcescancellation of operations: implicit propagation of a token

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 25/ 30

Page 38: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Synchronous Programming—Pro and Contra

ensures temporal and logicalcorrectness

blocking a thread might blockcomplete systemrequires manual use ofsynchronization mechanismsmay lie outside the control ofthe programmer

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 26/ 30

Page 39: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Synchronous Programming—Pro and Contra

ensures temporal and logicalcorrectness

blocking a thread might blockcomplete systemrequires manual use ofsynchronization mechanismsmay lie outside the control ofthe programmer

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 26/ 30

Page 40: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchronous Programming—Pro and Contra

system stays responsiveoutperforms synchronoussystemsmain process is alwayssingle-threadedprogrammer is in control oftask suspensionmulti-threading is notforbiddenallows to reduce the syntax to“computation expressions”no need to explicitly ensuretemporal correctness

program needs to beorganized in smaller stepsno explicit use ofmulti-threadingnot all interprocesscommunication can bereduced to eventshigh complexity withoutcallbacks

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 27/ 30

Page 41: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Asynchronous Programming—Pro and Contra

system stays responsiveoutperforms synchronoussystemsmain process is alwayssingle-threadedprogrammer is in control oftask suspensionmulti-threading is notforbiddenallows to reduce the syntax to“computation expressions”no need to explicitly ensuretemporal correctness

program needs to beorganized in smaller stepsno explicit use ofmulti-threadingnot all interprocesscommunication can bereduced to eventshigh complexity withoutcallbacks

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 27/ 30

Page 42: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Conclusion

Asynchronous programming eliminates some issues from synchronousprogrammingAsynchrony allows the programmer to take controlAsynchrony takes care of temporal correctness

Synchronous programming is required in some areasAsynchronous programming can not be used at any operationComplexity of Asynchrony can ensure unmaintainable code

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 28/ 30

Page 43: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Conclusion

Asynchronous programming eliminates some issues from synchronousprogrammingAsynchrony allows the programmer to take controlAsynchrony takes care of temporal correctness

Synchronous programming is required in some areasAsynchronous programming can not be used at any operationComplexity of Asynchrony can ensure unmaintainable code

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 28/ 30

Page 44: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Thank You for Your attention.

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 29/ 30

Page 45: Jan Pascal Maas - uni-luebeck.de · Seminar Concepts of Programming Languages. Introduction Classification Approaches Conclusion Agenda 1 Introduction 2 Classification Synchronous

Introduction Classification Approaches Conclusion

Literature

Dave Peticolas.An introduction to asynchronous programming and twisted.http://krondo.com/?p=1209, 2009.Accessed: 2015-11-07.Rambabu Posa.Node.js processing model – single threaded model with event looparchitecture.https://tinyurl.com/jjc7btk, 2015.Accessed: 2015-12-17.

J. P. Maas (University of Luebeck) Synchronous vs. Asynchronous Programming 30/ 30