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
420
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
490
Functional Composition with Dependency Injection (IN/Clojure 2016)
kumarshantanu
0
630
Performance optimization with Code as Data in Clojure
kumarshantanu
0
740
Production Clojure: An Experience Report
kumarshantanu
2
1.4k
Other Decks in Programming
See All in Programming
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
370
快速入門可觀測性
blueswen
0
450
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
340
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
800
良いユニットテストを書こう
mototakatsu
11
3.4k
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
560
iOS開発におけるCopilot For XcodeとCode Completion / copilot for xcode
fuyan777
1
700
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
330
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
600
103 Early Hints
sugi_0000
1
280
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
210
fs2-io を試してたらバグを見つけて直した話
chencmd
0
260
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
9k
We Have a Design System, Now What?
morganepeng
51
7.3k
Making the Leap to Tech Lead
cromwellryan
133
9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
The Cult of Friendly URLs
andyhume
78
6.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Designing for humans not robots
tammielis
250
25k
The Invisible Side of Design
smashingmag
299
50k
Code Review Best Practice
trishagee
65
17k
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