Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction to Clojure
Search
Pablo Tamarit
October 30, 2012
Programming
86
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Clojure
Pablo Tamarit
October 30, 2012
Transcript
22 slides
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)
More Decks by Pablo Tamarit
See All by Pablo Tamarit
From Bash to Z shell in 5 min
ptamarit
1
94
Introduction à Clojure
ptamarit
0
100
Other Decks in Programming
See All in Programming
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
1.3k
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
320
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
450
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
510
Skills Are the New npm [AAIF Bengaluru, Nov 2026]
shivamsaraswat
0
140
Canvas 2D Context Next
petamoriken
0
840
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
1
410
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
360
はじめてのPLATEAU
nokonoko1203
1
680
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
150
読みやすい!と評判(?)の発表の準備にかける私のこだわり
shoheimitani
0
170
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
650
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
529
40k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
410
The agentic SEO stack - context over prompts
schlessera
0
1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Documentation Writing (for coders)
carmenintech
77
5.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.4k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.5k
The Art of Programming - Codeland 2020
erikaheidi
57
15k
Into the Great Unknown - MozCon
thekraken
41
2.8k