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
500
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The design of Clojure
An outline of how the Clojure programming language is designed to be used.
Shantanu Kumar
February 28, 2016
More Decks by Shantanu Kumar
See All by Shantanu Kumar
BRACT: A Minimal DRY Application Framework
kumarshantanu
1
560
Functional Composition with Dependency Injection (IN/Clojure 2016)
kumarshantanu
0
700
Performance optimization with Code as Data in Clojure
kumarshantanu
0
910
Production Clojure: An Experience Report
kumarshantanu
2
1.6k
Other Decks in Programming
See All in Programming
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
240
Performance Engineering for Everyone
elenatanasoiu
0
240
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
280
はてなアカウント基盤 State of the Union
cockscomb
1
1.1k
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
330
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
7.1k
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
170
dRuby over BLE
makicamel
2
390
Agentic UI
manfredsteyer
PRO
0
200
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
120
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.4k
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.8k
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Everyday Curiosity
cassininazir
0
240
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
RailsConf 2023
tenderlove
30
1.5k
The Curious Case for Waylosing
cassininazir
1
410
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
440
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Prompt Engineering for Job Search
mfonobong
0
360
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
WENDY [Excerpt]
tessaabrams
11
38k
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