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
590
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
Kotlin 2.2が切り拓く: コンテキストパラメータで書く関数型DSLと新しい依存管理のかたち
knih
0
390
CloudflareのSandbox SDKを試してみた
syumai
0
120
HTTPじゃ遅すぎる! SwitchBotを自作ハブで動かして学ぶBLE通信
occhi
0
230
CSC509 Lecture 11
javiergs
PRO
0
300
FlutterKaigi 2025 システム裏側
yumnumm
0
550
自動テストのアーキテクチャとその理由ー大規模ゲーム開発の場合ー
segadevtech
2
930
Researchlyの開発で参考にしたデザイン
adsholoko
0
120
AIを駆使して新しい技術を効率的に理解する方法
nogu66
0
520
CSC509 Lecture 09
javiergs
PRO
0
290
ノーコードからの脱出 -地獄のデスロード- / Escape from Base44
keisuke69
0
670
例外処理を理解して、設計段階からエラーを見つけやすく、起こりにくく #phpconfuk
kajitack
12
5.7k
Amazon Bedrock Knowledge Bases Hands-on
konny0311
0
140
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
40
2.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.1k
Navigating Team Friction
lara
190
15k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
24
1.5k
Fireside Chat
paigeccino
41
3.7k
The Cult of Friendly URLs
andyhume
79
6.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
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