Clojure - Why does it matter?

887
-1

Published on

An introduction to Clojure at why you should take a closer look.

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
887
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
15
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Clojure - Why does it matter?

  1. 1. Clojure Why does it matter? @friemens
  2. 2. ● Published 2008 by Rich Hickey. ● Dynamically typed. ● Compiles to bytecode. A pragmatic Lisp for the JVM
  3. 3. & Simplicity Advanced stuff Lisp Deconstruction
  4. 4. & Simplicity Advanced stuff Lisp Deconstruction
  5. 5. Few ubiquitous data structures and powerful core library. Simple Complicated Data encapsulated behind specific APIs of OO classes. Immutable data. Mutable class instances & synchronization. Embedded „code generators“. External DSL tooling. Pure functions. Side effects & dependence on context.
  6. 6. Design is deconstruction Small libraries, no big frameworks! HTTP server Middle- ware functions Routing function Handler functions Page renderer
  7. 7. Deconstructing the database Datomic A modular, facts-based database system. Storage service Transactor Query Cache Peer library Application Database
  8. 8. State and Identity OO style (conflated) Clojure style (separated)
  9. 9. & Simplicity Advanced stuff Lisp Deconstruction
  10. 10. & Simplicity Advanced stuff Lisp Deconstruction
  11. 11. Huh? Lisp? Lisp! Other Languages Time Expressive Power
  12. 12. The elegance of Lisp
  13. 13. http://xkcd.com/297
  14. 14. Functional programming Functions as values Powerful data structures „[...] a unit tester's wet dream.“ No assignments Laziness
  15. 15. Example: Square root approximation gn+1 := (n/gn + gn) / 2
  16. 16. Concise code public <K,V> Map<V, K> revertKeysVals(Map<K, V> src) { final Map<V, K> dst = new HashMap<V, K>(); for (Map.Entry<K, V> e : src.entrySet()) { dst.put(e.getValue(), e.getKey()); } return dst; } (defn revert-kv [m] (->> m (map (juxt second first)) (into {})))
  17. 17. Prefer purity Pure functions Side effects Context
  18. 18. Code is data, or: why does Lisp look different? Code Data
  19. 19. Common How it could be Build config DSL grammar Settings Serialization XML Xtext .properties JSON Debug output Anything EDN EDN EDN EDN EDN Clojure is a superset of Extensible Data Notation
  20. 20. A powerful language allows for simpler tools
  21. 21. Interactive development Demo
  22. 22. & Simplicity Advanced stuff Lisp Deconstruction
  23. 23. & Simplicity Advanced stuff Lisp Deconstruction
  24. 24. Persistent datastructures 0 1 2 3 4 5 6 6 7 8 9 10 7
  25. 25. Concurrency support Actor style: Pulsar librarySoftware Transactional Memory CSP style: core.async library Widely used: Synchronization and LockingJava Clojure
  26. 26. Advanced libraries core.logic core.async core.typed core.reducers Datomic map + fold parallelized Logic programming CSP style programming Optional type system Facts-based database
  27. 27. Internal DSLs just happen HTTP routing UI form description Data access
  28. 28. Full stack Clojure Browser App Server Database ClojureScript Clojure Datomic
  29. 29. & Simplicity Advanced stuff Lisp Deconstruction
  30. 30. Advanced thinking Expressive power Fosters dev skills Advanced concurrency support Perfect for unit testing What's in for you? Concise data manipulation Interactive programming
  31. 31. Thank you. Questions? @friemens www.itemis.de
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×