istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear...
Transcript of istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear...
![Page 2: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/2.jpg)
Motivation
• Software Development is about taking things apart.
• Clojure is a simple and elegant language.“Simplicity is a pre-requisite for reliability” (Dijkstra)
• Clojure demands that you raise your game, and pays you back for doing so.
![Page 3: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/3.jpg)
Why Clojure?
• Extremely expressive language
• First-class functions
• Awesome Java Interop abilities
• Power of lisp (macros, function composition)
• FUNctional
![Page 4: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/4.jpg)
Why Lisp?
• Little Syntax to Learn
• Say a lot more with less code, fewer lines, fewer bugs
• Bend your language to the problem, not the other way around
• Code as Data
![Page 5: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/5.jpg)
Why Lisp?
When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying: "I tried one of those bananas, which you say are so delicious. The white part was ok, but the yellow part was very tough and tasted awful.
Paul Graham
![Page 6: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/6.jpg)
Functional Programming
• OOP makes code understandable by encapsulating moving parts
• FP makes code understandable by minimizing moving parts
!• Better fit for concurrency and multicore architectures
![Page 7: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/7.jpg)
Agility!
• Architectural agility is the agility you get from building a system that is fundamentally simple.
• Simplicity enables change, it’s the primary source of real agility.
• If you’re dragging an elephant around you’re never going to be agile
* “Simple Made Easy” by Rich Hickey
![Page 8: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/8.jpg)
Simple Use Case
CommandExecutor.java
Executes the command that is described in the “command description”
Result and Document are wrappers around java.util.Map
Step1: Design
Step2: Implement & TestHttpCommandExecutor.java JmxCommandExecutor.java JmsCommandExecutor.java
Step3: Integrate
CommandExecutorService.java
ExecutorRegistry.java
![Page 9: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/9.jpg)
Simple Use CaseStep3: Integrate
DelegatingCommandExecutorService.java
SimpleExecutorRegistry.java
![Page 10: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/10.jpg)
Simple Use CaseStep4: In Action
someApplicationContext.xml
![Page 11: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/11.jpg)
This is brilliant if you are charging by the hour
![Page 12: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/12.jpg)
Simple Use Case - ClojureDelegator
Code for one of the handlers (Bonus)
![Page 13: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/13.jpg)
What Clojure Looks Like
int function ( ) { return 5; }
( fn [ ] 5 )
1+1; (+ 1 1)
System.out.println(“Hello World!”); (println “Hello World!”)
![Page 14: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/14.jpg)
Clojure Introduction - Language Primitives
Boolean true, falseCharacter \aKeyword :a, :b
List (1 2 3), (println x)Map {:marka "Bmw", :model “320d”, :renk “mavi”}Nil nil
Number 1, 4.5Set #{“a” “b” “c”}
String “Ola!”Symbol user/foo, java.lang.StringVector [1 2 3]
![Page 15: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/15.jpg)
Clojure Introduction - Special FormsEvery form not handled specially by a special form or macro is considered by the compiler to be an expression, which is evaluated to yield a value.
def (def symbol init?)
if (if test then else?)
do (do exprs*)
let (let [bindings* ] exprs*)
quote (quote form)
var (var symbol)
fn (fn name? [params* ] exprs*)
loop (loop [bindings* ] exprs*)
recur (recur exprs*)
try/catch/throw (try expr* catch-clause* finally-clause?)
![Page 16: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/16.jpg)
Clojure Introduction - Functions
![Page 17: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/17.jpg)
Clojure Introduction - Collections
{ } Map {“a” 1 “b” 2}
#{ } Set {“a” “b” “c”}
‘( ) List ‘(1 2 3)
[ ] Vector [“a” “b” “c”]
The trick is to efficiently use primitive data structures and library functions
![Page 18: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/18.jpg)
Clojure Introduction - Examples
=>(doc map)…… !=>(map inc [3 4 5]) (4 5 6) !=> (doc reduce) ……. !=> (reduce + [3 4 5]) 12 !
![Page 19: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/19.jpg)
Clojure Introduction - Examples=>(doc filter)…… !=> (filter even? [1 2 3 4]) (2 4) !=> (doc remove) …… !=> (remove nil? [1 nil 2 nil]) (1 2) !!!
=>(doc reductions)…… !=> (reductions + [1 2 3 4]) (1 3 6 10) !=> (doc remove) …… !=> (remove nil? [1 nil 2 nil]) (1 2) !!!
![Page 20: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/20.jpg)
Clojure Introduction - Key Concepts
• Leiningen (Clojure Build Tool) !
• Repl !
• Emacs !
• CounterClockwise (Eclipse Plugin) !
• La Clojure / Cursive (Idea Plugins) !
• JVM tools
![Page 21: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/21.jpg)
Who is Using Clojure
• Nokia Maps • Twitter • Factual • Lumosity • YieldBot • USwitch • Climate • Akamai • Citi • Nugg • Prismatic • Netflix
![Page 22: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/22.jpg)
Clojure @Sebula
• Distributed Crawler that supports Http, MongoDB, JDBC
RedisStorm Spout
Storm Bolts
Manager
HTTPMongoDB JDBC
Storm Bolts
Elastic Search
![Page 23: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/23.jpg)
Clojure @Sebula• Unique Delay queue with Carmine (Redis Library)
![Page 24: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/24.jpg)
Clojure @Sebula
• Quartize (Quartz Library)
![Page 25: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/25.jpg)
Clojure @Sebula
• Search Analytics • Flume, Cassandra, Cascading, Cascalog
Elasticsearch Cluster
Flume Collector (Clojure)
Elasticsearch Cluster
Flume Collector (Clojure) Cassandra
Rest
(Cascalog & Clojure)
Dashboard
![Page 26: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/26.jpg)
Clojure @Sebula
• Rcmmndr: Hadoop & Cassandra Integration
Http Collector (Clojure)
Http Collector (Clojure) Cassandra
Mahout Manager (Clojure)
Rest Backend
Rest Backend
![Page 27: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/27.jpg)
Clojure In Depth
• Collections & Data Structures • Destructuring • State & Concurrency & Parallelism • Macros • Protocols & Datatypes • MultiMethods • Java Interoperability
![Page 28: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/28.jpg)
Talks
• Simple Made Easy by Rich Hickey !
• Narcissistic Design - Stuart Halloway
![Page 29: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/29.jpg)
Books
• Land of Lisp • Clojure Programming • Programming Clojure
![Page 30: istanbul hackers clojureistanbulcoders.org/assets/meetups/2013-11-07... · Why Lisp? When I hear people complain about Lisp's parentheses, it sounds to my ears like someone saying:](https://reader030.fdocuments.us/reader030/viewer/2022041019/5ece3e7b46e8db7f82263df1/html5/thumbnails/30.jpg)
Resources• Programming Clojure • ClojureWerkz Clojure Workshop: http://clojureworkshop.com/ • Working with Legacy Code • clojureist.com • IstanbulCoders.org • [email protected]