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
360
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
420
Functional Composition with Dependency Injection (IN/Clojure 2016)
kumarshantanu
0
550
Performance optimization with Code as Data in Clojure
kumarshantanu
0
660
Production Clojure: An Experience Report
kumarshantanu
2
1.2k
Other Decks in Programming
See All in Programming
AppDeveloperCon 2024 EU: Building polyglot developer experiences in 2024
salaboy
0
380
document.write再考
brn
5
2.5k
Migrating to Signals: A Practical Workshop
manfredsteyer
PRO
0
280
phpunit/php-code-coverageって何をしてるんだ #phperkaigi
o0h
PRO
2
220
PHPerKaigi 2024〜10年以上動いているレガシーなバッチシステムを Kubernetes(Amazon EKS) に移行する取り組み〜
tshinowpub
1
220
LLMチャットボットのアプリケーション設計Tips
os1ma
4
660
[スクリプト] Swiftの型推論を学ぼう
omochi
0
110
WebComponentsで フレームワークを1ページに共存させる
webuilder240
0
150
上手な探索的テストとその上達方法について
matsu802
4
650
WasmOS: Wasmを実行する自作Microkernel
riru
0
370
「コンパイル時のユニットテスト」導入するとユニットテストを 書かなくてよくなるのか?
tomohisa
9
2.2k
TCAの Shared Stateって どういう仕組みになってんの?
yimajo
0
330
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
Agile that works and the tools we love
rasmusluckow
323
20k
The Cult of Friendly URLs
andyhume
73
5.6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
352
28k
Debugging Ruby Performance
tmm1
68
11k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
11
1.4k
Rebuilding a faster, lazier Slack
samanthasiow
72
8.2k
We Have a Design System, Now What?
morganepeng
42
6.7k
Six Lessons from altMBA
skipperchong
19
2.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
A Modern Web Designer's Workflow
chriscoyier
689
190k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
178
11k
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