thinking in clojurescript
play

Thinking'in'ClojureScript - PowerPoint PPT Presentation

Thinking'in'ClojureScript Programming)is)not)about)typing,)it's)about)thinking)4)Rich)Hickey What%is%ClojureScript? ClojureScript-is-a-compiler-for-Clojure-that-targets-JavaScript. Goals Understand*the*ClojureScript*thought*process


  1. Thinking'in'ClojureScript Programming)is)not)about)typing,)it's)about)thinking)4)Rich)Hickey

  2. What%is%ClojureScript? ClojureScript-is-a-compiler-for-Clojure-that-targets-JavaScript.

  3. Goals • Understand*the*ClojureScript*thought*process • Learn*enough*ClojureScript • Convince*YOU*to*take*ClojureScript*for*a*spin • Take*some*of*these*principles*back*to*JavaScript

  4. Why$ClojureScript? • Philosophy • It's-not-JavaScript • Data-Structures-/-Immutability • core.async-library

  5. It's%not%JavaScript

  6. • Thought(out(design(( Nan == Nan ;false ) • Ba2le(tested((i.e.(Google(Closure) • Browser(Repl • Real;me(feedback( • Macros,(namespaces

  7. Figwheel(/(Browser(Repl

  8. Just%enough%ClojureScript

  9. Hello%ClojureScript Hello ClojureScript ;; Hello ClojureScript

  10. Func%on'Call (+ 5 (* 5 2)) ;; 15 // JavaScript 5 + 5 * 2

  11. Defining'Func+ons (defn multiply [x, y] (* x y)) // JavaScript function multiply(x, y) { x * y }

  12. Interop (. js/document (getElementById "app") ;; method call (.-value input) ;; property

  13. atom (def count (atom 0)) @count ;; 0 (swap! count 1) (reset! count 1)

  14. let (let [x 1] x)

  15. Macros (-> (om/get-node owner "new-contact-name") .-value)

  16. (defmacro unless [pred & body] `(if (not ~pred) (do ~@body) nil)) ;; Compiles to (macroexpand '(unless true (/ 1 0)) ; => (if (clojure.core/not true) (do (/ 1 0)) nil)

  17. core.asyc Clojure's*implementa1on*of*Communica1ng*Sequen1al*Processes

  18. Communica)ng+Sequen)al+Processes • processes • channels • coordina.on

  19. Escape'callback'hell

  20. Write&sequen+al&logic (println "do something") (send-to-channel) (println "continue")

  21. Primi%ves

  22. Chan%(get%be+er%defini0ons%for%these) (chan)

  23. Put (put!) (>!)

  24. Take (take!) (<!)

  25. go (go (println "Waiting...") (<! events) (show! "Got an event") )

  26. Code%example

  27. Immutability (def a [1 2 3]) (println (conj a 42)) ;; [1 2 3 42] (println a) ;; [1 2 3]

  28. Om#+#React

  29. Lets%talk%about%Om

  30. Om Interface)to)Facebook's)React

  31. React • V#in#MVC • Immediate#mode#rendering • Components

  32. Example h"ps:/ /github.com/iamjarvo/pplz

  33. Helpful'links • h#p:/ /funcool.github.io/clojurescript6unraveled/ • h#ps:/ /github.com/circleci/frontend • h#ps:/ /www.youtube.com/user/ClojureTV • h#ps:/ /github.com/omcljs/om • h#p:/ /swannode#e.github.io/

  34. Me • Jearvon)Dharrie • Twi/er:)@jearvon • Podcast:)h/p:/ /turing.cool

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend