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
Haskell でアルゴリズムを抽象化する / 関数型言語で競技プログラミング
naoya
17
4.7k
Development of an App for Intuitive AI Learning - Blockly Summit 2025
teba_eleven
0
120
Benchmark
sysong
0
210
AWS CDKの推しポイント 〜CloudFormationと比較してみた〜
akihisaikeda
3
280
Team topologies and the microservice architecture: a synergistic relationship
cer
PRO
0
850
A comprehensive view of refactoring
marabesi
0
810
生成AIコーディングとの向き合い方、AIと共創するという考え方 / How to deal with generative AI coding and the concept of co-creating with AI
seike460
PRO
1
300
Webからモバイルへ Vue.js × Capacitor 活用事例
naokihaba
0
710
Javaのルールをねじ曲げろ!禁断の操作とその代償から学ぶメタプログラミング入門 / A Guide to Metaprogramming: Lessons from Forbidden Techniques and Their Price
nrslib
3
2k
機械学習って何? 5分で解説頑張ってみる
kuroneko2828
0
210
Cline指示通りに動かない? AI小説エージェントで学ぶ指示書の書き方と自動アップデートの仕組み
kamomeashizawa
1
540
コード書くの好きな人向けAIコーディング活用tips #orestudy
77web
3
320
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
7
480
Thoughts on Productivity
jonyablonski
69
4.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Speed Design
sergeychernyshev
31
1k
Fireside Chat
paigeccino
37
3.5k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
How to Ace a Technical Interview
jacobian
276
23k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Embracing the Ebb and Flow
colly
86
4.7k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
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