Veha Suwatphisankij
!@#@$^&%&
clojurescript course
detective game
slide url: http://tiny.cc/cljsl
clojurescript course : agenda
09:00 play game & install clojure & editor
09:30 basic clojurescript : data, pure function, lisp
12:00 lunch
13:00 play more game & install clojure & editor
13:15 reagent & reframe
16:00 play even more game
16:15 more clojurescript : interop, protocol
more learning source
slide url: http://tiny.cc/cljsl
detective game
สรุป
1 คนเราสามารถสร้างความเข้าใจ
หรือสมมุติฐานที่อาจ ไม่ถูกต้องได้ง่ายมาก
2 ทุกคนพร้อมรับฟังสิ่งที่เราสงสัย
ผมพูดอะไรไม่รู้เรื่อง ถามได้เลย
slide url: http://tiny.cc/cljsl
install java & lein
installation
online editor :
Clojure is a dynamic, general-purpose programming language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming. Clojure is a compiled language, yet remains completely dynamic – every feature supported by Clojure is supported at runtime. Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.
Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures. When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.
I hope you find Clojure's combination of facilities elegant, powerful, practical and fun to use.
Rich Hickey
author of Clojure and CTO Cognitect
real value : ความจริงยังไง ก็ยังเป็นความจริงอยู่วันยันค่ำ
lisp : ง่ายกว่าก็ดีกว่า
pure function : ผมไม่รู้ไม่เห็นอะไรทั้งนั้น
macro : กฎมีไว้แหก
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
repl : ทำงานต่อเนื่อง ไรรอยต่อ
hosted language &
fully inter op : ถ้าเธอพร้อมฉันก็พร้อมไปด้วยกัน
protocol : รับๆ ไปก่อนแล้วค่อยแก้ทีหลัง
atom
core.async
tranduser
transient
core.logic
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
4
5.1
"clj"
:days
'name
2/3
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
(add 1 2)
[1 2 3 4]
(add 1 2)
{:name clj}
#{ :red
:yellow
:green}
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
{:flag :diamond
:number :one
:power [1 2 4]}
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
design & discuss
data for represent :
1 playing card
2 game with 4 player play card
each have 4 card, one card for each type
3 priority of card
4 http service
5 programming language
?
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
collection function
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
real value : ความจริงก็ยังเป็นความจริงอยู่วันยันค่ำ
lisp : simple syntax
('i :am "vehas"
:height 180
:hobby ["board game" :cooking
"programming" ])
:color #{'red 'green 'blue :pink})
lisp : simple syntax
(+ 1 2)
hug of love or parentheses
function
arguement
arguement
lisp : simple syntax
(def ten 10)
parentheses
function,
special form,
macro
arguement
arguement
lisp : simple syntax
(def eleven (inc ten))
parentheses
function,
special form,
macro
arguement
lisp : simple syntax
(def pi 10) ; assign pi to ten
(def name "munin")
(if (< pi 10) 10 -10)
(fn [] "hello")
(fn [name] (str "hello " name))
(def hello (fn [name] (str "hello " name))))
lisp : simple syntax
(def pi 10)
(def -name "munin")
(if (< pi 10) 10 -10)
(fn [] "hello")
(fn [name] (str "hello " name))
(def hello (fn [name] (str "hello " name))))
lisp : simple syntax
?
make absolute function
macro : แหกทุกกฎ (1: macro explaind )
(def hello
(fn [name]
(str "hello " name)))
(defn hello
[name] (str "hello" name))
macro : แหกทุกกฎ (1: macro explaind )
js (text)
jsvm
javascript virtual machine
browser (render)
reader
interpreter
macro : แหกทุกกฎ (1: macro explaind )
js (text)
jsvm
javascript virtual machine
browser (render)
reader
interpreter
clojurescript
reader
complier
macro
macro : แหกทุกกฎ (1: macro explaind )
(macroexpand '(defn add [a b] (+ a b)))
macro : แหกทุกกฎ (1: macro explaind )
threading macro
pure function : ผมไม่รู้ไม่เห็นอะไรทั้งนั้น
(inc 2)
(dec 3)
((fn [n] (dec n) 20)
inc
1
2
pure function : ผมไม่รู้ไม่เห็นอะไรทั้งนั้น
(str "a" "b" "c")
(* 2 3 4)
pure function : ผมไม่รู้ไม่เห็นอะไรทั้งนั้น
hof : heighter order function
((fn [f a b] (f a b))
* 2 3)
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
(inc 2)
(dec 3)
((fn [n] (dec n) 20)
inc
1
2
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
inc
1
2
inc
2
heigher order function : function over function
2
4
inc
3
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
inc
1
2
inc
2
heigher order function : function over function
3
4
inc
3
map
(map inc [1 2 3])
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
(defn even?
[n]
(= (mod 2 n) 0))
1
true
false
2
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
filter : (filter even? [ 1 2 3])
1
2
false
2
heigher order function : function over function
3
3
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
filter : (filter odd? [ 1 2 3])
heigher order function : function over function
seq abstraction : รักเธอที่สุด แต่ไม่หยุดที่เธอ
namespace : https://stuartsierra.com/2016/clojure-how-to-ns.html
name convention : https://stackoverflow.com/a/10733162
special symbol : https://clojure.org/guides/weird_characters
atom : https://clojuredocs.org/clojure.core/atom
repl: ทำงานต่อเนื่อง ไร้รอยต่อ
hosted language & fully inter op :
ถ้าเธอพร้อมฉันก็พร้อมไปด้วยกัน
basic interop :
some tutorial:
http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/
google closure library : https://clojurescript.org/reference/google-closure-library
interop with npm ecosystem:
protocol : รับๆ ไปก่อนแล้วค่อยแก้ทีหลัง
etc:
life long learning
official introduction: clojure.org/reference/reader
book: clojure for brave and truth
clojurescript book
doc & example : clojuredocs.org
group : fb.com/groups/clojurethai
newsletter : therepl.net
: purelyfunctional.tv/newsletter
community : reddit.com/r/Clojure/
life long learning
online learning course
free
http://www.parens-of-the-dead.com/
paid
clojure inside out by Neal Ford , Stuart Halloway (oreilly free 10d )
https://lambdaisland.com/ (7$/ mo free 7 d)
https://purelyfunctional.tv/ (49$/mo)
life long learning
online learning book - free
life long learning
online learning book - paid
learner friendly but practical project
give me some feed back
http://crepl.thegeez.net/p/guest_77264_pad
reagent : ก็คือรีแอ็กนั้นแหละ
reagent: lein new reagent
http://reagent-project.github.io/
data
view
reagent : ก็คือรีแอ็กนั้นแหละ
read more :
https://purelyfunctional.tv/guide/re-frame-a-visual-explanation/
https://purelyfunctional.tv/guide/re-frame-building-blocks/
https://purelyfunctional.tv/article/react-vs-re-frame/
reagent : ก็คือรีแอ็กนั้นแหละ
re-frame
data
view
signal
register
database
event
By Veha Suwatphisankij