O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScript na sua próxima web App

231 visualizações

Publicada em

Considere usar Clojure/ClojureScript na sua próxima web App

Publicada em: Educação
  • Seja o primeiro a comentar

  • Seja a primeira pessoa a gostar disto

TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScript na sua próxima web App

  1. 1. Considere usar Clojure/ClojureScript na sua próxima web App What is it and why is it interesting?
  2. 2. About me devpaulomarques@gmail.com in/devpaulomarques fb/devpaulomarques ADS Senac-RS DomTI
  3. 3. “APRENDER UMA NOVA LINGUAGEM DE PROGRAMAÇÃO É SÓ APRENDER A SINTAXE” Algum amigo seu.
  4. 4. Timeline ● Lisp 1958 ● Clojure 2007 ● Clojure 1.0 2009 ● Clojure 1.8 2016
  5. 5. What is Clojure? Clojure is a functional Lisp that targets the JVM and enables simpler software design.
  6. 6. Clojure is a Lisp
  7. 7. Clojure is a Lisp
  8. 8. Clojure is a Lisp Code as data
  9. 9. Clojure is a Lisp No sintax
  10. 10. It looks like this (def a 1) (def f (fn [x] (* 2 x))) (f a) ;; 2 (f (+ a 10)) ;; 22
  11. 11. Clojure is a Lisp
  12. 12. REPL Read-Eval-Print-Loop
  13. 13. 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)))
  14. 14. Macros ????
  15. 15. 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)))
  16. 16. Paradigms as Libraries Design by Contract - core.contracts Logic Programming - core.logic Lightweight threads + channels - core.async Optional/Gradual Type system - core.typed
  17. 17. What is Clojure? Clojure is a functional Lisp that targets the JVM and enables simpler software design.
  18. 18. Targets the JVM Constructor new 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!
  19. 19. Targets the JVM Chained Access person.getAddress().getState().getCode(); (.. person getAddress getState getCode)
  20. 20. Targets the JVM Chained Access person.getAddress().getState().getCode(); (.. person getAddress getState getCode) (macroexpand '(.. person getAddress getState getCode)) (. (. (. person getAddress) getState) getCode)
  21. 21. Targets the JVM Multiple Updates person.setFirstName("Ben"); person.setLastName("Mabey"); person.makePresenter(); (doto person (.setFirstName "Ben") (.setLastName "Mabey") .makePresenter)
  22. 22. What is Clojure? Clojure is a functional Lisp that targets the JVM and enables simpler software design.
  23. 23. Clojure is functional Avoid state changes First class functions High order functions
  24. 24. Why is Clojure interesting? ● Succinct
  25. 25. Why is Clojure interesting? ● Succinct ● Java Interop
  26. 26. Why is Clojure interesting? ● Succinct ● Java Interop ● Multi-threaded
  27. 27. Why is Clojure interesting? ● Succinct ● Java Interop ● Multi-threaded ● Lazy
  28. 28. Why is Clojure interesting? ● Succinct ● Java Interop ● Multi-threaded ● Lazy ● Fun ● ...
  29. 29. ClojureScript JavaScript
  30. 30. ClojureScript
  31. 31. ClojureScript
  32. 32. Why ClojureScript Google closure compiler
  33. 33. Why ClojureScript Google closure compiler Modularity
  34. 34. Why ClojureScript Google closure compiler Modularity Immutability
  35. 35. Why ClojureScript Google closure compiler Modularity Immutability And...
  36. 36. REPL
  37. 37. React
  38. 38. Cljs + Reagent Reagent minimalistic interface between ClojureScript and React Hiccup Hiccup is a library for representing HTML in Clojure
  39. 39. Reagent
  40. 40. Reagent
  41. 41. Add some style
  42. 42. Garden
  43. 43. Cljs + Reagent + Garden
  44. 44. Thanks

×