Slide 1

Slide 1 text

Clojure is ⚡Awesome⚡! by Avi Flax • avi@aviflax.com • August 2017

Slide 2

Slide 2 text

* What: An Open Source programming system * Who: Initial design and implementation by Rich Hickey, BDFL. * When: First preview release: 2007; 1.0 was in 2009. Some W’s What Who When by Avi Flax • avi@aviflax.com • August 2017

Slide 3

Slide 3 text

* Why does it exist? * Hickey did a lot of work with C# and Java and was dissatisfied * He wanted a LISP that: * fast, pragmatic * embraces immutability, concurrency, and polymorphism * not constrained by backwards compatibility * empowered and accelerated by building on an established platform Why by Avi Flax • avi@aviflax.com • August 2017

Slide 4

Slide 4 text

Why is it ⚡Awesome⚡? by Avi Flax • avi@aviflax.com • August 2017

Slide 5

Slide 5 text

* This is a lot of stuff, and itʼs not even everything. * But I think itʼs actually more than the sum of its parts. * I think Clojure is… In a ! ⚡ ⚡ by Avi Flax • avi@aviflax.com • August 2017

Slide 6

Slide 6 text

* Each of these aspects of Clojure is excellent, but itʼs how they fit together to enable and empower designing and building great software over time that is really ⚡Awesome⚡! * We'll revisit each of these strengths later; next I'd like to show you some examples. A cohesive toolkit for thinking & building over time by Avi Flax • avi@aviflax.com • August 2017

Slide 7

Slide 7 text

Examples! by Avi Flax • avi@aviflax.com • August 2017

Slide 8

Slide 8 text

API and database are written in Clojure by Avi Flax • avi@aviflax.com • August 2017

Slide 9

Slide 9 text

* API and UI are written in Clojure and ClojureScript * Other companies using Clojure include Walmart, Chartbeat, Consumer Reports, Puppet, Beanstalk, The Climate Corporation, Thoughtworks, Cerner, Atlassian, and many more by Avi Flax • avi@aviflax.com • August 2017

Slide 10

Slide 10 text

* Donʼt want to dwell on this; just want you to be able to read the examples. * The syntax definitely looks strange at first, but: * People generally get used to the syntax very quickly and just stop noticing it. Syntax by Avi Flax • avi@aviflax.com • August 2017

Slide 11

Slide 11 text

* Referential transparency * Everything is whitespace-delimited * Commas are whitespace * Prefix notation means there are very few reserved characters Calls (callee arg arg arg) (callee (callee arg) arg arg) (capitalize "park assist") (- 10 2 3) by Avi Flax • avi@aviflax.com • August 2017

Slide 12

Slide 12 text

Vectors Indexed, random-access sequences: ["this" "is" "a" "vector"] by Avi Flax • avi@aviflax.com • August 2017

Slide 13

Slide 13 text

Functions ;; Syntax: (fn [arg-1 arg-2] body) ;; Example: (fn [a b] (+ a b)) by Avi Flax • avi@aviflax.com • August 2017

Slide 14

Slide 14 text

Vars ;; Syntax: (def name value) ;; Example: (def default-max-connections 10) by Avi Flax • avi@aviflax.com • August 2017

Slide 15

Slide 15 text

Functions in Vars ;; Syntax: (def function-name (fn [arg-1 arg-2] body)) ;; Example: (def add (fn [a b] (+ a b))) ;; Sugar: (defn add [a b] (+ a b)) by Avi Flax • avi@aviflax.com • August 2017

Slide 16

Slide 16 text

Everything is an Expression (defn hello [first-name] (str "Hello " first-name (if (= first-name "Avi") "!" "."))) by Avi Flax • avi@aviflax.com • August 2017

Slide 17

Slide 17 text

* Even try/catch is an expression! Everything is an Expression (defn good-bye [first-name] (str "Bye " (try (capitalize first-name) (catch Exception err "")))) by Avi Flax • avi@aviflax.com • August 2017

Slide 18

Slide 18 text

* IMHO Clojureʼs syntax is simpler, more regular, more expressive, and more powerful than most languages — definitely including Ruby! * Donʼt even get me started on Rubyʼs blocks :facepalm: Rosetta Slide Case Ruby Clojure Call a function sum(1, 2, 3) (+ 1 2 3) Call a method names.join(',') (join names ",") Define function def uc(s); s.upcase; end (defn uc [s] (upper-case s)) Anon. function ->(s) { s.upcase } (fn [s] (upper-case s)) Control structures if bar; foo; end (if bar foo) Passing functions ¯\_(ϑ)_/¯ (map uc names) Composing functions ¯\_(ϑ)_/¯ (comp uc reverse) by Avi Flax • avi@aviflax.com • August 2017

Slide 19

Slide 19 text

by Avi Flax • avi@aviflax.com • August 2017

Slide 20

Slide 20 text

Short Dives by Avi Flax • avi@aviflax.com • August 2017

Slide 21

Slide 21 text

Symbolics 3640 lisp machine running the Genera operating system in the Retro- Computing Society of RI display at the Vintage Computer Festival East 1.0. Image via WikiMedia Commons. It’s a LISP • Functional • Declarative • Dynamic • Interactive Development → Developer Productivity • Code as Data → Macros • Everything is an expression • Lazy by Avi Flax • avi@aviflax.com • August 2017

Slide 22

Slide 22 text

* JavaScript: ClojureScript; server-side (Node) or client- side (browsers) * Mobile: primarily via ClojureScript + React Native * Serverless: via either ClojureScript+Node or JVM * Embedded: Ferret is a Clojure transpiler that transpiles Clojure to self contained portable ISO C++11. Itʼs verified to run on Arduino, Teensy, SparkFun, NodeMcu. * Erlang: Clojang is a Clojure library that enables Clojure programs to communicate with Erlang processes It’s Got Reach • JVM • CLR • JavaScript • Mobile • Serverless • Embedded • Erlang by Avi Flax • avi@aviflax.com • August 2017

Slide 23

Slide 23 text

It’s Mature • 10 years • host platforms: 20+ years • 10 major releases • Vibrant community • Rich ecosystem • Interoperability • Strong stewardship by Avi Flax • avi@aviflax.com • August 2017

Slide 24

Slide 24 text

Immutability • Baked in at the deepest level • Encourages rigorous thinking about where/when/why mutable state • Enables (powerful + simple + safe) concurrency • Escape hatches for performance • Deeper, longer-term benefits by Avi Flax • avi@aviflax.com • August 2017

Slide 25

Slide 25 text

* “Clojureʼs reference model clearly separates identities from values.” (Programming Clojure, 3rd Ed.) * 4 different kinds of references for different cases Concurrency • Immutability • References • Software Transactional Memory • Atoms • Agents • Vars • CSP: lightweight routines and channels by Avi Flax • avi@aviflax.com • August 2017

Slide 26

Slide 26 text

* Performance: you can add type hints, transients, etc * Correctness: specifications Scalability • Scripts • Prototypes • Products • Platforms • Performance • Correctness by Avi Flax • avi@aviflax.com • August 2017

Slide 27

Slide 27 text

Maintainability • Simplicity • Data Orientation • Coherence • Polymorphism • Protocols • Multimethods • Records • Specifications • Property Testing by Avi Flax • avi@aviflax.com • August 2017

Slide 28

Slide 28 text

TBD Why is it ⛈Not⛈ ⚡Awesome⚡? by Avi Flax • avi@aviflax.com • August 2017

Slide 29

Slide 29 text

* — I think. Now what? • Videos! • Simple Made Easy by Rich Hickey • Clojure in 10 Big Ideas by Stuart Halloway • Clojure for Rubyists — Accessing the GitHub API by Jeff Terrell* by Avi Flax • avi@aviflax.com • August 2017

Slide 30

Slide 30 text

Clojure is ⚡Awesome⚡! You should try it! tryclj.com by Avi Flax • avi@aviflax.com • August 2017