6. Setting expectations
• This is an experience report
• Not a language primer
• Assumes no familiarity except basic facts
7. Setting expectations
• This is an experience report
• Not a language primer
• Assumes no familiarity except basic facts
• ~200 slides.This is gonna be fast.
17. Wanted
• An environment that does not suck is
operationally sane
• A runtime that has decent tooling
(profilers, concurrency-related metrics, GC
metrics)
18. Wanted
• An environment that does not suck is
operationally sane
• A runtime that has decent tooling
(profilers, concurrency-related metrics, GC
metrics)
• A runtime that yields good baseline
performance
19. Wanted
• An environment that does not suck is
operationally sane
• A runtime that has decent tooling
(profilers, concurrency-related metrics, GC
metrics)
• A runtime that yields good baseline
performance
• Painless upgrade paths
26. JVM
• One of the most mature runtimes you can
find
27. JVM
• One of the most mature runtimes you can
find
• Excellent tooling
28. JVM
• One of the most mature runtimes you can
find
• Excellent tooling (VisualVM,YourKit, jstack,
jhat,VM/+XX flags, BTrace, …)
29. JVM
• One of the most mature runtimes you can
find
• Excellent tooling
• Excellent baseline performance
30. JVM
• One of the most mature runtimes you can
find
• Excellent tooling
• Excellent baseline performance
• Multilingual: Clojure, Java, JRuby, Scala, JS
implementations
34. Clojure
• Very high level, concise, expressive
• Excellent concurrency/parallelism story
35. Clojure
• Very high level, concise, expressive
• Excellent concurrency/parallelism story
• Very good baseline performance
36. Clojure
• Very high level, concise, expressive
• Excellent concurrency/parallelism story
• Very good baseline performance
• Consistent, well designed
37. Clojure
• Very high level, concise, expressive
• Excellent concurrency/parallelism story
• Very good baseline performance
• Consistent, well designed
• Decent tooling
38. Clojure
• Very high level, concise, expressive
• Excellent concurrency/parallelism story
• Very good baseline performance
• Consistent, well designed
• Decent tooling
• Fun to work with (motivation)
55. Clojure: baseline
performance
• What matters the most is what bytecode
the compiler produces
• Java interop bytecode is typically the same
as produced by javac
56. Clojure: baseline
performance
• What matters the most is what bytecode
the compiler produces
• Java interop bytecode is typically the same
as produced by javac
• Watch out for reflective calls, primitive
boxing
63. Clojure: baseline
performance
• Optional type hints
• Type inference in simple cases
• If JVM can optimize your bytecode, things
run screaming fast
• From 2% (Java lib wrappers) to 200% (naïve
numerics heavy code, tight loops) penalty
compared to Java
66. Clojure: baseline
performance
• Immutable data structures have O(log32 n)
access complexity
• Immutable data structures have associated
GC tax
• Focus on exploiting parallelism over
squeezing µs from a single thread
73. Clojure: stability
• Have been using 1.3 since alpha1
• Hit by 4 Clojure bugs in ~3 years
• 1 bug is an edge case that is not worth
fixing (I did something really stupid)
74. Clojure: stability
• Have been using 1.3 since alpha1
• Hit by 4 Clojure bugs in ~3 years
• 1 bug is an edge case that is not worth
fixing (I did something really stupid)
• Alphas more solid than GA releases of
almost all other languages I’ve worked with
75. Clojure: stability
• Hit by 4 Clojure bugs in ~3 years
• 1 bug is an edge case that is not worth
fixing (I did something really stupid)
• Alphas more solid than GA releases of
almost all other languages I’ve worked with
• Others (e.g.ThoughtWorks) report the
same experience
76. Clojure: stability
• Upgraded 28 apps & libraries from 1.3 to
1.4. Just 1 change due to a tricky 3rd party
library.The rest was a drop-in replacement.
77. Clojure: stability
• Upgraded 28 apps & libraries from 1.3 to
1.4. Just 1 change due to a tricky 3rd party
library.The rest was a drop-in replacement.
• When upgrading is this easy, people do it
happily
78. Clojure: stability
• Upgraded 28 apps & libraries from 1.3 to
1.4. Just 1 change due to a tricky 3rd party
library.The rest was a drop-in replacement.
• When upgrading is this easy, people do it
happily
• No library binary compatibility hell some
other JVM languages suffer from
79. Clojure: stability
• Many active developers are conservative
with versioning & calling things “done”
80. Clojure: stability
• Many active developers are conservative
with versioning & calling things “done”
• Fits JVM ecosystem maturity really well
86. Clojure: consistency
• Collections/sequences library is very
unified
• Easy to implement your own data types
that work just like core Clojure types
• Almost no “bad baggage” in the core
87. Clojure: consistency
• Collections/sequences library is very
unified
• Easy to implement your own data types
that work just like core Clojure types
• Almost no “bad baggage” in the core
• The language was actually designed
90. Clojure: deployment
• Pretty standard JVM deployment options
• Compile everything AOT into a single jar
(“überjar”), including dependencies, assets,
etc
91. Clojure: deployment
• Pretty standard JVM deployment options
• Compile everything AOT into a single jar
(“überjar”), including dependencies, assets,
etc
• A tiny shell script + start-stop-daemon
92. Clojure: deployment
• Pretty standard JVM deployment options
• Compile everything AOT into a single jar
(“überjar”), including dependencies, assets,
etc
• A tiny shell script + start-stop-daemon
• Chef or Capistrano
103. Clojure: operations
• VisualGC gives real insight into what is
going on with object allocation, tenuring,
death rate
• JVM DTrace support (Solaris, SmartOS,
FreeBSD, OS X)
104. Clojure: operations
• VisualGC gives real insight into what is
going on with object allocation, tenuring,
death rate
• JVM DTrace support (Solaris, SmartOS,
FreeBSD, OS X)
• BTrace
107. Clojure: community
• Full of intelligent engineers who don’t give
two shits about Hacker News
• Over 10 conferences to date
108. Clojure: community
• Full of intelligent engineers who don’t give
two shits about Hacker News
• Over 10 conferences to date
• ~10K people on the mailing list
109. Clojure: community
• Full of intelligent engineers who don’t give
two shits about Hacker News
• Over 10 conferences to date
• ~10K people on the mailing list
• Users from small and not-so-small startups
to Fortune 50 corporations in finance,
biotech, retail
114. Clojure: changes the
way you think
• About managing your program state
• About the value of experimenting (REPL
driven development)
115. Clojure: changes the
way you think
• About managing your program state
• About the value of experimenting (REPL
driven development)
• About metaprogramming
116. Clojure: changes the
way you think
• About managing your program state
• About the value of experimenting (REPL
driven development)
• About metaprogramming
• About isolating side effects
118. Clojure: changes the
way you think
• Program = pure core + parts that
communicate with the outside world
(network, disk I/O)
119. Clojure: changes the
way you think
• Program = pure core + parts that
communicate with the outside world
(network, disk I/O)
• Pure parts are ridiculously easy to reason
about, test, experiment with and reuse
120. Clojure: changes the
way you think
• Program = pure core + parts that
communicate with the outside world
(network, disk I/O)
• Pure parts are ridiculously easy to reason
about, test, experiment with and reuse
• Typical Rails app: 95% of methods have side
effects
122. Clojure: changes the
way you think
• Typical Clojure app: 40% of functions have
side effects
• Anecdotal evidence: 3-4 times less time
spent on tests
123. Clojure: changes the
way you think
• Typical Clojure app: 40% of functions have
side effects
• Anecdotal evidence: 3-4 times less time
spent on tests
• Moral of the story: make more of your
code not have side effects
124. Clojure: fun to work
with
• Profoundly changes the way you think
125. Clojure: fun to work
with
• Profoundly changes the way you think
• Motivates you to learn
126. Clojure: fun to work
with
• Profoundly changes the way you think
• Motivates you to learn
• Easy things are easy, hard things are
possible
127. Clojure: fun to work
with
• Profoundly changes the way you think
• Motivates you to learn
• Easy things are easy, hard things are
possible
• Wheels are already invented in clojure.core
or JDK
128. Clojure: fun to work
with
• Stable: fewer distractions, get in the flow
129. Clojure: fun to work
with
• Stable: fewer distractions, get in the flow
• REPL driven development keeps you in the
flow for longer periods
130. Clojure: fun to work
with
• Stable: fewer distractions, get in the flow
• REPL driven development keeps you in the
flow for longer periods
• Polymorphism done right <3
131. Clojure: fun to work
with
“Clojure demands that you raise your game
and rewards you greatly for it…”
132. Clojure: fun to work
with
• The community is full of smart and down
to earth people.
143. Clojure: misc
• Leiningen (leiningen.org) is excellent
• Deps management, build tool, custom tasks
are just Clojure functions
144. Clojure: misc
• Leiningen (leiningen.org) is excellent
• Deps management, build tool, custom tasks
are just Clojure functions
• Packages your code + all deps into a single
jar for deployment
145. Clojure: misc
• Leiningen (leiningen.org) is excellent
• Deps management, build tool, custom tasks
are just Clojure functions
• Packages your code + all deps into a single
jar for deployment
• Makes it trivial to develop against multiple
Clojure versions
149. Clojure: misc
• clojars.org
• Deploy via SSH (SCP) or HTTPS
• Very easy to deploy snapshot releases
• Clojars and Leiningen are maintained by the
same core team
153. Clojure: ecosystem
• Feels a bit like Ruby circa 2009
• But with the entire JVM ecosystem at your
reach
154. Clojure: ecosystem
• Feels a bit like Ruby circa 2009
• But with the entire JVM ecosystem at your
reach
• And Leiningen + clojars.org
155. Clojure: ecosystem
• Feels a bit like Ruby circa 2009
• But with the entire JVM ecosystem at your
reach
• And Leiningen + clojars.org
• Community ~ doubles every year in size
156. Clojure: ecosystem
• Feels a bit like Ruby circa 2009
• But with the entire JVM ecosystem at your
reach
• And Leiningen + clojars.org
• Community ~ doubles every year in size
• Google for “The State of Clojure” survey
158. Clojure: ecosystem
• ~35% of people come from Java, ~35% from
Ruby or Python
• Libraries, not frameworks
159. Clojure: ecosystem
• ~35% of people come from Java, ~35% from
Ruby or Python
• Libraries, not frameworks
• Decent libraries just for almost every
problem
160. Clojure: ecosystem
• ~35% of people come from Java, ~35% from
Ruby or Python
• Libraries, not frameworks
• Decent libraries just for almost every
problem
• 15 books, 2 outdated (cover 1.2)
161. Clojure: ecosystem
• ~35% of people come from Java, ~35% from
Ruby or Python
• Libraries, not frameworks
• Decent libraries just for almost every
problem
• 15 books, 2 outdated (cover 1.2)
• clojure-doc.org, tryclj.com, …
166. Clojure: what sucks
• clojure.org
• Documentation (guides, the ref is mostly
OK, books are great)
167. Clojure: what sucks
• clojure.org
• Documentation (guides, the ref is mostly
OK, books are great)
• Compiler messages can be cryptic
168. Clojure: what sucks
• clojure.org
• Documentation (guides, the ref is mostly
OK, books are great)
• Compiler messages can be cryptic
• JVM startup time + code compilation on
each run (without REPL or tools such as
Drip)
177. ClojureWerkz
• Modern targets (Clojure 1.5+, JDK 6)
• Feature rich
• Well documented
• Friendly license (EPL, the same as Clojure)
178. ClojureWerkz
• Modern targets (Clojure 1.5+, JDK 6)
• Feature rich
• Well documented
• Friendly license (EPL, the same as Clojure)
• Tested against multiple Clojure versions, 3
JDKs on travis-ci.org
181. ClojureWerkz
• Projects reuse a lot of Java libraries
• Which are often officially supported (e.g.
RabbitMQ, ElasticSearch, MongoDB, Riak,
Reactor)
182. “ClojureWerkz stuff is really improving my
Clojure experience, which is rapidly becoming
my language of choice…”
187. Clojure: the takeaway
• A lot of merit of its own
• Great stability
• Hosted (symbiotic) language is a great thing
188. Clojure: the takeaway
• A lot of merit of its own
• Great stability
• Hosted (symbiotic) language is a great thing
• Don’t fear the JVM
189. Clojure: the takeaway
• A lot of merit of its own
• Great stability
• Hosted (symbiotic) language is a great thing
• Don’t fear the JVM
• Immutability is essential for sane
concurrent programming