Clojure - Why does it matter?
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Clojure - Why does it matter?

on

  • 686 views

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

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

Statistics

Views

Total Views
686
Views on SlideShare
641
Embed Views
45

Actions

Likes
0
Downloads
3
Comments
0

2 Embeds 45

https://twitter.com 44
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Clojure - Why does it matter? Presentation Transcript

  • 1. Clojure Why does it matter? @friemens
  • 2. ● Published 2008 by Rich Hickey. ● Dynamically typed. ● Compiles to bytecode. A pragmatic Lisp for the JVM
  • 3. & Simplicity Advanced stuff Lisp Deconstruction
  • 4. & Simplicity Advanced stuff Lisp Deconstruction
  • 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. Design is deconstruction Small libraries, no big frameworks! HTTP server Middle- ware functions Routing function Handler functions Page renderer
  • 7. Deconstructing the database Datomic A modular, facts-based database system. Storage service Transactor Query Cache Peer library Application Database
  • 8. State and Identity OO style (conflated) Clojure style (separated)
  • 9. & Simplicity Advanced stuff Lisp Deconstruction
  • 10. & Simplicity Advanced stuff Lisp Deconstruction
  • 11. Huh? Lisp? Lisp! Other Languages Time Expressive Power
  • 12. The elegance of Lisp
  • 13. http://xkcd.com/297
  • 14. Functional programming Functions as values Powerful data structures „[...] a unit tester's wet dream.“ No assignments Laziness
  • 15. Example: Square root approximation gn+1 := (n/gn + gn) / 2
  • 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. Prefer purity Pure functions Side effects Context
  • 18. Code is data, or: why does Lisp look different? Code Data
  • 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. A powerful language allows for simpler tools
  • 21. Interactive development Demo
  • 22. & Simplicity Advanced stuff Lisp Deconstruction
  • 23. & Simplicity Advanced stuff Lisp Deconstruction
  • 24. Persistent datastructures 0 1 2 3 4 5 6 6 7 8 9 10 7
  • 25. Concurrency support Actor style: Pulsar librarySoftware Transactional Memory CSP style: core.async library Widely used: Synchronization and LockingJava Clojure
  • 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. Internal DSLs just happen HTTP routing UI form description Data access
  • 28. Full stack Clojure Browser App Server Database ClojureScript Clojure Datomic
  • 29. & Simplicity Advanced stuff Lisp Deconstruction
  • 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. Thank you. Questions? @friemens www.itemis.de