* 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 • [email protected]flax.com • August 2017
* 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 • [email protected]flax.com • August 2017
* 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 • [email protected]flax.com • August 2017
* 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 • [email protected]flax.com • August 2017
* 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 • [email protected]flax.com • August 2017
* 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.
* 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 • [email protected]flax.com • August 2017
* 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 • [email protected]flax.com • August 2017
* 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 • [email protected]flax.com • August 2017
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 • [email protected]flax.com • August 2017
* 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 • [email protected]flax.com • August 2017
It’s Mature • 10 years • host platforms: 20+ years • 10 major releases • Vibrant community • Rich ecosystem • Interoperability • Strong stewardship by Avi Flax • [email protected]flax.com • August 2017
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 • [email protected]flax.com • August 2017
* “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 • [email protected]flax.com • August 2017
* — 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 • [email protected]flax.com • August 2017