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
The design of Clojure
Search
Shantanu Kumar
February 28, 2016
Programming
0
450
The design of Clojure
An outline of how the Clojure programming language is designed to be used.
Shantanu Kumar
February 28, 2016
Tweet
Share
More Decks by Shantanu Kumar
See All by Shantanu Kumar
BRACT: A Minimal DRY Application Framework
kumarshantanu
1
530
Functional Composition with Dependency Injection (IN/Clojure 2016)
kumarshantanu
0
660
Performance optimization with Code as Data in Clojure
kumarshantanu
0
800
Production Clojure: An Experience Report
kumarshantanu
2
1.5k
Other Decks in Programming
See All in Programming
코딩 에이전트 체크리스트: Claude Code ver.
nacyot
0
990
AI Ramen Fight
yusukebe
0
110
AIのメモリー
watany
11
970
ご注文の差分はこちらですか? 〜 AWS CDK のいろいろな差分検出と安全なデプロイ
konokenj
4
680
PHPUnitの限界をPlaywrightで補完するテストアプローチ
yuzneri
0
290
Yes, You Can Work on Rails & any other Gem
kaspth
0
110
型で語るカタ
irof
1
820
おやつのお供はお決まりですか?@WWDC25 Recap -Japan-\(region).swift
shingangan
0
150
Understanding Kotlin Multiplatform
l2hyunwoo
0
170
20250708_JAWS_opscdk
takuyay0ne
2
150
オンコール⼊⾨〜ページャーが鳴る前に、あなたが備えられること〜 / Before The Pager Rings
yktakaha4
2
1.1k
ZeroETLで始めるDynamoDBとS3の連携
afooooil
0
120
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
126
53k
Speed Design
sergeychernyshev
32
1k
A Modern Web Designer's Workflow
chriscoyier
695
190k
Side Projects
sachag
455
43k
Visualization
eitanlees
146
16k
Git: the NoSQL Database
bkeepers
PRO
431
65k
Unsuck your backbone
ammeep
671
58k
Making the Leap to Tech Lead
cromwellryan
134
9.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
BBQ
matthewcrist
89
9.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Transcript
The Design of Clojure Shantanu Kumar, Concur 1
Who am I? • Engineer @ Concur • Author of
“Clojure High Performance Programming” • Open Source enthusiast: https://github.com/ kumarshantanu • @kumarshantanu on Twitter 2
Clojure • Created by Rich Hickey, 2007 • Eclipse Public
License (OSS) • Website — https://clojure.org/ • Lisp • Functional • Hosted on JVM (and CLR, JS) 3
Big ideas • Pervasive immutability (Epochal time model) • First-class
values • First-class functions • Performance • Host interoperability • First-class state management 4
–Stuart Halloway “Clojure feels like a general-purpose language beamed back
from the near future.” 5
Getting started with Clojure http://leiningen.org/ https://learnxinyminutes.com/docs/clojure/ http://www.braveclojure.com/ https://www.4clojure.com/ 6
Interactive REPL 7
Data types • Number: 42, -5.67, 22/7 • Boolean: true,
false • Character: \x, \y, \newline, \space • String: “foo”, “bar” (multi-line literals are supported) • Symbol: ‘do-something, ‘bizfn • Keyword: :red, :blue • Nothing: nil 8
Data structures • List: ‘(“Harry” 34 :male) — sequential access
• Map: {:name “Harry” :age 34} • Set: #{:red :blue} • Vector: [“Harry” 34 :male] 9
Working with data structures 10
Functions 11
Code is data 12
Persistent Data-structures • Immutable (updates return new instances) • Structure
sharing (Hash array mapped trie) • 32-way branching for O(<7) performance • Sustained performance across updates • Reference: “Ideal Hash Trees” (Phil Bagwell) 13
Working with collections 14
I want a loop! No automatic tail-call optimization 15
–Alan J Perlis “A language that doesn't affect the way
you think about programming, is not worth knowing.” 16
Records 17
Records • Class semantics (memory layout) • Behave as maps
• Immutable in the same way as maps 18
Protocols 19
Protocols • Behaviour contract • Polymorphism • Dispatch on target
object type • Used as implementation details 20
No structural inheritance! But, there are value hierarchies Image source:
https://xspblog.files.wordpress.com/2008/06/owl_yarly.jpg 21
Macros 22
Sample output 23
Macros • Compile-time code manipulation • Because code is data
24
Java interop 25
Concurrent execution • CPU-bound and I/O-bound thread pools • `future`:
Asynchronous one-time access • `pmap`: Concurrent CPU-bound processing • `promise/deliver`: Single producer-consumer • Java’s concurrent collections considered idiomatic 26
Concurrency and state • Atoms — uncoordinated compare and swap
• Agents — asynchronous sequential operations • Refs — Software Transactional Memory • Dynamic vars — Thread-local access 27
Thank you! @kumarshantanu 28