SlideShare a Scribd company logo
Clojure compiled to JS
A Introduction
@friemens
Agenda
Some general remarks (a.k.a „blah-blah“)
Getting started with the tooling
Exploring the language and core library
React / Om / core.async
Wrap up
Powerful core library
Why?
Functional programming
One language in backend and frontend
Unfamiliar tooling
Why not?
Too much for quick-and-dirty UI enhancements
An alien language
Sweet spot: full stack Clojure
ClojureScript
Clojure
Datomic
„Rich-Client“
in a browser
Backend
Database
Fundamentals
(a.k.a things-we-need-to-understand-first)
It's a Lisp (OMG!)
The core idea of Functional Programming™
A hosted language
Lispy syntax
Ordered
Associative
Function
Invocation
var x = [1,2,3];(def x [1 2 3])
(def m {:a “Foo“}) var m = {a: “Foo“};
function bar (a) {
return a + 42;
}
(defn bar [a]
(+ a 42))
bar(0);(bar 0)
The REPL*
Read-Eval-Print-Loop
*
Pure functions
Side effects
Context
The core idea of Functional Programming
Thou shalt not mutate in place
Mutability causes cognitive load
var x = [1,2,3];
foo(x);
After foo,
what's in x?
ClojureScript is built on immutability
(def x [1 2 3])
(foo x)
(assert (= x [1 2 3]))
… on efficient immutability
Structural
sharing
x x'
ClojureScript is a hosted language
Your host: the browser
Clojure Script
Getting started with the tooling
Ideal tooling
Browser
Console
Editor
REPL
Instant feedback
Highly recommended tutorial:
https://github.com/clojure/clojurescript/wiki/Quick-Start
cljs.jar
Or follow the steps on
https://github.com/adzerk-oss/boot-cljs-example
Getting started with Boot
Either use the example from
https://github.com/friemen/cugb/tree/master/cljsintro
Traditional architecture of UIs
View
Model Controller
Dataflow approach to UI
Om / React
core.async
App. State View
Databinding
App
state
DOM
event
updates
mutations
Controller
e.g. Angular
transform
render
diff + merge
DOM
App
state
swap
React+Om
Virtual DOM
event
DOM operations are
soooo sloooow.
Bi-directional
Uni-directional
Burn Hollywood Burn!*
Public Enemy (1990)
*
Callbacks are ok, but, uhm ...
function reloadAddressbook (state, event) {
ask("Are you sure?", function (answer) {
if (answer) {
ajax.get("/addresses", function (response) {
if (response.statusCode == 200) {
state.addresses.items = response.body;
}
});
}
});
}
Ask for confirmation
ok?
Issue GET request
success?
Replace items
But how do you implement concurrent requests?
CSP* with core.async = channels + go blocks
Communicating Sequential Processes, Tony Hoare (1978)
*
(def c1 (chan))
(go-loop [xs []]
(let [x (<! c1)]
(println "Got" x ", xs so far:" xs)
(recur (conj xs x))))
(put! c1 "foo")
;; outputs: Got bar , xs so far: [foo]
a blocking read
make a new channelcreates a
lightweight
process
async write
core.async: no need for callbacks
Ask for confirmation
ok?
Issue GET request
success?
Replace items
(defn <addressbook-reload
[state event]
(go (if (= :ok (<! (<ask "Are you sure?")))
(let [{s :status addresses :body}
(<! (http/get "/addresses"))]
(if (= 200 s)
(assoc-in state
[:addresses :items]
addresses)
state)))
Getting started with
React / Om / core.async
Wrap up
ClojureScript is ...
... overkill for little enhancements
… a mature language to tackle UI complexity
… demanding to learn, but this will pay-of
Links to resources on GitHub
https://github.com/friemen/cugb/
Thank you for listening!
Questions?
@friemens riemenschneider@doctronic.de

More Related Content

PDF
Painless Data Storage with MongoDB & Go
PPTX
Value protocols and codables
PPTX
ECMAScript 6 and the Node Driver
PPTX
Parse, scale to millions
PDF
Introduction to asynchronous DB access using Node.js and MongoDB
PDF
Redesigning Common Lisp
PDF
Getting Started with Go
PDF
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Painless Data Storage with MongoDB & Go
Value protocols and codables
ECMAScript 6 and the Node Driver
Parse, scale to millions
Introduction to asynchronous DB access using Node.js and MongoDB
Redesigning Common Lisp
Getting Started with Go
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...

What's hot (19)

PDF
2019 11-bgphp
PDF
Gogo shell
PDF
Javascript development done right
PDF
React for Beginners
PDF
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
PPTX
Javascript asynchronous
PDF
7 Common Mistakes in Go (2015)
PDF
Groovy Powered Clean Code
ODP
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
PDF
Go for Rubyists
PPT
Mobile webapplication development
PDF
Vidoop CouchDB Talk
PDF
XForms and eXist: A Perfect Couple
PPTX
Coroutines talk ppt
PDF
Happy Go Programming Part 1
PPTX
Writing data analysis pipeline as ruby gem
PDF
7 Common mistakes in Go and when to avoid them
PDF
Php assíncrono com_react_php
KEY
About Clack
2019 11-bgphp
Gogo shell
Javascript development done right
React for Beginners
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Javascript asynchronous
7 Common Mistakes in Go (2015)
Groovy Powered Clean Code
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Go for Rubyists
Mobile webapplication development
Vidoop CouchDB Talk
XForms and eXist: A Perfect Couple
Coroutines talk ppt
Happy Go Programming Part 1
Writing data analysis pipeline as ruby gem
7 Common mistakes in Go and when to avoid them
Php assíncrono com_react_php
About Clack
Ad

Viewers also liked (14)

PDF
Some basic FP concepts
PDF
Clojure - Why does it matter?
PDF
Clojure+ClojureScript Webapps
PDF
Making design decisions in React-based ClojureScript web applications
PDF
ClojureScript - A functional Lisp for the browser
PDF
An Adventure in Serverless ClojureScript
PDF
Why you should be excited about ClojureScript
PDF
JavaFX GUI architecture with Clojure core.async
PPTX
FlatGUI: Reactive GUI Toolkit Implemented in Clojure
PDF
All for Web development
PDF
Clojurescript slides
PDF
Thinking Functionally with Clojure
PPTX
CLI utility in ClojureScript running on Node.js
PDF
Build Features, Not Apps
Some basic FP concepts
Clojure - Why does it matter?
Clojure+ClojureScript Webapps
Making design decisions in React-based ClojureScript web applications
ClojureScript - A functional Lisp for the browser
An Adventure in Serverless ClojureScript
Why you should be excited about ClojureScript
JavaFX GUI architecture with Clojure core.async
FlatGUI: Reactive GUI Toolkit Implemented in Clojure
All for Web development
Clojurescript slides
Thinking Functionally with Clojure
CLI utility in ClojureScript running on Node.js
Build Features, Not Apps
Ad

Similar to ClojureScript Introduction (20)

PDF
ClojureScript for the web
PDF
Korolev: Single page apps running on server
PDF
Exploring Clojurescript
PPTX
Functional Programming with JavaScript
PPTX
Things about Functional JavaScript
PDF
Nodejs Explained with Examples
PDF
Nodejsexplained 101116115055-phpapp02
PDF
Nodejs - A quick tour (v6)
PPTX
JS Essence
KEY
Playing With Fire - An Introduction to Node.js
PDF
Node.js - A Quick Tour
PDF
Introduction to clojure
PDF
High Performance web apps in Om, React and ClojureScript
PPTX
Iron Languages - NYC CodeCamp 2/19/2011
KEY
JavaScript Growing Up
PPT
jimmy hacking (at) Microsoft
PDF
Nodejs - A quick tour (v5)
PDF
Origins of Elixir programming language
PPTX
Functional programming
KEY
NodeJS
ClojureScript for the web
Korolev: Single page apps running on server
Exploring Clojurescript
Functional Programming with JavaScript
Things about Functional JavaScript
Nodejs Explained with Examples
Nodejsexplained 101116115055-phpapp02
Nodejs - A quick tour (v6)
JS Essence
Playing With Fire - An Introduction to Node.js
Node.js - A Quick Tour
Introduction to clojure
High Performance web apps in Om, React and ClojureScript
Iron Languages - NYC CodeCamp 2/19/2011
JavaScript Growing Up
jimmy hacking (at) Microsoft
Nodejs - A quick tour (v5)
Origins of Elixir programming language
Functional programming
NodeJS

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Cloud computing and distributed systems.
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
A Presentation on Artificial Intelligence
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Encapsulation theory and applications.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
Teaching material agriculture food technology
PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Machine learning based COVID-19 study performance prediction
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Cloud computing and distributed systems.
Encapsulation_ Review paper, used for researhc scholars
A Presentation on Artificial Intelligence
Assigned Numbers - 2025 - Bluetooth® Document
Encapsulation theory and applications.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Network Security Unit 5.pdf for BCA BBA.
A comparative analysis of optical character recognition models for extracting...
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Teaching material agriculture food technology
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Machine learning based COVID-19 study performance prediction

ClojureScript Introduction