TDC2016POA | Trilha Arquitetura - Apache Kafka: uma introdução a logs distribuídos
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScript na sua próxima web...
-
Upload
tdc-globalcode -
Category
Education
-
view
203 -
download
0
Transcript of TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScript na sua próxima web...
What is Clojure?
Clojure is a functional Lisp that targets the JVM and enables simpler software design.
Macros(defmacro expect [value to|!to matcher match]
(let [assertion (if (= matcher 'be)
`(= ~value ~match)
`(~matcher value match))]
(if (= to|!to 'not-to)
`(is (not ~assertion))
`(is ~assertion))))
;; isso expande para:
(testing "Sum is working"
(is (not (= (+ 2 2) 3)))
(is (= (+ 2 1) 3)))
Macros(defmacro expect [value to|!to matcher match]
(let [assertion (if (= matcher 'be)
`(= ~value ~match)
`(~matcher value match))]
(if (= to|!to 'not-to)
`(is (not ~assertion))
`(is ~assertion))))
;; isso expande para:
(testing "Sum is working"
(is (not (= (+ 2 2) 3)))
(is (= (+ 2 1) 3)))
Paradigms as Libraries
Design by Contract - core.contracts
Logic Programming - core.logic
Lightweight threads + channels - core.async
Optional/Gradual Type system - core.typed
What is Clojure?
Clojure is a functional Lisp that targets the JVM and enables simpler software design.
Targets the JVMConstructornew Person("Paulo");
(Person. "Paulo")
Static Member Math.PI // 3.141592653589793
Math/PI ;; 3.141592653589793
Instance Method " Hello world! ".trim(); //Hello world!
(.trim " Hello world! ") ;;Hello world!
Targets the JVMChained Access person.getAddress().getState().getCode();
(.. person getAddress getState getCode)
Targets the JVMChained Access person.getAddress().getState().getCode();
(.. person getAddress getState getCode)
(macroexpand '(.. person getAddress getState getCode))
(. (. (. person getAddress) getState) getCode)
Targets the JVMMultiple Updatesperson.setFirstName("Ben");
person.setLastName("Mabey");
person.makePresenter();
(doto person (.setFirstName "Ben") (.setLastName "Mabey") .makePresenter)
What is Clojure?
Clojure is a functional Lisp that targets the JVM and enables simpler software design.
Cljs + Reagent
Reagent minimalistic interface between ClojureScript and React
HiccupHiccup is a library for representing HTML in Clojure