Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Clojure
Search
Pablo Tamarit
October 30, 2012
Programming
81
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Clojure
Pablo Tamarit
October 30, 2012
More Decks by Pablo Tamarit
See All by Pablo Tamarit
From Bash to Z shell in 5 min
ptamarit
1
92
Introduction à Clojure
ptamarit
0
98
Other Decks in Programming
See All in Programming
30年振りにコンパイラの定数整数除算を改善した
herumi
7
2.8k
VibeCodingからAgenticWorkflowへ
starfish719
0
730
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
260
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
220
typoなんかねぇよ
raspython3
0
190
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.9k
リアルな遅延を測る仕様
kota_yata
1
120
FDEが実現するAI駆動経営の現在地
gonta
2
290
仕様駆動開発の消費期限
watany
20
8.8k
MySQLとPostgreSQLって何が違うの?
akagami
0
120
SlackアプリとLambdaの 連携を構築した話
pawn_4_s
1
130
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.4k
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
580
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
380
Thoughts on Productivity
jonyablonski
76
5.3k
The World Runs on Bad Software
bkeepers
PRO
72
12k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Designing Experiences People Love
moore
143
24k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
240
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Are puppies a ranking factor?
jonoalderson
2
3.8k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
550
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
370
Transcript
Introduction to Clojure Pablo Tamarit October 30, 2012 GenevaJUG
? 2000 2001 2002 2003 2004 2005 2006 2007 2008
2009 2010 2011 2012 1999 - 2005 EIG 2007 - 2049 CERN
(def basket [{:name "apples", :type :fruits} {:name "pears", :type :fruits}
{:name "scoubidous", :type :objects}]) (group-by :type basket) {:fruits [{:type :fruits, :name "apples"} {:type :fruits, :name "pears"}], :objects [{:type :objects, :name "scoubidous"}]} Sampling
• Philosophical part • Theoretical part • Practical part
Philosophical part
Clojure • Created in 2007 • Simplicity • Not object
oriented! • Dynamic typing • Everything is immutable • No state • No side effects • Dialect of Lisp! + λ
Lisp • Invented in 1958
John McCarthy 1927 – 2011
Lisp • Invented in 1958 • Lots of Irritating Superfluous
Parentheses?
Lisp • Invented in 1958 • Lots of Irritating Superfluous
Parentheses • Homoiconicity • Macros paulgraham.com/avg.html
Theoretical part
Language • Simple syntax, rich vocabulary. – Syntax: data, functions
– Vocabulary: functions clojure.org/cheatsheet
Syntax: collections List ("one" 2 3 3) Vector ["one" 2
3 3] Set #{"one" 2 3} Map {:name "Pablo", :age 28} (:age {:name "Pablo", :age 28}) 28
Syntax: functions Call (+ 1 2 3) Definition (defn abs
[n] (if (neg? n) (- n) n)) Anonymous definition (fn [x y] (+ (abs x) (abs y))) Sugared anonymous definition #(+ (abs %1) (abs %2)) condition then else vector list fn args
Vocabulary: functions (def coll [-42 5 -0.1]) (map abs coll)
(42 5 0.1) (reduce + 0 coll) -37.1 (filter neg? coll) (-42 -0.1)
Interop Java Clojure new JFrame("Titre") (JFrame. "Titre") Color.RED Color/RED frame.setTitle("Titre2")
(.setTitle frame "Titre2") frame.getTitle().toLowerCase() (.. frame getTitle toLowerCase) frame.add(panel) frame.pack() frame.setVisible(true) (doto frame (.add panel) (.pack) (.setVisible true)) 2 4 1 3
Practical part
What to install? • Nothing! <dependency> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> <version>1.4.0</version> </dependency>
• What’s in the JAR? – The library – REPL: java -jar clojure.jar – Compiler: .clj .class
Tools • Build – leiningen – clojure-maven-plugin • IDE –
Counterclockwise (Eclipse) – La Clojure (IntelliJ IDEA) – Emacs!
Resources • Presentations: – blip.tv/clojure – infoq.com/clojure • Books: –
clojurebook.com – joyofclojure.com • Exercises: – 4clojure.com
Questions?
Image credits • Clojure logo: © Tom Hickey (tomhickey.com) •
Aerial view of the LHC: © 2001 CERN (cdsweb.cern.ch/record/42370) • The Treachery of Images: © 1929 René Magritte • Duke models: © Sun Microsystems Inc. (duke.kenai.com/models) • Portrait of John McCarthy: © 2006 null0 (flic.kr/p/q39Sg) • The Call of the Peaks: © 1942 René Magritte • Clairvoyance: © 1936 René Magritte • Cooled Beans: © 2008 Chris Bay (flic.kr/p/4z6CBA) • Gears: © Dima Yagnyuk (thenounproject.com/noun/gears/#icon- No2174, thenounproject.com/Deadtype) • Tools: © Jacob Hardbower (thenounproject.com/noun/tools/#icon- No4684, thenounproject.com/HeartWired)