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
91
Introduction à Clojure
ptamarit
0
97
Other Decks in Programming
See All in Programming
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
130
Webフレームワークの ベンチマークについて
yusukebe
0
160
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
780
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.5k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
10
4k
AIで効率化できた業務・日常
ochtum
0
130
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
160
3Dシーンの圧縮
fadis
1
770
Oxlintのカスタムルールの現況
syumai
6
1.1k
ふつうのFeature Flag実践入門
irof
7
3.8k
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
150
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
190
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
Building AI with AI
inesmontani
PRO
1
1.1k
How to make the Groovebox
asonas
2
2.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Paper Plane (Part 1)
katiecoart
PRO
0
8.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Between Models and Reality
mayunak
4
330
The World Runs on Bad Software
bkeepers
PRO
72
12k
ラッコキーワード サービス紹介資料
rakko
1
3.6M
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
160
Art, The Web, and Tiny UX
lynnandtonic
304
22k
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)