SlideShare a Scribd company logo
Paradigms 
of 
core.async 
LambdaJam 
Brisbane 
Workshop 
May 
2014 
Julian 
Gamble 
@juliansgamble 
! 
Github 
repo 
http://bit.ly/ylj14-­‐clojure
Paradigms 
of 
core.async 
LambdaJam 
Brisbane 
Workshop 
May 
2014 
Julian 
Gamble 
@juliansgamble 
! 
Github 
repo 
http://bit.ly/ylj14-­‐clojure
Getting set up 
• Clone the repository at: 
• http://github.com/juliangamble/lambdajam-2014- 
core.async-workshop 
or http://bit.ly/ylj14-clojure 
• Or get a copy of the repository and the maven 
libraries from a usb (or sharing on my computer)
Benefits 
In this workshop you will gain an understanding of: 
• go blocks and how they do concurrency 
• core.async queues 
• go block timers 
• alts! functions and how it enables reading multiple queues 
• how core.async processes work in ClojureScript 
• the visual impacts of how the core.async function enables 
simple ‘process-level’ pauses 
• how to use core.async to separate out the calculation and 
display parts of your code
Benefits 
In this workshop you will gain an understanding of: 
• how to use core.async to send a queue of updates to the 
display layer 
• the original ants implementation Rich Hickey used to 
demonstrate concurrency features in Clojure 
• converting a Clojure code-base to ClojureScript 
• using shared data structures in ClojureScript 
• a working knowledge of converting a single-threaded 
ClojureScript application to a concurrent one using 
core.async
Requirements 
• Prerequisites are high! (No intro-to-lang classes) 
• Text editor 
• Leiningen installed 
• Internet connection preferable but not essential 
(Cloning github repo)
functional programming in 
Australia
functional programming in 
Australia
Overview 
• We have 7 items to work through: 
Item Description 
1-­‐references API 
Reference 
material 
2-­‐basic-­‐example core.async 
Hello 
World 
3-­‐basic-­‐multi-­‐chan-­‐example Handling 
multiple 
channels 
4-­‐tim-­‐baldridge-­‐10K-­‐processes Using 
core.async 
in 
ClojureScript 
5-­‐not-­‐10K-­‐processes Trying 
to 
mimic 
core.async 
in 
raw 
js 
6-­‐swanodette-­‐10K-­‐processes Using 
core.async 
for 
an 
animation 
pipeline 
in 
js 
7-­‐rich-­‐hickey-­‐original-­‐ants-­‐demo The 
Swing 
demo 
Rich 
Hickey 
used 
to 
demo 
Clojure 
concurrency 
8-­‐ants-­‐cljs-­‐no-­‐async The 
actual 
workshop 
(don’t 
look 
at 
solution 
unless 
you 
really 
need 
it)
How do the exercises work? 
Inside each of the 7 directories is a PDF with the 
following headings: 
• Code to Read 
• Things to Note In the Code 
• Code Model 
• Activities 
• Questions for Reflection
What is core.async? 
• A set of primitives for creating, reading and 
writing to queues 
• A code walking macro that splices go blocks 
into state machines 
• A mechanism for asynchronous computation 
• A library in both Clojure and Clojurescript
Why does it relate to functional 
programming? 
• Clojure is a functional language 
• Clojure’s immutable data structures are based on 
Okasaki’s book – Purely Functional Data Structures 
• We’ll be comparing different methods of solving 
concurrency problems in a functional language (STM 
vs CSP) 
• core.async is implemented using a sophisticated Lisp 
macro - something only possible in a functional 
language 
• in non-functional languages like Go and C# - CSP is 
achieved by compiler-extensions - whereas in a 
functional language like Clojure - this functionality 
comes as a mere library
What is CSP? 
• Communicating Sequential Processes 
• Comes out of process calculi – an attempt in the 
1970’s [Transputer era] to optimise computer 
usage through specialised algebra. 
• Based on message passing via 
channels 
• Subject of 1978 Book by C.A.R. Hoare
2-basic-example 
• Open the PDF and then the code 
-­‐main 
function 
first 
go 
block 
second 
go 
>! my-­‐q block <!
2-basic-example
2-basic-example
3-basic-multi-chan-example 
-­‐main 
function 
first 
go 
block 
third 
go 
block 
>! my-­‐q1 
alts! 
second 
go 
block my-­‐q2 >!
Applying the paradigms of core.async in Clojure and ClojureScript
3-basic-multi-chan-example
4-tim-baldridge-10K-processes 
make-­‐scene 
function 
make-­‐cell 
function 
10K 
go 
block 
1. Set 
colour 
2. Paint 
canvas 
cell 
3. Pause 
for 
random 
interval 
4. Loop
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
5-not-10K-processes 
makeScene 
function 
10K 
makeCell 
function 
mainLoop 
function 
100
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
6-swanodette-10K-processes 
[idx 
v] [idx 
v] 
let 
block ‘render’ render-­‐loop ‘queue’ render! 
core.async 
channel parameter 
passed 
in 
during 
function 
call
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
7-rich-hickey-original-ants-demo 
-­‐main 
function 
send-­‐off send-­‐off send-­‐off 
animation 
agent 
ant 
behaviour 
agent 
evaporation 
agent 
world 
symbol 
(vector 
of 
vectors)
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
8-ants-cljs-no-async 
animate 
function 
requestAnimationFrame 
single 
call single 
call single 
send-­‐off-­‐ 
animation 
function 
behave-­‐ants 
function 
(callback) 
evaporate 
function 
world 
symbol 
(vector 
of 
vectors) 
call
Applying the paradigms of core.async in Clojure and ClojureScript
Applying the paradigms of core.async in Clojure and ClojureScript
Workshop Activity 
• Make the changes described in pdf #8 to 
change this to a core.async ClojureScript 
program 
• Then work through the challenges in the 
‘Questions for Reflection’ question
Questions? 
LambdaJam 
Brisbane 
Workshop 
May 
2014 
Julian 
Gamble 
@juliansgamble 
! 
Github 
repo 
http://bit.ly/ylj14-­‐clojure 
[Then the final slide]
Applying the paradigms of core.async in Clojure and ClojureScript

More Related Content

PDF
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
KEY
About Clack
PPTX
Lisp in the Cloud
PPTX
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
KEY
Hybrid concurrency patterns
PDF
Steamlining your puppet development workflow
KEY
Actors and Threads
ODP
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
About Clack
Lisp in the Cloud
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Hybrid concurrency patterns
Steamlining your puppet development workflow
Actors and Threads
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp

What's hot (20)

PDF
Woo: Writing a fast web server
PDF
Building GUI App with Electron and Lisp
PDF
Clack: glue for web apps
PPTX
Shellshock- from bug towards vulnerability
PDF
Ruby in office time reboot
PDF
An introduction and future of Ruby coverage library
PDF
JavaScript Language Update 2016 (LLoT)
ODP
Developing high-performance network servers in Lisp
PDF
Woo: Writing a fast web server @ ELS2015
PDF
Puppet Development Workflow
PDF
Writing a fast HTTP parser
PDF
Understand How Node.js and Core Features Works
PPTX
Parsing and Rewriting Ruby Templates
KEY
Building MapAttack
PDF
Ansible
PDF
Ansible - Hands on Training
PDF
Back to the future: Isomorphic javascript applications
PDF
20140425 ruby conftaiwan2014
PDF
But we're already open source! Why would I want to bring my code to Apache?
PDF
20140419 oedo rubykaigi04
Woo: Writing a fast web server
Building GUI App with Electron and Lisp
Clack: glue for web apps
Shellshock- from bug towards vulnerability
Ruby in office time reboot
An introduction and future of Ruby coverage library
JavaScript Language Update 2016 (LLoT)
Developing high-performance network servers in Lisp
Woo: Writing a fast web server @ ELS2015
Puppet Development Workflow
Writing a fast HTTP parser
Understand How Node.js and Core Features Works
Parsing and Rewriting Ruby Templates
Building MapAttack
Ansible
Ansible - Hands on Training
Back to the future: Isomorphic javascript applications
20140425 ruby conftaiwan2014
But we're already open source! Why would I want to bring my code to Apache?
20140419 oedo rubykaigi04
Ad

Similar to Applying the paradigms of core.async in Clojure and ClojureScript (20)

PDF
Clojure+ClojureScript Webapps
PDF
Intro to Clojure's core.async
PDF
Error Handling in Reactive Systems
PDF
Functional (web) development with Clojure
PDF
Pivorak Clojure by Dmytro Bignyak
PPTX
Clojure Fundamentals Course For Beginners
PDF
Clojure in real life 17.10.2014
PDF
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
PDF
Clojure 1.1 And Beyond
PDF
Exploring Clojurescript
PDF
Functional web with clojure
PDF
JavaFX GUI architecture with Clojure core.async
PDF
From Java to Parellel Clojure - Clojure South 2019
PDF
Introduction to Clojure
PDF
HelsinkiJS - Clojurescript for Javascript Developers
PDF
ClojureScript for the web
PPTX
Clojure 7-Languages
PDF
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
PDF
REPL Driven Mobile Development with Clojure(script)
ODP
Getting started with Clojure
Clojure+ClojureScript Webapps
Intro to Clojure's core.async
Error Handling in Reactive Systems
Functional (web) development with Clojure
Pivorak Clojure by Dmytro Bignyak
Clojure Fundamentals Course For Beginners
Clojure in real life 17.10.2014
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Clojure 1.1 And Beyond
Exploring Clojurescript
Functional web with clojure
JavaFX GUI architecture with Clojure core.async
From Java to Parellel Clojure - Clojure South 2019
Introduction to Clojure
HelsinkiJS - Clojurescript for Javascript Developers
ClojureScript for the web
Clojure 7-Languages
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
REPL Driven Mobile Development with Clojure(script)
Getting started with Clojure
Ad

Recently uploaded (20)

PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
medical staffing services at VALiNTRY
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
L1 - Introduction to python Backend.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Softaken Excel to vCard Converter Software.pdf
medical staffing services at VALiNTRY
How to Migrate SBCGlobal Email to Yahoo Easily
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
2025 Textile ERP Trends: SAP, Odoo & Oracle
Design an Analysis of Algorithms I-SECS-1021-03
L1 - Introduction to python Backend.pptx
history of c programming in notes for students .pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
How Creative Agencies Leverage Project Management Software.pdf
Reimagine Home Health with the Power of Agentic AI​
Odoo POS Development Services by CandidRoot Solutions
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx

Applying the paradigms of core.async in Clojure and ClojureScript

  • 1. Paradigms of core.async LambdaJam Brisbane Workshop May 2014 Julian Gamble @juliansgamble ! Github repo http://bit.ly/ylj14-­‐clojure
  • 2. Paradigms of core.async LambdaJam Brisbane Workshop May 2014 Julian Gamble @juliansgamble ! Github repo http://bit.ly/ylj14-­‐clojure
  • 3. Getting set up • Clone the repository at: • http://github.com/juliangamble/lambdajam-2014- core.async-workshop or http://bit.ly/ylj14-clojure • Or get a copy of the repository and the maven libraries from a usb (or sharing on my computer)
  • 4. Benefits In this workshop you will gain an understanding of: • go blocks and how they do concurrency • core.async queues • go block timers • alts! functions and how it enables reading multiple queues • how core.async processes work in ClojureScript • the visual impacts of how the core.async function enables simple ‘process-level’ pauses • how to use core.async to separate out the calculation and display parts of your code
  • 5. Benefits In this workshop you will gain an understanding of: • how to use core.async to send a queue of updates to the display layer • the original ants implementation Rich Hickey used to demonstrate concurrency features in Clojure • converting a Clojure code-base to ClojureScript • using shared data structures in ClojureScript • a working knowledge of converting a single-threaded ClojureScript application to a concurrent one using core.async
  • 6. Requirements • Prerequisites are high! (No intro-to-lang classes) • Text editor • Leiningen installed • Internet connection preferable but not essential (Cloning github repo)
  • 9. Overview • We have 7 items to work through: Item Description 1-­‐references API Reference material 2-­‐basic-­‐example core.async Hello World 3-­‐basic-­‐multi-­‐chan-­‐example Handling multiple channels 4-­‐tim-­‐baldridge-­‐10K-­‐processes Using core.async in ClojureScript 5-­‐not-­‐10K-­‐processes Trying to mimic core.async in raw js 6-­‐swanodette-­‐10K-­‐processes Using core.async for an animation pipeline in js 7-­‐rich-­‐hickey-­‐original-­‐ants-­‐demo The Swing demo Rich Hickey used to demo Clojure concurrency 8-­‐ants-­‐cljs-­‐no-­‐async The actual workshop (don’t look at solution unless you really need it)
  • 10. How do the exercises work? Inside each of the 7 directories is a PDF with the following headings: • Code to Read • Things to Note In the Code • Code Model • Activities • Questions for Reflection
  • 11. What is core.async? • A set of primitives for creating, reading and writing to queues • A code walking macro that splices go blocks into state machines • A mechanism for asynchronous computation • A library in both Clojure and Clojurescript
  • 12. Why does it relate to functional programming? • Clojure is a functional language • Clojure’s immutable data structures are based on Okasaki’s book – Purely Functional Data Structures • We’ll be comparing different methods of solving concurrency problems in a functional language (STM vs CSP) • core.async is implemented using a sophisticated Lisp macro - something only possible in a functional language • in non-functional languages like Go and C# - CSP is achieved by compiler-extensions - whereas in a functional language like Clojure - this functionality comes as a mere library
  • 13. What is CSP? • Communicating Sequential Processes • Comes out of process calculi – an attempt in the 1970’s [Transputer era] to optimise computer usage through specialised algebra. • Based on message passing via channels • Subject of 1978 Book by C.A.R. Hoare
  • 14. 2-basic-example • Open the PDF and then the code -­‐main function first go block second go >! my-­‐q block <!
  • 17. 3-basic-multi-chan-example -­‐main function first go block third go block >! my-­‐q1 alts! second go block my-­‐q2 >!
  • 20. 4-tim-baldridge-10K-processes make-­‐scene function make-­‐cell function 10K go block 1. Set colour 2. Paint canvas cell 3. Pause for random interval 4. Loop
  • 23. 5-not-10K-processes makeScene function 10K makeCell function mainLoop function 100
  • 26. 6-swanodette-10K-processes [idx v] [idx v] let block ‘render’ render-­‐loop ‘queue’ render! core.async channel parameter passed in during function call
  • 29. 7-rich-hickey-original-ants-demo -­‐main function send-­‐off send-­‐off send-­‐off animation agent ant behaviour agent evaporation agent world symbol (vector of vectors)
  • 35. 8-ants-cljs-no-async animate function requestAnimationFrame single call single call single send-­‐off-­‐ animation function behave-­‐ants function (callback) evaporate function world symbol (vector of vectors) call
  • 38. Workshop Activity • Make the changes described in pdf #8 to change this to a core.async ClojureScript program • Then work through the challenges in the ‘Questions for Reflection’ question
  • 39. Questions? LambdaJam Brisbane Workshop May 2014 Julian Gamble @juliansgamble ! Github repo http://bit.ly/ylj14-­‐clojure [Then the final slide]