ºÝºÝߣ
Submit Search
NDC14 - Rx? Functional Reactive Programming?? ??? ?? ???
?
347 likes
?
70,340 views
Jong Wook Kim
Follow
2014? 5? 28? NDC14 ???????.
Read less
Read more
1 of 105
More Related Content
NDC14 - Rx? Functional Reactive Programming?? ??? ?? ???
2.
2
3.
3
4.
? Google 4 ???? ????
?? ?????? ?????
5.
5
6.
? ? f :
X ¡ú Y int main() { return 42; } a b c 1 2 3 X Y f 6
7.
a b c 1 2 3 X Y f :
X ¡ú Y ? ? ? Z g : Y ¡ú Z f g 7
8.
a b c X ? ? ? Z g ¡ã f
: X ¡ú Z g ¡ã f 8 ????
9.
¡ int y =
f(x); int z = g(y); ¡ 9 ???? ????? ? ??, ????? ??? ¡ú ???, ???
10.
f g 10 ???? ??
???? ?????
11.
g ¡ã f 11 ?
??? ??? ??? ????? ?
12.
12 ?? ?? ??
?? ??? ???? ???? ????
13.
ANYTHING 13 ? ????? ???
???? ??? ???!
14.
? Google 14 ???: ????
??
15.
15 40? ? ????
16.
16
17.
17 7~80??? ???? ???
?? ??? ??? ? ???? ?? ??? ???? ?? ???? ??
18.
18 ???? ??? ????
19.
19 ? ???? ?????
?? ??? ???? ??? ??
20.
20
22.
22
23.
A = 3 B
= 4 C = A + B A = 4 B = 5 print C 23 ??? 7? ?????
24.
24 ??? ???? Reactive
Programming
25.
C = A
+ B + A C B 25 ???? ??? ???? ??, ???? ??? ??? ???? ?
26.
26 ??? ???? ???
??? ??
27.
27 ??? ??? ??
??? ??
28.
? Behringer 28 ??? ??
??? ??? ??
29.
? Manu Cornet 29 ??
??? ?? ????
30.
Declarative Logic Abductive Answer Set Constraint Functional Inductive Functional Functional Logic Dataflow Reactive Cell-Oriented Structured Object-Oriented Prototype-BasedClass-Based ModularBlock-Structured Point-Free
Style Procedural Event-Driven Service-Oriented Time-Driven Concurrent Relativistic Action Agent-Oriented Aspect-Oriented Automata-Based End-User Expression-Oriented Feature-Oriented Non-Structured Array Metaprogramming Template Reflective Homoiconic Automatic Flow-Based Concatenative Function-LevelValue-Level Imperative Semantic Concept ProbabilisticLanguage-Oriented Natural Language Discipline-Specific Domain-Specific Grammar-Oriented Intentional Programming Paradigms @ Wikipedia
31.
Declarative Logic Abductive Answer Set Constraint Functional Inductive Functional Functional Logic Dataflow Reactive Cell-Oriented Structured Object-Oriented Prototype-BasedClass-Based ModularBlock-Structured Point-Free
Style Procedural Event-Driven Service-Oriented Time-Driven Concurrent Relativistic Action Agent-Oriented Aspect-Oriented Automata-Based End-User Expression-Oriented Feature-Oriented Non-Structured Array Metaprogramming Template Reflective Homoiconic Automatic Flow-Based Concatenative Function-LevelValue-Level Imperative Semantic Concept ProbabilisticLanguage-Oriented Natural Language Discipline-Specific Domain-Specific Grammar-Oriented Intentional 31 ¡ mov ah, 09h lea dx, msg int 21h ¡
32.
Declarative Logic Abductive Answer Set Constraint Functional Inductive Functional Functional Logic Dataflow Reactive Cell-Oriented Structured Object-Oriented Prototype-BasedClass-Based ModularBlock-Structured Point-Free
Style Procedural Event-Driven Service-Oriented Time-Driven Concurrent Relativistic Action Agent-Oriented Aspect-Oriented Automata-Based End-User Expression-Oriented Feature-Oriented Non-Structured Array Metaprogramming Template Reflective Homoiconic Automatic Flow-Based Concatenative Function-LevelValue-Level Imperative Semantic Concept ProbabilisticLanguage-Oriented Natural Language Discipline-Specific Domain-Specific Grammar-Oriented Intentional 32 typedef struct { int x, y } POINT; void foo(POINT *p) { if (p->x > 0) { p->y *= -1; } }
33.
Declarative Logic Abductive Answer Set Constraint Functional Inductive Functional Functional Logic Dataflow Reactive Cell-Oriented Structured Object-Oriented Prototype-BasedClass-Based ModularBlock-Structured Point-Free
Style Procedural Event-Driven Service-Oriented Time-Driven Concurrent Relativistic Action Agent-Oriented Aspect-Oriented Automata-Based End-User Expression-Oriented Feature-Oriented Non-Structured Array Metaprogramming Template Reflective Homoiconic Automatic Flow-Based Concatenative Function-LevelValue-Level Imperative Semantic Concept ProbabilisticLanguage-Oriented Natural Language Discipline-Specific Domain-Specific Grammar-Oriented Intentional 33 template<typename T> class Foo { T t; public: Foo(T t) : t(t) {} void foo() { cout << t; } };
34.
Declarative Logic Abductive Answer Set Constraint Functional Inductive Functional Functional Logic Dataflow Reactive Cell-Oriented Structured Object-Oriented Prototype-BasedClass-Based ModularBlock-Structured Point-Free
Style Procedural Event-Driven Service-Oriented Time-Driven Concurrent Relativistic Action Agent-Oriented Aspect-Oriented Automata-Based End-User Expression-Oriented Feature-Oriented Non-Structured Array Metaprogramming Template Reflective Homoiconic Automatic Flow-Based Concatenative Function-LevelValue-Level Imperative Semantic Concept ProbabilisticLanguage-Oriented Natural Language Discipline-Specific Domain-Specific Grammar-Oriented Intentional 34
35.
??? Logic Abductive Answer Set Constraint Functional Inductive ??? Functional Logic ?????? ???? Cell-Oriented ??? ???? Prototype-Based???
?? ????? ?? Point-Free Style ??? Event-Driven Service-Oriented Time-Driven ??? Relativistic Action Agent-Oriented Aspect-Oriented Automata-Based End-User Expression-Oriented Feature-Oriented Non-Structured Array ??????? ??? ???? Homoiconic Automatic Flow-Based Concatenative Function-LevelValue-Level ??? Semantic Concept ProbabilisticLanguage-Oriented Natural Language Discipline-Specific Domain-Specific Grammar-Oriented Intentional 35
36.
??? imperative ??? declarative ??? procedural ??? concurrent 36 ???? ??? ???
? ?
37.
37
38.
Event-Driven ???? ???? Scalable ??? ???? Resilient ???
???? Responsive ???? ???? 38
39.
1? ? ? 39
40.
10-3? ? ? 40
41.
10-6? ? ? ???? ??? 41
42.
10-9? ? ? 42
43.
? ? ? ? ? ? ? ? 43 ?? ??!!
44.
OUTPUT foo(INPUT a); 44 ???
???? ??? ???? ??? ?? ??? ???? ???? ?? ???? ???? ?? ???? ????? ??? ???? ?????
45.
? ? ? ? ? ? ? ? 45 ?? ??!!
46.
? Peter Thomas 46 ????
??? ?? ?? + ???? JDBC? ???
47.
47 ???? ??? ????,
? ?? ???? ??? ??? ??!
48.
48 ????? ??? ????
???? ?????
49.
49 ?? ????? ?
?? ???? ????
51.
? ? ? ? ? ? ? 51
52.
function foo(a, callback); 52 node.js?
vert.x? ???? ??
53.
foo(a, function(err, result)
{ if (err) { // handle error } else { // use result } ); 53
54.
// ?? ??
?? function compositeTask(t0, callback) { task1(t0, function(err, t1) { if (err) { callback(err); } task2(t1, function(err, t2) { if (err) { callback(err); } task3(t2, function(err, t3) { if (err) { callback(err); } callback(null, t3); }); }); }); } 54
55.
OUTPUT foo(INPUT a); 55 ??
?? ????
56.
M<OUTPUT> foo(INPUT a); 56
57.
INPUT => M<OUTPUT> INPUT
=> OUTPUT 57
58.
Checkpoint! 58
59.
59
60.
60
61.
? Aditya Bhargava 61 ??
?
62.
? Aditya Bhargava 62 ?
?? ??? ?? ??? ?? ?
63.
? Aditya Bhargava Maybe,
Option, Optional, Nullable 63 ?? ?? ?? ?? ??? ??
64.
? Aditya Bhargava 64 ??
??? +3? ??? ? ????-
65.
? Aditya Bhargava 65 ?????
?? ??? ? ??!
66.
? Aditya Bhargava 66 ???
map
67.
? Aditya Bhargava 67 ??
??? ?? ?? ?? ??
68.
? Aditya Bhargava 68 ???
??? ? ??? ??? ? ??!
69.
f g 69 ??? ????
????¡
70.
+3 +4 ? Aditya
Bhargava 70
71.
? Aditya Bhargava 71 ??
??? ??? ???
72.
72 ??? ?? ???
73.
73
74.
74
75.
75
76.
76 unit, return, just
mapMany, bind, thenCompose, >>=
77.
a = unit(2) b
= a.flatMap(x -> unit(x+3)) c = b.flatMap(y -> unit(y+4)) // c == unit(9) +3 +4 77
78.
?? ?? ?? Try<T>
Iterable<T> ??? Future<T> 78 ???
79.
79
80.
?? ?? ?? Try<T>
Iterable<T> ??? Future<T> Observable<T> 80
81.
81 ??? ??? ???
?? ?? ???? ?? Rx Reactive Extensions (.NET, 2009) RxJava (2012) rxjava-scala rxjava-groovy rxjava-clojure rxjava-jruby rxjava-kotlin RxJS RxCPP RxPy (2011) (2012) (2013)
82.
82
83.
Iterable (pull) Observable
(push) ??? ?? T next() onNext(T) ?? ?? throws Exception onError(Exception) ?? returns onCompleted() 83
84.
Iterable (pull) Observable
(push) getDataFromLocalMemory() .skip(10) .take(5) .map(s -> s + "foo") .forEach(println) getDataFromNetwork() .skip(10) .take(5) .map(s -> s + "foo") .forEach(println) 84
85.
+3 +4 Observable<int> add(Observable<int> input) { return
input.map(x -> x+3) .map(y -> y+4); } 85
86.
query1 query2 Observable<int> query1(int input); Observable<int>
query2(int input); Observable<int> query(Observable<int> input) { return input.flatMap(query1) .flatMap(query2); } 86
87.
x + y Observable<int> zip(Observable<int>
xs, Observable<int> ys) { return zip(xs, ys, (x, y) -> x + y); } yx 87
88.
? ? ? ? ? ? ? ? ? ? 88
89.
TCP Dispatcher Handler Handler Handler ¡ Data Grid DB
Driver ¡ 89
90.
TCP Dispatcher Handler Handler Handler ¡ Data Grid DB
Driver ¡ 90 Node
91.
Node 1 Node
2 Node 4Node 3 91
92.
Node 1 Node
2 Node 4Node 3 92 Service
93.
Service A Service B Service
D Service C Service E 93
94.
Service A Service B Service
D Service C Service E 94
95.
Service A Service B Service
D Service C Service E 95
96.
Event-Driven ???? ???? Scalable ??? ???? Resilient ???
???? Responsive ???? ???? 96
97.
97
98.
http://www.reactive-streams.org/ 98
99.
99
100.
100
101.
101
102.
102
103.
103
105.
105
Editor's Notes
??????
?? ????? ? ? ?? ??? ? ????? ??? ???? ? ? ?? ????. ?? ??? ?????? ??? ?? ??? ?? ?? ??? Functional Reactive Programming ???.
?? ? ??? ¡°?? ?? ??¡±??? ????? ??? ?? ??? ?? ???? ??????? ?? ??? ??? ?? ?? ??? ???. ??? ?? ???? ????? ??????? ?? ??? ???? ?? ?????, ?? ? ????? ?? ?? ???? ??? ? ??? ?????.
?? ??? ????, ????? ????? ??? ???? ??? ???? ?? ?? ??? ????. ???? ??? ??? ???? ??? ?? ??? ???Imperative ?? ???Procedural ??? ???.
??? ??? ???? ????? ? ????? ?? ?? ???? ?? ? ????. F ? g ? ?? ?? ??? ??? ?? ?????. ???? ?? ???, f? g? ????? ?? ??? ?? ?????. ?? ???? ? ??? ???Declarative???.
?? ??? ? ??? ??? ??? ? ??? ??? ? ?? ???.
??? ?? ??? ??? ? ?? ?? ?? ?? ? ???? ??? ? ????. ???? ??? ?? ??? ?????? ???? ??? ???? ? ????? ??? ???? ?? ? ?? ?? ?? ? ??? ??? ???.
?? ??? ?????? ????? ?? ????. 1973???? ?? ??? ?? 2013?? ???? ? ????? 1973? ???? ¡¯40? ?? ?????£§? ??? ?????,
?? 40? ??? ??? ?????? ??? ?????. ??? ?? ?? ?? ???? ??? ?? ??? ??? ??? ??? ????? ??? ??? ? ??? ??? ????.
??? ?? ???? ??? ???? ???? ?? ????, 70??? 80??? ???? ??? ???? ??? ?? ???.
?? ???? ????? ???? ??? ? ????? ???? ??? ?? ????? ?? ? ?????? ?? ????, ???? ?? ? ??? ?? ? ??????. ? ??? ???..
??? ????, ? ???? ????? ?? ? ????, ? ?????? ?? ????? ????, ??? ???? ??? ????? ??? ?????? ??? ?? ??????. ??? ? ??? ?? ? ??? ???? ??? ?? ?? ???? ?? ?? ?????. ?? ??? ??? ??? ???? ?? ???? ?????, ?? ??????? ??? ?? ?? ? ????.
???? ?????? ??? ??? ??? ????? ??? ? ?? ??? ???????.
??? ?? ??? ???? ??? ????? 3, 4? ???? C? ??? ???? A, B? ?? ??? C? ?? ???? ????. ??? ?? Reactive Programming ? ?? ???? ?????.
??????, Reactive ?? C = A + B ?? ??? ?? ?? ??? ?? ??? ??? ??? ?? ????. ????, ???procedural, ???imperative?? ?? ???declarative??, ???? ??? ?? ?? ???? ??? ??? ????. ????? ??? ????? ?? ??? C = A + B ?? ?? A, B? ?? ??? ???? C? ?? ???? ???.
?, ????? ???? ???? ???? ?? ?? ?? ??? ????? ?? ??? ??? ??? ????, ??? ??? ?? ???? ??? ?? ? ????. ???? ?? ??? ?? ??? ?? ?? ????.
?? ??? ???? ????? ????. ??? ¡®????¡¯?? ??? ??? ?? ????. ?? ??? ?? ????? CPU? ?? ???? ??? ???, ?? ????? ??? ??? ???? Verilog ?? ???? ?????? ?????? ?????.
???? ???? ??? ??? ??? ??? ???? ??? ?? ???? ??? ??? ?? ??? ??? ?????.
?? ?? ?? ??? ??? ???? ?? ?? ??? ?? ???? ???? ?? ???? ?? ???? ?? ?? ?? ?? ?? ????? ???? ???? ?? ???. ??? ??? ????? ???? ???? ???? ??? ?? ???? ?? ?????? ??? ????? ?????.
??????? ¡°????? ????£¢??? ???? ?? ????? ????? ????? ???, ?? ? ? ?? ????. ?? ?????? ???? ???? ?? ??? ??? ?? ????, ? ? ?? ????? ???? ???? ???? ??? ?? ???????.
?? ?? ??? ? ????? ?? ???? ???? ?? ????? ?? ??? ????? ???Imperative ???. ???? ???? ??? ?? ???? ??? ??? ????. ????? ??? ?? ???? ?? ??? ????? ??? ????? ??? ??? ?????.
C ??? ????? ?? ?? ??? ??? ?????, ??? ???? ???? ??? ? ???? ? ? ???. ??? C? ??? ???? ????? ?? ??? ???? ??? ???? ?? ??? ???, ????? ?? ???? ???? ¡°????? ?? ¡°? ?????.
??? ??? C++, Java, C# ? ?? ???? ????? ???? ? ? ?? ????? ???? ?????. ? ???? ??? ???? ??? ??? ?????? ????. ??? ? ???, ????? ????? ??? ?? ???? ? ? ?? ? ????.
??? ???? ?????? ?? ??? ??? ?? ?? ??????.
??? ??? ??? ??? ??? ??? ???? ???? ??? ???? ?????? ??? ?? ????? ??????? ? ? ?????. ?? ????? ??? ??? ?? ????? ????
? ??? ???? ?? ???? ??? ??? ???? ????, ???? ????? ???? ?? ?? ?? ???? ??? ???? ???? ??? ??? ??? ?? ? ??? ?????.
??? ??? ? ? ????? ???? ????? ?? ??, ??? ???? ????? ???.
? ? ??? ??? ?? Event-Driven ? ?? ????? ???. Event-Driven ? ???? ??? ??? ?? ??? ?????.
??? ?? ??? ??? ?? ??? ?????. ??? ??? ???. ? ??? ????? ???? ???, ??? ???? ??? ?? ??? ? ??? ??? ???? ????? ?? ?? ???? ????. ??? ???? ????? ????? ??? ?? ?? ???? ??? ???? ???? ???,
??? ????? ? ? ?? ?????? ?? ??????? ???? ?? ???. ?? ??? ?? ?? ??? ??? ???? ? ???, ???? ??? ?? ??? ???? ????. ? ??? ???? ??? ???? ??? ???? ?? ????, ?? ??? ???? ? ???? ???? ??? ???. ??? ?? ??? ??? ???? ???? ??? ??? ??? ??????.
?? ??? ??? ?? ????? ???????? ??? ?? ??? ?????. ??? ? ????? ???? 1000? ??? ??? ? ????.
??? ?????? ??? ?? ??? ????????? ??? ??? ? ? ?? ???. ???? ????? ??? 4?? ???? ??? ?? ?? ? ???. ??? ? ? ???? ????? ??? ??? ??? ???? ???? ?? ??? ????? ?? ???? ??? ??? ?? ???.
Event Driven ??? ?? ?? ?? ??? ?? ???? ????? ?????. ???? ??? ??? ?? ?????. ?? ??? ?????? ??? ???? ?? ?? ??????? ? ??? IOCP? ????? ?? ??? ??? ??. ¡ ??? ? NodeJS? VertX? ???? ??? ?? ???.
??? ??? ?? ??? ??? ?? ?? ???.
NodeJS? ?? ???? ?? ?? ??? ?????. ??? ??? ??,
?? ???? ??? ??? 3? ??? ??? ??, ?? ??? ?? ?? ?? ?? ?? ??? ???? ???. ? ????? ?????? ????? ??? ????? ??? ? ?? ??? ??????. NodeJS API?? ? ?? ??? ?? ??? ????? ?? ?? ??? ??? ?? ??? ?? ??, ??? ? ?????? ???? ??? ???? ?? ?? ? ?? ????? ???? ?? ???? ???? ???? ???.
??? ??? ?? ??? ??? ??? ??? ?? ???,
?? M ?? ??? ??? ? ????.
? M?? ?? ??? ???? ????? ?????.
??? ?????? ??? ?? ??? ????? ????? ??? ??. ??? ??? ??? ???? ??? ???? ????? ? ? ??? ???,
???? ???? ???????.
??? ? ???? ???? ??? ??? ? ??? ???? ???? ?? ?????.
????? ? ? ??? ??? ?? Event-Driven ? ?? ????? ???.
?????? ????? , ?? ?? ???? NodeJS? ??? ???, ?????????? ?????? ?? ?? MVVM ?????? ???? ?????? ??? ???? ????. Q Promise?? ?? ????, Javascript Promise?? ??? ???? ???, Rx? ?????? ??? ?? ????.
?? ?? ???? ?? ??? ?? Dart? ?? ???? Future? ??? ???? ?????. ?? ??? ??? ?? ? ??.
FRP ???? ???? ??? 3D ????? ??? ? ?? ELM?? ??? ????. ????? ??? ?? ???? ????? ??? ??? ??? ? ? ??? ??????.