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
470
0
Share
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
550
Functional Composition with Dependency Injection (IN/Clojure 2016)
kumarshantanu
0
690
Performance optimization with Code as Data in Clojure
kumarshantanu
0
880
Production Clojure: An Experience Report
kumarshantanu
2
1.6k
Other Decks in Programming
See All in Programming
存在論的プログラミング: 時間と存在を記述する
koriym
5
780
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.8k
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
3
510
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
130
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
300
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
540
へんな働き方
yusukebe
6
2.9k
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.5k
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
540
事業会社でのセキュリティ長期インターンについて
masachikaura
0
230
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3k
Coding at the Speed of Thought: The New Era of Symfony Docker
dunglas
0
4.6k
Featured
See All Featured
Unsuck your backbone
ammeep
672
58k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Navigating Weather and Climate Data
rabernat
0
160
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
700
The Invisible Side of Design
smashingmag
302
51k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
180
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.8k
Chasing Engaging Ingredients in Design
codingconduct
0
160
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
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