-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclojurescript.html
776 lines (692 loc) · 30.9 KB
/
clojurescript.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>ClojureScript + Reagent + Reframe</title>
<meta name="author" content="(김동우)"/>
<style type="text/css">
.underline { text-decoration: underline; }
</style>
<link rel="stylesheet" href="./css/reveal.css"/>
<link rel="stylesheet" href="./css/theme/moon.css" id="theme"/>
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = './css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<section id="slide-org46c0c1e">
<h2 id="org46c0c1e">ClojureScript + Reagent + Reframe</h2>
<div class="outline-text-2" id="text-org46c0c1e">
</div></section>
<section id="slide-org813e9b0">
<h3 id="org813e9b0">vs</h3>
<p>
Javascript + React + Redux
</p>
</section>
</section>
<section>
<section id="slide-orgc6163ba">
<h2 id="orgc6163ba">Clojure</h2>
<ul>
<li>함수형 언어 : 불변(Immutable) 데이터 형 + 일급 함수</li>
<li>발전된 Lisp : code-as-data 패러다임을 map과 vector까지 확장</li>
<li>다형성(Polymorphism) 지원</li>
<li>동적(Dynamic) 언어</li>
<li>JVM 환경에서 실행 (기생 언어)</li>
</ul>
</section>
</section>
<section>
<section id="slide-org5479bbd">
<h2 id="org5479bbd">Why Clojure?</h2>
<div class="outline-text-2" id="text-org5479bbd">
</div></section>
<section id="slide-orgf57ba6f">
<h3 id="orgf57ba6f">by Official Rational</h3>
<ul>
<li>A Lisp</li>
<li>for Functional Programming</li>
<li>symbiotic with an established Platform</li>
<li>designed for Concurrency</li>
</ul>
</section>
<section id="slide-org5c5a1c0">
<h3 id="org5c5a1c0">by Uncle Bob</h3>
<ul>
<li>함수형 언어 : 멀티 스레딩 프로그래밍의 어려움 해결</li>
<li>Lisp : 간결한 문법. Homoiconic</li>
<li>JVM 환경에서 실행 : 기존 Java 코드와 호환.</li>
<li>STM 지원 : 동시성 문제 해결</li>
<li>성능 : 메모리를 공유하는 불변 데이터 구조 사용</li>
<li>지원 : 커뮤니티와 다양한 도구들</li>
</ul>
</section>
</section>
<section>
<section id="slide-org41224bf">
<h2 id="org41224bf">Javascript</h2>
<ul>
<li>동적 / 약한 타입의 언어</li>
<li>멀티 패러다임 언어 : 객체지향 + 절차형 + 함수형</li>
<li>인터프리터 언어 (JIT)</li>
</ul>
</section>
<section id="slide-orgab4380d">
<h3 id="orgab4380d">Influenced by</h3>
<ul>
<li>C : 문법 (if, while, for, switch …), statement 와 expression 구분</li>
<li>Java : 문법 (new…), 기본 라이브러리 API (Math, Date…)</li>
<li>Scheme : Closure, Lexical Scope, 일급함수, 동적 타입, (eval?)</li>
<li>Self : Prototype 상속</li>
</ul>
</section>
<section id="slide-orgeec5a3f">
<h3 id="orgeec5a3f">Most Popular Language</h3>
<ul>
<li>브라우저 환경에서 사용할 수 있는 유일한 언어
<ul>
<li>일명, 웹 환경에서의 어셈블리 언어</li>
<li>(하지만.. WebAssembly가 나온다면?)</li>
</ul></li>
<li>Node.js : 백엔드 개발</li>
<li>Electron : PC 어플리케이션 개발</li>
<li>React Native : 네이티브 모바일 어플리케이션 개발</li>
</ul>
</section>
<section id="slide-org64352fe">
<h3 id="org64352fe">Most blamed Langauge</h3>
<ul>
<li><a href="https://medium.com/javascript-non-grata/javascript-is-a-dysfunctional-programming-language-a1f4866e186f">https://medium.com/javascript-non-grata/javascript-is-a-dysfunctional-programming-language-a1f4866e186f</a></li>
<li>wtfjs</li>
<li>JavaScript Garden</li>
<li>JavaScript Gotchas</li>
<li>Common JavaScript Errors</li>
</ul>
</section>
</section>
<section>
<section id="slide-org3c8ece4">
<h2 id="org3c8ece4">Compile to Javascript</h2>
<div class="outline-text-2" id="text-org3c8ece4">
</div></section>
<section id="slide-orgcf5770f">
<h3 id="orgcf5770f">Google Web Toolkit (2006)</h3>
<p>
Java를 Javascript로 변환. Google 개발
</p>
</section>
<section id="slide-org5fb9d00">
<h3 id="org5fb9d00">CoffeeScript (2009)</h3>
<p>
간결한 Javascript. Ruby, Python 등의 영향
</p>
</section>
<section id="slide-org4c11230">
<h3 id="org4c11230">Dart (2011)</h3>
<p>
개션된 Javascript. 기본 라이브러리 강화. Google 개발
</p>
</section>
<section id="slide-org8eb23a1">
<h3 id="org8eb23a1">ClojureScript (2011)</h3>
<p>
Clojure를 Javascript로 변환
</p>
</section>
<section id="slide-org64cdcb5">
<h3 id="org64cdcb5">TypeScript (2012)</h3>
<p>
Javascript의 Superset. 타입시스템 도입
</p>
</section>
<section id="slide-orgdbe7773">
<h3 id="orgdbe7773">Elm (2012)</h3>
<p>
정적 타입, 순수 함수형 언어. No runtime Exception
</p>
</section>
<section id="slide-org12e53b2">
<h3 id="org12e53b2">PureScript (2013)</h3>
<p>
정적 타입, 순수 함수형 언어. Haskell 영향
</p>
</section>
<section id="slide-orgb73aeae">
<h3 id="orgb73aeae">BuckleScript (2016)</h3>
<p>
Ocaml 을 Javascript 로 변환
</p>
</section>
<section id="slide-org1159b13">
<h3 id="org1159b13">Reason (2016)</h3>
<p>
Ocaml과 호환. BuckleScript를 이용. Facebook 개발
</p>
</section>
</section>
<section>
<section id="slide-org470914d">
<h2 id="org470914d">ClojureScript</h2>
<ul>
<li>Clojure 코드를 Javascript 로 변환시켜 주는 컴파일러</li>
<li>Clojure 로 작성됨 -> 컴파일을 위해 JVM 환경 필요 (크로스 컴파일러)</li>
<li>구글 ClosureCompiler 사용 -> 생성된 Javascript 파일을 최적화</li>
</ul>
</section>
</section>
<section>
<section id="slide-org6bd2bb5">
<h2 id="org6bd2bb5">Clojure vs ClojureScript</h2>
<ul>
<li>확장자 : clj (Clojure) / cljs (ClojureScript ) / cljs (All)</li>
<li>Numbers : 자바스크립트 Number 와 동일</li>
<li>단일 문자형 없음, 모두 문자열</li>
<li>Refs, Transactions, Agents 지원 안됨</li>
<li>정규식 지원 방식은 Javascript 와 동일</li>
<li>매크로 작성시 런타임 환경과 별도로 컴파일 되어야 함
<ul>
<li>Computat ergo est: 클로저스트립트에서 매크로 작성시 주의점</li>
</ul></li>
</ul>
</section>
</section>
<section>
<section id="slide-org4b20209">
<h2 id="org4b20209">Google Closure Compiler</h2>
<ul>
<li>ClojureCompiler ClosureCompiler (스펠링 주의)</li>
<li>기존의 Javascript 코드를 최적화해서 새로운 Javascript 코드를 생성
<ul>
<li>Dead Code Elimination</li>
<li>Minify & Mangle</li>
<li>Code Spliting</li>
</ul></li>
<li>JSDoc 을 활용해서 코드 최적화에 필요한 정보를 얻음</li>
</ul>
</section>
</section>
<section>
<section id="slide-org777ff2a">
<h2 id="org777ff2a">Google Clojure Library</h2>
<ul>
<li>Google 내부의 서비스에 사용되는 오픈소스 라이브러리 셋</li>
<li>브라우저 호환성, 네임스페이스, OOP, Math, String, DOM 등 다양한 기능 제공</li>
<li>ClojureScript 컴파일러가 생성하는 코드에서 사용됨</li>
<li>Closure Compiler에 최적화됨</li>
</ul>
</section>
</section>
<section>
<section id="slide-orge2a1c18">
<h2 id="orge2a1c18">JS vs CLJS (Similarities)</h2>
<ul>
<li>First Class Function</li>
<li>Dynamic Typing</li>
<li>Anonymous function (Lambda Expression)</li>
<li>Closure & Lexical Scoping</li>
<li>Literal (JS: Object/Array, CLJS: Map/Vector/Set/List)</li>
<li>Destructuring</li>
<li>Rest Arguments</li>
<li>Numbers & String</li>
</ul>
</section>
</section>
<section>
<section id="slide-orgd10ce65">
<h2 id="orgd10ce65">JS vs CLJS (differences)</h2>
<div class="outline-text-2" id="text-orgd10ce65">
</div></section>
<section id="slide-org3674c7f">
<h3 id="org3674c7f">Mutable vs Immutable</h3>
<div class="outline-text-3" id="text-org3674c7f">
</div></section>
<section id="slide-org4752e8f">
<h4 id="org4752e8f">JavaScript</h4>
<div class="org-src-container">
<pre class="src src-js"><span style="color: #F0DFAF; font-weight: bold;">var</span> <span style="color: #DFAF8F;">state</span> = <span style="color: #DCDCCC;">{</span>
count: <span style="color: #BFEBBF;">0</span>
<span style="color: #DCDCCC;">}</span>;
state.count = state.count + <span style="color: #BFEBBF;">1</span>;
</pre>
</div>
</section>
<section id="slide-org9c5b0f6">
<h4 id="org9c5b0f6">ClojureScript</h4>
<div class="org-src-container">
<pre class="src src-clojure">(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">state</span> (atom {<span style="color: #BFEBBF;">:count</span> <span style="color: #BFEBBF;">0</span><span style="color: #666666;">}))</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">updating the state</span>
(swap! state #(update <span style="color: #DFAF8F;">%</span> <span style="color: #BFEBBF;">:count</span> inc<span style="color: #666666;">))</span>
</pre>
</div>
</section>
<section id="slide-orgcb22d68">
<h3 id="orgcb22d68">Reference vs Value</h3>
<div class="outline-text-3" id="text-orgcb22d68">
</div></section>
<section id="slide-orgdc5651d">
<h4 id="orgdc5651d">Javascript</h4>
<div class="org-src-container">
<pre class="src src-js"><span style="color: #F0DFAF; font-weight: bold;">const</span> <span style="color: #DFAF8F;">personA</span> = <span style="color: #DCDCCC;">{</span>
age: <span style="color: #BFEBBF;">32</span>,
name: <span style="color: #BFEBBF;">{</span>first: <span style="color: #CC9393;">'John'</span>, last: <span style="color: #CC9393;">'Doe'</span><span style="color: #BFEBBF;">}</span>
<span style="color: #DCDCCC;">}</span>;
<span style="color: #F0DFAF; font-weight: bold;">const</span> <span style="color: #DFAF8F;">personB</span> = <span style="color: #DCDCCC;">{</span>
age: <span style="color: #BFEBBF;">32</span>,
name: <span style="color: #BFEBBF;">{</span>first: <span style="color: #CC9393;">'John'</span>, last; <span style="color: #CC9393;">'Doe'</span><span style="color: #BFEBBF;">}</span>
<span style="color: #DCDCCC;">}</span>
console.log<span style="color: #DCDCCC;">(</span>personA === personB<span style="color: #DCDCCC;">)</span>;
</pre>
</div>
</section>
<section id="slide-org494ca18">
<h4 id="org494ca18">ClojureScript</h4>
<div class="org-src-container">
<pre class="src src-clojure">(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">person-a</span> {<span style="color: #BFEBBF;">:age</span> <span style="color: #BFEBBF;">32</span>
<span style="color: #BFEBBF;">:name</span> {<span style="color: #BFEBBF;">:first</span> <span style="color: #CC9393;">"John"</span> <span style="color: #BFEBBF;">:last</span> <span style="color: #CC9393;">"Doe"</span><span style="color: #666666;">}})</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">person-b</span> {<span style="color: #BFEBBF;">:age</span> <span style="color: #BFEBBF;">32</span>
<span style="color: #BFEBBF;">:name</span> {<span style="color: #BFEBBF;">:first</span> <span style="color: #CC9393;">"John"</span> <span style="color: #BFEBBF;">:last</span> <span style="color: #CC9393;">"Doe"</span><span style="color: #666666;">}})</span>
(println (= person-a person-b<span style="color: #666666;">))</span>
</pre>
</div>
</section>
<section id="slide-orgf6ef6bb">
<h3 id="orgf6ef6bb">Modules vs Namespace</h3>
<div class="outline-text-3" id="text-orgf6ef6bb">
</div></section>
<section id="slide-org84f9596">
<h4 id="org84f9596">Javascirpt</h4>
<ul>
<li>CommonJS / ES6 Module</li>
</ul>
<div class="org-src-container">
<pre class="src src-js"><span style="color: #5F7F5F;">// </span><span style="color: #7F9F7F;">my/math.js</span>
<span style="color: #F0DFAF; font-weight: bold;">export</span> <span style="color: #F0DFAF; font-weight: bold;">function</span> sum<span style="color: #DCDCCC;">(</span><span style="color: #DFAF8F;">a</span>, <span style="color: #DFAF8F;">b</span><span style="color: #DCDCCC;">)</span> <span style="color: #DCDCCC;">{</span>
<span style="color: #F0DFAF; font-weight: bold;">return</span> a + b;
<span style="color: #DCDCCC;">}</span>
<span style="color: #5F7F5F;">// </span><span style="color: #7F9F7F;">my/app.js</span>
<span style="color: #F0DFAF; font-weight: bold;">import</span> <span style="color: #DCDCCC;">{</span>sum<span style="color: #DCDCCC;">}</span> from <span style="color: #CC9393;">'./math'</span>;
<span style="color: #F0DFAF; font-weight: bold;">const</span> <span style="color: #DFAF8F;">result</span> = sum<span style="color: #DCDCCC;">(</span><span style="color: #BFEBBF;">10</span> + <span style="color: #BFEBBF;">20</span><span style="color: #DCDCCC;">)</span>;
</pre>
</div>
</section>
<section id="slide-org8d4b4fd">
<h4 id="org8d4b4fd">ClojureScript</h4>
<ul>
<li>namespace</li>
</ul>
<div class="org-src-container">
<pre class="src src-clojure"><span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">my/math.cljs</span>
(<span style="color: #F0DFAF; font-weight: bold;">ns</span> <span style="color: #7CB8BB;">my.math</span><span style="color: #666666;">)</span>
(<span style="color: #F0DFAF; font-weight: bold;">defn</span> <span style="color: #93E0E3;">sum</span> [a b<span style="color: #666666;">]</span>
(+ a b<span style="color: #666666;">))</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">my/app.cljs</span>
(<span style="color: #F0DFAF; font-weight: bold;">ns</span> <span style="color: #7CB8BB;">my.app</span>
(<span style="color: #BFEBBF;">:require</span> [<span style="color: #7CB8BB;">my.math</span> <span style="color: #BFEBBF;">:refer</span> [sum<span style="color: #666666;">]]))</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">result</span> (sum <span style="color: #BFEBBF;">10</span> <span style="color: #BFEBBF;">20</span><span style="color: #666666;">))</span>
</pre>
</div>
</section>
<section id="slide-org54ec2f5">
<h3 id="org54ec2f5">OOP(Class) vs Protocol</h3>
</section>
<section id="slide-orgd8d180d">
<h3 id="orgd8d180d">Generator vs core.async</h3>
</section>
</section>
<section>
<section id="slide-orgc49b860">
<h2 id="orgc49b860">Tooling</h2>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left"> </th>
<th scope="col" class="org-left">Javascript</th>
<th scope="col" class="org-left">ClojureScript</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">Package Managemant</td>
<td class="org-left">npm / yarn</td>
<td class="org-left">Leiningen / Boot</td>
</tr>
<tr>
<td class="org-left">Scaffolding</td>
<td class="org-left">Yeoman / …</td>
<td class="org-left">Leiningen / Boot</td>
</tr>
<tr>
<td class="org-left">Compile (Transpile)</td>
<td class="org-left">Babel / TypeScript</td>
<td class="org-left">Leiningen / Boot</td>
</tr>
<tr>
<td class="org-left">Build</td>
<td class="org-left">Webpack / Rollup</td>
<td class="org-left">Leiningen / Boot</td>
</tr>
<tr>
<td class="org-left">Interactive Programming</td>
<td class="org-left">Webpack Dev Server</td>
<td class="org-left">Figwheel / REPL</td>
</tr>
<tr>
<td class="org-left">Static Code Analizer</td>
<td class="org-left">ESLint</td>
<td class="org-left">Kibit</td>
</tr>
</tbody>
</table>
</section>
</section>
<section>
<section id="slide-org05e5a09">
<h2 id="org05e5a09">Interop</h2>
<div class="outline-text-2" id="text-org05e5a09">
</div></section>
<section id="slide-org0ff1904">
<h3 id="org0ff1904">Global Variables / APIs</h3>
<div class="org-src-container">
<pre class="src src-clojurescript">(<span style="color: #7CB8BB;">js</span><span style="color: #DCDCCC; background-color: #3F3F3F;">/</span>alert <span style="color: #CC9393;">"Hello"</span><span style="color: #666666;">)</span>
(<span style="color: #7CB8BB;">js</span><span style="color: #DCDCCC; background-color: #3F3F3F;">/</span>document.getElementById <span style="color: #CC9393;">"app"</span><span style="color: #666666;">)</span>
(<span style="color: #7CB8BB;">js</span><span style="color: #DCDCCC; background-color: #3F3F3F;">/</span>document.body.lastChild.innerHTML.charAt <span style="color: #BFEBBF;">7</span><span style="color: #666666;">)</span>
(<span style="color: #7CB8BB;">js</span><span style="color: #DCDCCC; background-color: #3F3F3F;">/</span>some.of.my.libraries.api.method <span style="color: #CC9393;">"args"</span><span style="color: #666666;">)</span>
(<span style="color: #7CB8BB;">js</span><span style="color: #DCDCCC; background-color: #3F3F3F;">/</span>$.ajax #js {<span style="color: #BFEBBF;">:url</span> <span style="color: #CC9393;">"/"</span>
<span style="color: #BFEBBF;">:success</span> (<span style="color: #F0DFAF; font-weight: bold;">fn</span> [res] (<span style="color: #7CB8BB;">js</span><span style="color: #DCDCCC; background-color: #3F3F3F;">/</span>console.log res<span style="color: #666666;">))})</span>
</pre>
</div>
</section>
<section id="slide-org87623cd">
<h3 id="org87623cd">Method Call / Property Access</h3>
<div class="org-src-container">
<pre class="src src-clojure"><span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">same as javacript string</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">s</span> <span style="color: #9FC59F;">"Hello Clojure"</span><span style="color: #666666;">)</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">method call</span>
(<span style="color: #94BFF3;">.toUpperCase</span> s) <span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">"HELLO CLOJURE"</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">property access</span>
(<span style="color: #94BFF3;">.-length</span> s) <span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">13</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">chaning</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">my-div</span> (<span style="color: #7CB8BB;">js</span><span style="color: #DCDCCC; background-color: #3F3F3F;">/</span>document.querySelector <span style="color: #CC9393;">"div"</span><span style="color: #666666;">))</span>
(<span style="color: #94BFF3;">.-length</span> (<span style="color: #94BFF3;">.toUpperCase</span> (<span style="color: #94BFF3;">.-innerHTML</span> my-div<span style="color: #666666;">)))</span>
(<span style="color: #F0DFAF; font-weight: bold;">->></span> my-div <span style="color: #94BFF3;">.-innerHTML</span> <span style="color: #94BFF3;">.toUpperCase</span> <span style="color: #94BFF3;">.-length</span><span style="color: #666666;">)</span>
(<span style="color: #F0DFAF; font-weight: bold;">..</span> my-div -innerHTML <span style="color: #94BFF3;">toUpperCase</span> -length<span style="color: #666666;">)</span>
</pre>
</div>
</section>
<section id="slide-orga204bcb">
<h3 id="orga204bcb">Object / Array</h3>
<div class="org-src-container">
<pre class="src src-clojure"><span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">macro</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">arr</span> (array <span style="color: #BFEBBF;">1</span> <span style="color: #BFEBBF;">2</span> <span style="color: #BFEBBF;">3</span><span style="color: #666666;">))</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">obj</span> (js-obj <span style="color: #CC9393;">"x"</span> <span style="color: #BFEBBF;">1</span> <span style="color: #CC9393;">"y"</span> <span style="color: #BFEBBF;">2</span><span style="color: #666666;">))</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">reader literal</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">arr</span> #js [<span style="color: #BFEBBF;">1</span> <span style="color: #BFEBBF;">2</span> <span style="color: #BFEBBF;">3</span><span style="color: #666666;">])</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">obj</span> #js {<span style="color: #BFEBBF;">:x</span> <span style="color: #BFEBBF;">1</span> <span style="color: #BFEBBF;">:y</span> <span style="color: #BFEBBF;">2</span><span style="color: #666666;">})</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">clj -> js function</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">arr</span> (clj->js [<span style="color: #BFEBBF;">1</span> <span style="color: #BFEBBF;">2</span> <span style="color: #BFEBBF;">3</span><span style="color: #666666;">]))</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">obj</span> (clj->js {<span style="color: #BFEBBF;">:x</span> <span style="color: #BFEBBF;">1</span> <span style="color: #BFEBBF;">:y</span> <span style="color: #BFEBBF;">2</span><span style="color: #666666;">}))</span>
<span style="color: #5F7F5F;">;; </span><span style="color: #7F9F7F;">jc -> clj function</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">arr-clj</span> (js->clj arr<span style="color: #666666;">))</span>
(<span style="color: #F0DFAF; font-weight: bold;">def</span> <span style="color: #DFAF8F;">obj-clj</span> (js->clj obj<span style="color: #666666;">))</span>
</pre>
</div>
</section>
</section>
<section>
<section id="slide-org567d14e">
<h2 id="org567d14e">ClojureScript -> Javascript</h2>
<ul>
<li>Live Coding : <a href="http://app.klipse.tech/">http://app.klipse.tech/</a></li>
</ul>
</section>
</section>
<section>
<section id="slide-org83ccfee">
<h2 id="org83ccfee">Javascript Modules</h2>
<ul>
<li>CLJSJS</li>
<li>npm-deps</li>
</ul>
</section>
</section>
<section>
<section id="slide-org3771b50">
<h2 id="org3771b50">Who's using ClojureScript?</h2>
<ul>
<li><a href="https://github.com/clojure/clojurescript/wiki/Companies-Using-ClojureScript">https://github.com/clojure/clojurescript/wiki/Companies-Using-ClojureScript</a></li>
<li><a href="https://circleci.com/">https://circleci.com/</a></li>
<li><a href="https://precursorapp.com/">https://precursorapp.com/</a></li>
<li></li>
</ul>
</section>
</section>
<section>
<section id="slide-orgc95a69b">
<h2 id="orgc95a69b">React</h2>
<div class="outline-text-2" id="text-orgc95a69b">
</div></section>
<section id="slide-org779d33e">
<h3 id="org779d33e">Declarative</h3>
<ul>
<li>Imperative -> Declarative</li>
<li>Virtual-DOM (Reconcilation)</li>
<li>DOM을 직접 다루지 않고, 가상 DOM의 구조를 반환</li>
</ul>
</section>
<section id="slide-orgfb19cad">
<h3 id="orgfb19cad">Component-Based</h3>
<ul>
<li>Component를 합성하여 UI 구성</li>
<li>Template(X) -> JSX (Javascript Data Structure)</li>
</ul>
</section>
<section id="slide-orgb3d2b32">
<h3 id="orgb3d2b32">Learn Once, Write Anywhere</h3>
<ul>
<li>React Native</li>
<li>React VR</li>
</ul>
</section>
</section>
<section>
<section id="slide-org4edd161">
<h2 id="org4edd161">React - Functional Approch</h2>
<div class="outline-text-2" id="text-org4edd161">
</div></section>
<section id="slide-org45e0222">
<h3 id="org45e0222">Component = (Pure) Function</h3>
<ul>
<li>Input : Props</li>
<li>Ouput : V-DOM(React Element) Tree</li>
</ul>
<blockquote nil>
<p>
All React components must act like pure functions with respect to their props.
</p>
</blockquote>
</section>
<section id="slide-org6822d27">
<h3 id="org6822d27">Immutable Props</h3>
<ul>
<li>Props는 Read-Only</li>
</ul>
<blockquote nil>
<p>
Whether you declare a component as a function or a class,
it must never modify its own props
</p>
</blockquote>
</section>
<section id="slide-org9bb9187">
<h3 id="org9bb9187">Immutable State</h3>
<ul>
<li><code>this.state</code> 직접 변경 불가</li>
<li><code>setState()</code> 를 통한 명시적 변경</li>
</ul>
<blockquote nil>
<p>
Never mutate this.state directly,
as calling setState() afterwards may replace the mutation you made.
Treat this.state as if it were immutable.
</p>
</blockquote>
</section>
<section id="slide-org7f93bdd">
<h3 id="org7f93bdd">Immutability for Performance</h3>
<ul>
<li>shouldComponentUpdate()</li>
<li>Deep Equal 비교를 할 필요 없이 Shallow 비교</li>
</ul>
<div class="org-src-container">
<pre class="src src-js"><span style="color: #F0DFAF; font-weight: bold;">class</span> MyComponent <span style="color: #F0DFAF; font-weight: bold;">extends</span> React.Component <span style="color: #DCDCCC;">{</span>
shouldComponentUpdate<span style="color: #BFEBBF;">(</span>nextProps, nextState<span style="color: #BFEBBF;">)</span> <span style="color: #BFEBBF;">{</span>
<span style="color: #F0DFAF; font-weight: bold;">return</span> shallowCompare<span style="color: #D0BF8F;">(</span><span style="color: #BFEBBF;">this</span>, nextProps, nextState<span style="color: #D0BF8F;">)</span>;
<span style="color: #BFEBBF;">}</span>
render<span style="color: #BFEBBF;">()</span> <span style="color: #BFEBBF;">{</span>
<span style="color: #F0DFAF; font-weight: bold;">return</span> <div className=<span style="color: #D0BF8F;">{</span><span style="color: #BFEBBF;">this</span>.props.className<span style="color: #D0BF8F;">}</span>>foo</div>;
<span style="color: #BFEBBF;">}</span>
<span style="color: #DCDCCC;">}</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js"><span style="color: #F0DFAF; font-weight: bold;">class</span> MyComponent <span style="color: #F0DFAF; font-weight: bold;">extends</span> React.PureComponent <span style="color: #DCDCCC;">{</span>
render<span style="color: #BFEBBF;">()</span> <span style="color: #BFEBBF;">{</span>
<span style="color: #F0DFAF; font-weight: bold;">return</span> <div className=<span style="color: #D0BF8F;">{</span><span style="color: #BFEBBF;">this</span>.props.className<span style="color: #D0BF8F;">}</span>>foo</div>;
<span style="color: #BFEBBF;">}</span>
<span style="color: #DCDCCC;">}</span>
</pre>
</div>
</section>
</section>
<section>
<section id="slide-orge0ed66c">
<h2 id="orge0ed66c">React - Sample Code</h2>
</section>
</section>
<section>
<section id="slide-org827e34d">
<h2 id="org827e34d">Reagent : Simple React Wrapper</h2>
<ul>
<li>Minimalistic interface between ClojureScript and React.</li>
<li>JSX 대신 Hickup 형식의 문법 사용</li>
<li>State 관리를 위한 Ratom 제공</li>
</ul>
</section>
</section>
<section>
<section id="slide-org55e5946">
<h2 id="org55e5946">React vs Reagent</h2>
<div class="outline-text-2" id="text-org55e5946">
</div></section>
<section id="slide-orgd7c1b09">
<h3 id="orgd7c1b09">Simple Component</h3>
<div class="outline-text-3" id="text-orgd7c1b09">
</div></section>
<section id="slide-org874f65b">
<h4 id="org874f65b">React</h4>
<div class="org-src-container">
<pre class="src src-js"><span style="color: #F0DFAF; font-weight: bold;">function</span> <span style="color: #93E0E3;">simpleComponent</span><span style="color: #DCDCCC;">()</span> <span style="color: #DCDCCC;">{</span>
<span style="color: #F0DFAF; font-weight: bold;">return</span> <span style="color: #BFEBBF;">(</span>
<div>
<p>I am a component!</p>
<p className=<span style="color: #CC9393;">"someclass"</span>>
I have
<strong>bold</strong>
<span style=<span style="color: #D0BF8F;">{</span><span style="color: #93E0E3;">{</span>color: <span style="color: #CC9393;">"red"</span><span style="color: #93E0E3;">}</span><span style="color: #D0BF8F;">}</span>> and red</span>
text.
</p>
</div>
<span style="color: #BFEBBF;">)</span>
<span style="color: #DCDCCC;">}</span>
</pre>
</div>
</section>
<section id="slide-orgf038901">
<h4 id="orgf038901">Reagent</h4>
<div class="org-src-container">
<pre class="src src-clojure">(<span style="color: #F0DFAF; font-weight: bold;">defn</span> <span style="color: #93E0E3;">simple-component</span> [<span style="color: #666666;">]</span>
[<span style="color: #BFEBBF;">:div</span>
[<span style="color: #BFEBBF;">:p</span> <span style="color: #CC9393;">"I am a component!"</span><span style="color: #666666;">]</span>
[<span style="color: #BFEBBF;">:p.someclass</span>
<span style="color: #CC9393;">"I have "</span>
[<span style="color: #BFEBBF;">:strong</span> <span style="color: #CC9393;">"bold"</span><span style="color: #666666;">]</span>
[<span style="color: #BFEBBF;">:span</span> {<span style="color: #BFEBBF;">:style</span> {<span style="color: #BFEBBF;">:color</span> <span style="color: #CC9393;">"red"</span>}} <span style="color: #CC9393;">" and red "</span>]
<span style="color: #CC9393;">"text."</span><span style="color: #666666;">]])</span>
</pre>
</div>
</section>
<section id="slide-org6300180">
<h3 id="org6300180">Nested Component</h3>
<div class="outline-text-3" id="text-org6300180">
</div></section>
<section id="slide-orgbe334da">
<h4 id="orgbe334da">React</h4>
<div class="org-src-container">
<pre class="src src-js"><span style="color: #F0DFAF; font-weight: bold;">function</span> <span style="color: #93E0E3;">simpleParent</span><span style="color: #DCDCCC;">()</span> <span style="color: #DCDCCC;">{</span>
<span style="color: #DCDCCC;">}</span>
</pre>
</div>
</section>
<section id="slide-org0eedc73">
<h4 id="org0eedc73">Reagent</h4>
<div class="org-src-container">
<pre class="src src-clojure">(<span style="color: #F0DFAF; font-weight: bold;">defn</span> <span style="color: #93E0E3;">simple-parent</span> [<span style="color: #666666;">]</span>
[<span style="color: #BFEBBF;">:div</span>
[<span style="color: #BFEBBF;">:p</span> <span style="color: #CC9393;">"I include simple-component."</span><span style="color: #666666;">]</span>
[simple-component<span style="color: #666666;">]])</span>
</pre>
</div>
</section>
</section>
</div>
</div>
<script src="./lib/js/head.min.js"></script>
<script src="./js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: false,
center: true,
slideNumber: 'c',
rollingLinks: false,
keyboard: true,
overview: true,
margin: 0.10,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/fade/none
transitionSpeed: 'default',
multiplex: {
secret: '', // null if client
id: '', // id, obtained from socket.io server
url: '' // Location of socket.io server
},
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: './lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: './plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: './plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: './plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: './plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }]
});
</script>
</body>
</html>