Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Clojure night

487 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Clojure night

  1. 1. Clojure Community Night Aria Haghighi CTO @aria42 Saturday, October 5, 13
  2. 2. Eng @ Prismatic Saturday, October 5, 13
  3. 3. Eng @ Prismatic All Clojure in the back Saturday, October 5, 13
  4. 4. Eng @ Prismatic All Clojure in the back Some Clojure in the front Saturday, October 5, 13
  5. 5. Saturday, October 5, 13
  6. 6. <31. Why Saturday, October 5, 13
  7. 7. <31. Why 2. Open Source Saturday, October 5, 13
  8. 8. <31. Why 2. Open Source 3. What’s needed Saturday, October 5, 13
  9. 9. Why Clojure <3 Saturday, October 5, 13
  10. 10. Programming to Behavior Saturday, October 5, 13
  11. 11. Programming to Behavior Saturday, October 5, 13
  12. 12. Programming to Behavior Encapsulate The Object Saturday, October 5, 13
  13. 13. Programming to Behavior Interface Encapsulate The Object Saturday, October 5, 13
  14. 14. Programming to Behavior At it’s best, OOP is about coding to behavior, not state or identity Saturday, October 5, 13
  15. 15. Programming to Data Saturday, October 5, 13
  16. 16. Programming to Data Inherent data structures can be used to derive the structure of a program Saturday, October 5, 13
  17. 17. Programming to Data Inherent data structures can be used to derive the structure of a program Saturday, October 5, 13
  18. 18. Programming to Data Saturday, October 5, 13
  19. 19. Programming to Data Ins & Outs Saturday, October 5, 13
  20. 20. Programming to Data Ins & Outs Represent Saturday, October 5, 13
  21. 21. Programming to Data Ins & Outs Represent Transform Saturday, October 5, 13
  22. 22. The killer feature of Clojure isn’t that it’s a functional language, but the best data-oriented one Programming to Data Saturday, October 5, 13
  23. 23. Data Behavior Saturday, October 5, 13
  24. 24. Data Behavior sequences maps defn destructuring macros Saturday, October 5, 13
  25. 25. Data Behavior sequences maps defn destructuring macros deftype protocol reify Saturday, October 5, 13
  26. 26. Data Behavior sequences maps defn destructuring macros records multi- methods deftype protocol reify Saturday, October 5, 13
  27. 27. Data Behavior+ The crown of Clojure’s design is the clean separation of data and behavior Saturday, October 5, 13
  28. 28. Open Source Saturday, October 5, 13
  29. 29. Open Source Saturday, October 5, 13
  30. 30. Plumbing and Graph data-oriented composition and dependency prismatic/plumbing Saturday, October 5, 13
  31. 31. Graph: Overview Saturday, October 5, 13
  32. 32. Graph: Overview Univariate statistics: Given data as double[] xs Saturday, October 5, 13
  33. 33. Graph: Overview Univariate statistics: Given data as double[] xs m = 1 n nX i=1 xi m2 = 1 n nX i=1 x2 i v = m2 m2 Saturday, October 5, 13
  34. 34. Graph: Overview Univariate statistics: Given data as double[] xs m = 1 n nX i=1 xi m2 = 1 n nX i=1 x2 i v = m2 m2 xs n m2m v Saturday, October 5, 13
  35. 35. Graph: Overview Univariate statistics: Given data as double[] xs xs n m2m v Saturday, October 5, 13
  36. 36. Graph: Overview Univariate statistics: Given data as double[] xs xs n m2m v (defn stats [{:keys [xs]}] (let [n (count xs) m (/ (sum xs) n) m2 (/ (sum sq xs) n) v (- m2 (* m m))] {:n n :m m :m2 m2 :v v})) Saturday, October 5, 13
  37. 37. The Monster let (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  38. 38. The Monster let dozens of parameters, not compositional (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  39. 39. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  40. 40. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  41. 41. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  42. 42. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  43. 43. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  44. 44. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  45. 45. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  46. 46. The Monster let dozens of parameters, not compositional structure of (de)composition is locked up in an opaque function (defn start [{:keys [a,z]}] (let [s1 (store a ...) s2 (store b ...) db (sql-db c) t2 (cron s2 db...) ... srv (server ...)] (fn shutdown [] (.stop srv) ... (.flush s1)))) Saturday, October 5, 13
  47. 47. From let to Graph (defn stats [{:keys [xs]}] (let [n (count xs) m (/ (sum xs) n) m2 (/ (sum sq xs) n) v (- m2 (* m m))] {:n n :m m :m2 m2 :v v})) Saturday, October 5, 13
  48. 48. From let to Graph (defn stats [{:keys [xs]}] (let [n (count xs) m (/ (sum xs) n) m2 (/ (sum sq xs) n) v (- m2 (* m m))] {:n n :m m :m2 m2 :v v})) xs n m2m v Saturday, October 5, 13
  49. 49. From let to Graph (defn stats [{:keys [xs]}] (let [n (count xs) m (/ (sum xs) n) m2 (/ (sum sq xs) n) v (- m2 (* m m))] {:n n :m m :m2 m2 :v v})) {:n (fn [xs] (count xs)) :m (fn [xs n] (/ (sum xs) n)) :m2 (fn [xs n] (/ (sum sq xs) n)) :v (fn [m m2] (- m2 (* m m)))} xs n m2m v Saturday, October 5, 13
  50. 50. From let to Graph (defn stats [{:keys [xs]}] (let [n (count xs) m (/ (sum xs) n) m2 (/ (sum sq xs) n) v (- m2 (* m m))] {:n n :m m :m2 m2 :v v})) {:n (fn [xs] (count xs)) :m (fn [xs n] (/ (sum xs) n)) :m2 (fn [xs n] (/ (sum sq xs) n)) :v (fn [m m2] (- m2 (* m m)))} k k k k xs n m2m v Saturday, October 5, 13
  51. 51. Example:API Service Saturday, October 5, 13
  52. 52. Example:API Service (def api-service (service {:service-name “api” :backend-port 42424 :server-threads 100} {:store1 (instance store {:type :s3 ...}) :memo (fnk [store1] {:resource ...}) ... :api-server (...)})) Saturday, October 5, 13
  53. 53. sane DOM templating and manipulation prismatic/dommy Dommy Saturday, October 5, 13
  54. 54. fast primitive array math prismatic/hiphip HipHip (Array) w · x = nX i=1 wixi Saturday, October 5, 13
  55. 55. HipHip Examples Saturday, October 5, 13
  56. 56. HipHip Examples Dot Product w · x = nX i=1 wixi Saturday, October 5, 13
  57. 57. HipHip Examples Dot Product w · x = nX i=1 wixi Inner loop in machine learning Saturday, October 5, 13
  58. 58. HipHip Examples Dot Product w · x = nX i=1 wixi Inner loop in machine learning arg max ` w · x` prediction Saturday, October 5, 13
  59. 59. HipHip Examples Dot Product w · x = nX i=1 wixi Inner loop in machine learning arg max ` w · x` prediction P(x; w) / exp{w · x} training Saturday, October 5, 13
  60. 60. Dot Product w · x = nX i=1 wixi HipHip Examples Saturday, October 5, 13
  61. 61. Dot Product w · x = nX i=1 wixi (defn dot-product [^doubles ws ^doubles xs] (areduce ws idx sum 0.0 (+ sum (*  (aget ws idx) (aget xs idx)))) HipHip Examples Saturday, October 5, 13
  62. 62. Dot Product w · x = nX i=1 wixi HipHip Examples Saturday, October 5, 13
  63. 63. Dot Product w · x = nX i=1 wixi double dotProd(double[] ws, double[] xs) { double sum = 0.0; for (int i=0; i < xs.length; ++i) { sum += ws[i] * xs[i]; } return sum; } HipHip Examples Saturday, October 5, 13
  64. 64. Dot Product w · x = nX i=1 wixi HipHip Examples Saturday, October 5, 13
  65. 65. Dot Product w · x = nX i=1 wixi (defn dot-product [ws xs] (hiphip.double/asum [w ws x xs] (* w x)))      HipHip Examples Saturday, October 5, 13
  66. 66. declarative data description and validation prismatic/schema Schema Saturday, October 5, 13
  67. 67. What Clojure needs Saturday, October 5, 13
  68. 68. Where’s my debugger!?! Saturday, October 5, 13
  69. 69. MOAR Compiler Speed (require 'api.deploy) go get a coffee, it’s going to be a bit Saturday, October 5, 13
  70. 70. Compiler Tooling real IDE tools Make Paredit a library Saturday, October 5, 13
  71. 71. Multi-project support in Leiningen Saturday, October 5, 13
  72. 72. Native Client Story Saturday, October 5, 13
  73. 73. Thanks Questions? Saturday, October 5, 13

×