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
460
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
670
Performance optimization with Code as Data in Clojure
kumarshantanu
0
820
Production Clojure: An Experience Report
kumarshantanu
2
1.5k
Other Decks in Programming
See All in Programming
LLMとPlaywright/reg-suitを活用した jQueryリファクタリングの実際
kinocoboy2
4
680
チームの境界をブチ抜いていけ
tokai235
0
110
Django Ninja による API 開発効率化とリプレースの実践
kashewnuts
0
1.1k
Breaking Up with Big ViewModels — Without Breaking Your Architecture (droidcon Berlin 2025)
steliosf
PRO
1
350
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
950
XP, Testing and ninja testing ZOZ5
m_seki
3
380
AI Coding Meetup #3 - 導入セッション / ai-coding-meetup-3
izumin5210
0
640
実践AIチャットボットUI実装入門
syumai
7
2.5k
CSC305 Lecture 03
javiergs
PRO
0
240
ネイティブ製ガントチャートUIを作って学ぶUICollectionViewLayoutの威力
jrsaruo
0
140
Six and a half ridiculous things to do with Quarkus
hollycummins
0
130
Serena MCPのすすめ
wadakatu
4
920
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
53
7.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
45
2.5k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
960
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Why Our Code Smells
bkeepers
PRO
339
57k
How to Ace a Technical Interview
jacobian
280
24k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.2k
Practical Orchestrator
shlominoach
190
11k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
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