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
Joy of Clojure
Search
John Biesnecker
March 02, 2012
Programming
4
600
Joy of Clojure
A very brief introduction to Clojure delivered at Barcamp Shanghai on March 3, 2012.
John Biesnecker
March 02, 2012
Tweet
Share
More Decks by John Biesnecker
See All by John Biesnecker
Product Design for Chimps
biesnecker
0
130
Other Decks in Programming
See All in Programming
組織で育むオブザーバビリティ
ryota_hnk
0
170
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
Oxlintはいいぞ
yug1224
5
1.3k
Implementation Patterns
denyspoltorak
0
280
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
640
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
CSC307 Lecture 09
javiergs
PRO
1
830
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
0
900
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
Vibe codingでおすすめの言語と開発手法
uyuki234
0
220
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
AI巻き込み型コードレビューのススメ
nealle
0
110
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
140
Thoughts on Productivity
jonyablonski
74
5k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
A Soul's Torment
seathinner
5
2.2k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
88
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
89
Transcript
The Joy of Clojure Clojure之乐 John Biesnecker twitter: @biesnecker 新浪微博:
@岳撼 Barcamp Shanghai, 03 March 2012
Quick show of hands. Clojure junkies? LISP hackers? Functional Programming
aficionados? Java nerds? How many of you are ...
(= :clojure [:lisp :functional :jvm])
(= :clojure [:lisp :functional :jvm])
http://xkcd.com/297/
(= :data :code) (= :code :data) homoiconicity
(+ 1 2) ;; => 3
(eval (list (symbol “+”) 1 2)) ;; => 3
macros extend the language seamlessly
(defmacro unless [condition & body] `(if (not ~condition) (do ~@body)))
;; (unless (= true false) ;; (println “You don’t understand booleans, do you?”))
(= :clojure [:lisp :functional :jvm])
functional, but not pedantic about it (sorry Haskell... we can
still be friends though, right?)
immutable by default (with managed mutability when you need it)
easier to reason about
expressive
;; sum of multiples of 27 under one million (reduce
+ (filter #(zero? (mod % 27)) (range 0 1e6))) ;; 18518981481
composable (small pieces, loosely joined)
;; functions are first-class object (defn increment-by-three [x] (+ x
3)) (defn contrived-example [avector afunction] (map afunction avector) ;; (contrived-example [1 2 3] increment-by-three) ;; => (4 5 6)
;; anonymous functions are easy (defn contrived-example [avector afunction] (map
afunction avector) ;; (contrived-example [1 2 3] #(+ % 3)) ;; => (4 5 6)
(= :clojure [:lisp :functional :jvm])
(almost) seamless interop with Java
(BigInteger. “12345678900987654321”) ;; returns a java.math.BigInteger object
most new languages have poor library support
Clojure has every library ever written in Java
;; writing a high-performance thread-safe cache is hard (import ‘com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap)
(import ‘com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder) (-> (ConcurrentLinkedHashMap$Builder.) (.maximumWeightedCapacity 1000) (.build)) ;; thanks, Google ;-)
(= :clojure [:lisp :functional :jvm])
did I mention killer concurrency support?
questions?
谢谢 Thank you