10. Macros
• Macros are evaluated at compile-time (to generate code)
• One can also (eval) code at runtime
è Great tools for reducing boilerplate do concise DSLs
unless?
25. Editors
• We (6) are currently using:
– IDEA + Cursive
– Eclipse + CCW
– Vim + Fireplace
– Emacs + Cider
– LightTable
• Not yet as good as the Java tools, but getting
better every day
26. REPL-driven workflow
• Evaluate code as you go, instant feedback
– Develop in Editor, evaluate in REPL
– Ridiculously fast (single-pass) compiler
• Massive boost in productivity
• nRepl-servers
• Browser-Repls
27. Web stacks
• Mostly micro-libraries on top of Ring
– Request, Response, Adapters, Middlewares, Handlers
– https://github.com/ring-clojure/ring
• Packaged either:
– standalone web servers (uberjar)
– As Servlet Apps (and deploy as wars)
• Some popular libs
– Compojure (https://github.com/weavejester/compojure)
– Liberator (http://clojure-liberator.github.io/liberator/)
– Pedestal (https://github.com/pedestal/pedestal)
• Lot’s of support libs (clostache, hiccup, enlive, …)
33. Don’t trust the benchmark
Go
211k
h)p-‐kit
137k
Compojure
123k
Scalatra
107k
Play
98k
Spring
42k
h)p://www.techempower.com/benchmarks/#secKon=data-‐r9hw=i7test=json
34. Async web - Scala Clojure
h)p://www.slideshare.net/colinlogaan/clojure-‐at-‐a-‐post-‐office-‐36333973
37. Utils
• Use Java libraries or idiomatic clj-wrappers on
top of them
– clj-time, emailer, clj-ssh, timbre (logging) tons of other
goodnesses
38. Data formats
• JSON maps 1:1 to Clojure
– All core functions available, no need for external DSLs
• XML, lazy parsers, zippers, selectors
• Excel, use Apache POI directly
• EDN, Transit
• …
Demo
39. Clojurescript
• Clojure compiled into JavaScript
– No threads, some different implementation classes
• Google Closure compiler
• Browser-repls (http://clojurescript.net/)
– Same dynamic development flow as with Clojure
49. In Finland?
• Zenrobotics
– “the largest clojure codebase in the world”?
• Metosin
– Internally, for small large enterprises, Finnish Authorities
(with friends) abroad
– Training for others (Solita, Gofore, Futurice others)
• Solita (with friends)
• Others
• (lots of startups)
54. Flushing the Brain
• (Mutable) Objects
à Immutable Data, (pure) functions, references
• Design Patterns
à mostly not needed (builder, strategy, visitor,…), new functional design patterns
• Domain Driven Design
à Anemic Domain Model is a Functional Domain Model
• TDD
à RDD (with tests)
• Dependency Injection
à Thought not needed, but still good for large apps (via Stuart Sierra’s
Component-library, collecting app state into one place)
55. Goods and Bads
• Good
– Simple and beautiful code
– Awesome Development speed
– Great friendly ecosystem (libs, people support)
– The JVM Backup (can use Java anywhere, performance)
– Clojurescript(!!!)
– Extensibility (mini languages on top)
• Bad
– Startup time
– CLJS Build tools (vs Gulp)
– Refactoring in large projects (with current IDE support)
– 10% times, missing the static type system
56. I would use Clojure for…
• Everything, replacing both Java Scala!
• Just kidding, not for:
– Android development (object apis, startup) à Scala/Java
– Command line apps (slow startup) à whatever
– Maybe not for distributed computing à Spark/Akka/Scala
• But Clojure for mostly everything else.
57. Clojure @ Metosin
• Open source
– Ring-Swagger Compojure-api (Swagger 2.0)
– kekkonen.io (a snappy CQRS-lib)
– Lein-simulflow
• Community
– Tech talks, seminars, dojos
• Projects Training
• Fun stuff