SlideShare a Scribd company logo
Functional
(web) development
with Clojure
Why functional programming?
Introduction.
Clojure is a strongly typed,
dynamic, functional programming
language that is defined in terms
of its own persistent data structures.
Introduction.
Introduction.
Primary performance
bottleneck
Complexity
Introduction.
Ability to comprehend complexity
Normal person Smartest person in the world
Complexity
Introduction.
Have to bring the complex
thing closer to us. The other
way around doesn’t work.
Introduction.
Hence, Clojure.
Functional programming is only
interesting to the degree it helps
us achieve this goal.
Clojure provides tools for the mind
rather than for the machine.
Introduction.
Persistent (immutable) data structures
Object/stateless programming model
Software Transactional Memory (STM)
Powerful data processing and transformation tools
Powerful data validation and testing tools
Strongly and optionally typed
Powerful (and easy) concurrency+parallelism
Instant feedback-driven development
Hosted on several platforms
Features of the language.
Variables complects* time and state.
Objects complects time, state and identity.
Methods complects function and state.
Syntax complects order and meaning.
…
The real features of the language.
*To complect: to create complexity, usually by
intertwining two or more unrelated concepts
Values
Values
Functions
Data
…
In the browser, on NodeJS, on JVM, on .Net, on
Android and in iOS. Same language.
Piggybacks on other stuff. Acting like a symbiote,
with direct, toll-less access to the underlying
platform if need be.
Symbiote.
Beauty
Brains
Sample stack.
“Client”
“Server”
App
API
NodeJS
ClojureScript
Browser
ClojureScript
Clojure
JVM
Shared state
Server-side rendering
Crossref Walmart The Daily Mail Akamai
Circle CI Metabase Boeing Atlassian
Netflix CitiGroup LinkedInThoughtWorks
Cisco Nubank …
In production.
Apache Storm
Language.
Clojure, the language
String “Lol”
Character &
Number 267
Keyword :elephant
Var get-pizza
Data structures.
List (1 2 3 4 5)
Vector [1 2 3 4 5]
Map {:hello “world”}
Set #{1 2 3 4 5}
Data structures.
(explore-temple :machete :whip :gun)
Syntax.
That’s it.
Syntax.
Given a map of args,
construct a URL string.
Example.
“Simplicity does not precede
complexity, but follows it.”
Example.
Alan Perlis
Example.
{:tool “whip”
:garment “hat”
:nationality “american”
:location “jungle”}
?tool=whip&garment=hat&nationality=american&location=jungle
First attempt.
(def args {:tool "whip"
:garment "hat"
:nationality "american"
:location "jungle"})
(defn stringify [arg]
(update-in arg [0] name))
(defn splice-eqal [[key-part val-part]]
[key-part "=" val-part])
( ->> args
(vec)
(map stringify)
(map splice-equal)
(interpose "&")
(flatten)
(apply str))
Final result.
(defn format-arg
"Takes a vector of two items, where the first is
a keyword, which it turns into a string. It then
splices in an = between the two items, and fuses
them all together into a single string.”
[[key-part val-part]]
(str (name key-part) "=" val-part))
(defn make-string
"Takes a vector of args as strings, interposes ‘&’
between them and then mashes everything in it
together into a string."
[args]
( ->> args (interpose “&”) (apply str)))
(defn make-args
"Turns a map of args into a string."
[args]
(make-string (map format-arg args)))
What about frontend development?
Example.
Frontend development.
;; The state
(defonce app-state (atom 0))
;; Functions for modifying state
(defn increase-int []
(swap! app-state inc))
(defn decrease-int []
(swap! app-state dec))
;; The "template" for page content
(defn hello-world []
[:div
[:h1 (str "Current value in app-state: " @app-state)]
[:button {:on-click increase-int} "Inc"]
[:button {:on-click decrease-int} "Dec"]])
;; How we mount the "template"
(reagent/render-component [hello-world]
(. js/document (getElementById "app")))
The rendered result
Most work is done in libraries.
core.async decouples systems, adds both thread-
based and in-thread asynchrony.
core.spec regexes for data structures: validation
(syntactically and semantically),
generates automatic tests, generates
documentation, generates APIs, etc.
transducers higher order functions on steroids.
transit type-aware data structures on the wire.
How to learn how to think.
Use it.
How to learn how to think.
“The value of a language that strongly enforces a paradigm is
that it immerses you in that approach to solving problems.
“The more it enforces the paradigm, the more you are forced to
attempt solutions using that paradigm.
“The more functional your language, the more training you get
in approaching problems in a functional way.“
Can I do FP in my language?
Eric Normand
Incentives.
Things to have a look at.
Simple Made Easy. How complexity impacts business performance.
https://www.infoq.com/presentations/Simple-Made-Easy
Success stories. Some examples of Clojure in production.
https://clojure.org/community/success_stories
Clojure TV on Youtube. Tons of lectures and education.
https://www.youtube.com/user/ClojureTV
Clojure for the Brave and True. A gentle introduction to the language.
https://www.braveclojure.com/clojure-for-the-brave-and-true/

More Related Content

PDF
Codegeneration With Xtend
PDF
Extending the Xbase Typesystem
PDF
wtf is in Java/JDK/wtf7?
PDF
Deep dive into Xtext scoping local and global scopes explained
PPTX
Learning About JavaScript (…and its little buddy, JQuery!)
PDF
Object calisthenics (PHPCon Poland 2016)
PDF
Django Multi-DB in Anger
PPTX
Automation testing using Ruby with Cucumber in Docker
Codegeneration With Xtend
Extending the Xbase Typesystem
wtf is in Java/JDK/wtf7?
Deep dive into Xtext scoping local and global scopes explained
Learning About JavaScript (…and its little buddy, JQuery!)
Object calisthenics (PHPCon Poland 2016)
Django Multi-DB in Anger
Automation testing using Ruby with Cucumber in Docker

What's hot (20)

PDF
Polyglot Persistence
PPTX
Moose Best Practices
PDF
The art of readable code (ch1~ch4)
PDF
Using Xcore with Xtext
PDF
Ejb3 Struts Tutorial En
PDF
QA Fest 2015. Яков Крамаренко. Polyglot automation
PPT
A Short Introduction To jQuery
PDF
Serializing EMF models with Xtext
ODP
Drupal Best Practices
PDF
Introduction To Scala
PDF
Introduction to jOOQ
PDF
Xtext beyond the defaults - how to tackle performance problems
ODP
Multilingual drupal 7
PDF
Xtext's new Formatter API
ZIP
Object Oriented PHP5
ODP
Evolving Software with Moose
PDF
Utopia Kindgoms scaling case: From 4 to 50K users
PDF
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...
PDF
Puppet Camp DC 2015: Stop Writing Puppet Modules: A Guide to Best Practices i...
Polyglot Persistence
Moose Best Practices
The art of readable code (ch1~ch4)
Using Xcore with Xtext
Ejb3 Struts Tutorial En
QA Fest 2015. Яков Крамаренко. Polyglot automation
A Short Introduction To jQuery
Serializing EMF models with Xtext
Drupal Best Practices
Introduction To Scala
Introduction to jOOQ
Xtext beyond the defaults - how to tackle performance problems
Multilingual drupal 7
Xtext's new Formatter API
Object Oriented PHP5
Evolving Software with Moose
Utopia Kindgoms scaling case: From 4 to 50K users
Framework agnostic application Will it fit with Symfony? - Symfony live warsa...
Puppet Camp DC 2015: Stop Writing Puppet Modules: A Guide to Best Practices i...
Ad

Similar to Functional (web) development with Clojure (20)

ODP
Clojure
PDF
Introduction to clojure
PDF
Introduction to Apache Flink - Fast and reliable big data processing
PDF
Java for android developers
PDF
the productive programer: mechanics
PPTX
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...
PPT
Java Intro
PPTX
All of javascript
PDF
Fun with Functional Programming in Clojure
KEY
AMD - Why, What and How
PDF
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
PDF
Scala and jvm_languages_praveen_technologist
PDF
PuppetDB: Sneaking Clojure into Operations
PPTX
The Relevance of the Apache Solr Semantic Knowledge Graph
PPT
Oscon keynote: Working hard to keep it simple
PPTX
AestasIT - Internal DSLs in Scala
PPTX
All of Javascript
PDF
Session on Selenium Powertools by Unmesh Gundecha
PDF
Get into Functional Programming with Clojure
Clojure
Introduction to clojure
Introduction to Apache Flink - Fast and reliable big data processing
Java for android developers
the productive programer: mechanics
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...
Java Intro
All of javascript
Fun with Functional Programming in Clojure
AMD - Why, What and How
Fun with Functional Programming in Clojure - John Stevenson - Codemotion Amst...
Scala and jvm_languages_praveen_technologist
PuppetDB: Sneaking Clojure into Operations
The Relevance of the Apache Solr Semantic Knowledge Graph
Oscon keynote: Working hard to keep it simple
AestasIT - Internal DSLs in Scala
All of Javascript
Session on Selenium Powertools by Unmesh Gundecha
Get into Functional Programming with Clojure
Ad

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
AI in Product Development-omnex systems
PDF
medical staffing services at VALiNTRY
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
Mini project ppt template for panimalar Engineering college
DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
Digital Strategies for Manufacturing Companies
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
System and Network Administration Chapter 2
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
CRUISE TICKETING SYSTEM | CRUISE RESERVATION SOFTWARE
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPT
Introduction Database Management System for Course Database
PPTX
FLIGHT TICKET RESERVATION SYSTEM | FLIGHT BOOKING ENGINE API
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Essential Infomation Tech presentation.pptx
Understanding Forklifts - TECH EHS Solution
ManageIQ - Sprint 268 Review - Slide Deck
AI in Product Development-omnex systems
medical staffing services at VALiNTRY
Materi-Enum-and-Record-Data-Type (1).pptx
Mini project ppt template for panimalar Engineering college
The Five Best AI Cover Tools in 2025.docx
Digital Strategies for Manufacturing Companies
How to Migrate SBCGlobal Email to Yahoo Easily
System and Network Administration Chapter 2
How to Choose the Right IT Partner for Your Business in Malaysia
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
CRUISE TICKETING SYSTEM | CRUISE RESERVATION SOFTWARE
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Introduction Database Management System for Course Database
FLIGHT TICKET RESERVATION SYSTEM | FLIGHT BOOKING ENGINE API
A REACT POMODORO TIMER WEB APPLICATION.pdf
Online Work Permit System for Fast Permit Processing
Essential Infomation Tech presentation.pptx

Functional (web) development with Clojure

  • 3. Clojure is a strongly typed, dynamic, functional programming language that is defined in terms of its own persistent data structures. Introduction.
  • 5. Complexity Introduction. Ability to comprehend complexity Normal person Smartest person in the world
  • 6. Complexity Introduction. Have to bring the complex thing closer to us. The other way around doesn’t work.
  • 8. Functional programming is only interesting to the degree it helps us achieve this goal. Clojure provides tools for the mind rather than for the machine. Introduction.
  • 9. Persistent (immutable) data structures Object/stateless programming model Software Transactional Memory (STM) Powerful data processing and transformation tools Powerful data validation and testing tools Strongly and optionally typed Powerful (and easy) concurrency+parallelism Instant feedback-driven development Hosted on several platforms Features of the language.
  • 10. Variables complects* time and state. Objects complects time, state and identity. Methods complects function and state. Syntax complects order and meaning. … The real features of the language. *To complect: to create complexity, usually by intertwining two or more unrelated concepts Values Values Functions Data …
  • 11. In the browser, on NodeJS, on JVM, on .Net, on Android and in iOS. Same language. Piggybacks on other stuff. Acting like a symbiote, with direct, toll-less access to the underlying platform if need be. Symbiote.
  • 13. Crossref Walmart The Daily Mail Akamai Circle CI Metabase Boeing Atlassian Netflix CitiGroup LinkedInThoughtWorks Cisco Nubank … In production. Apache Storm
  • 15. String “Lol” Character & Number 267 Keyword :elephant Var get-pizza Data structures.
  • 16. List (1 2 3 4 5) Vector [1 2 3 4 5] Map {:hello “world”} Set #{1 2 3 4 5} Data structures.
  • 19. Given a map of args, construct a URL string. Example.
  • 20. “Simplicity does not precede complexity, but follows it.” Example. Alan Perlis
  • 21. Example. {:tool “whip” :garment “hat” :nationality “american” :location “jungle”} ?tool=whip&garment=hat&nationality=american&location=jungle
  • 22. First attempt. (def args {:tool "whip" :garment "hat" :nationality "american" :location "jungle"}) (defn stringify [arg] (update-in arg [0] name)) (defn splice-eqal [[key-part val-part]] [key-part "=" val-part]) ( ->> args (vec) (map stringify) (map splice-equal) (interpose "&") (flatten) (apply str))
  • 23. Final result. (defn format-arg "Takes a vector of two items, where the first is a keyword, which it turns into a string. It then splices in an = between the two items, and fuses them all together into a single string.” [[key-part val-part]] (str (name key-part) "=" val-part)) (defn make-string "Takes a vector of args as strings, interposes ‘&’ between them and then mashes everything in it together into a string." [args] ( ->> args (interpose “&”) (apply str))) (defn make-args "Turns a map of args into a string." [args] (make-string (map format-arg args)))
  • 24. What about frontend development? Example.
  • 25. Frontend development. ;; The state (defonce app-state (atom 0)) ;; Functions for modifying state (defn increase-int [] (swap! app-state inc)) (defn decrease-int [] (swap! app-state dec)) ;; The "template" for page content (defn hello-world [] [:div [:h1 (str "Current value in app-state: " @app-state)] [:button {:on-click increase-int} "Inc"] [:button {:on-click decrease-int} "Dec"]]) ;; How we mount the "template" (reagent/render-component [hello-world] (. js/document (getElementById "app"))) The rendered result
  • 26. Most work is done in libraries. core.async decouples systems, adds both thread- based and in-thread asynchrony. core.spec regexes for data structures: validation (syntactically and semantically), generates automatic tests, generates documentation, generates APIs, etc. transducers higher order functions on steroids. transit type-aware data structures on the wire.
  • 27. How to learn how to think. Use it.
  • 28. How to learn how to think. “The value of a language that strongly enforces a paradigm is that it immerses you in that approach to solving problems. “The more it enforces the paradigm, the more you are forced to attempt solutions using that paradigm. “The more functional your language, the more training you get in approaching problems in a functional way.“ Can I do FP in my language? Eric Normand
  • 30. Things to have a look at. Simple Made Easy. How complexity impacts business performance. https://www.infoq.com/presentations/Simple-Made-Easy Success stories. Some examples of Clojure in production. https://clojure.org/community/success_stories Clojure TV on Youtube. Tons of lectures and education. https://www.youtube.com/user/ClojureTV Clojure for the Brave and True. A gentle introduction to the language. https://www.braveclojure.com/clojure-for-the-brave-and-true/