SlideShare a Scribd company logo
Get into Functional
Programming with Clojure
by John Stevenson
@jr0cket
clojure.practical.li
Get into Functional Programming with Clojure
Why Functional Programming
it's not just because it's really fun...
OO
Software
in action
Josh Smith - Tweet
Original Gif
The Complexity Iceberg
- @krisajenkins
● complexity is very
dangerous when hidden
● You can't know what a
function does for certain if it
has side effects
Side Effects
Pure Functions
The results of the function are purely determined by its initial output and its own code
- no external influence, a function only uses local values
- referential transparency (the function can be replaced by its value)
Impure Functions - side causes
The results of the function are purely determined by its initial output and its own code
- behaviour externally influenced and non-deterministic
Eliminating Side Effects
Functional programming is about eliminating side effects where you can,
controlling them where you can't - @krisajenkins
The features in Functional Programming come from a
desire to reduce side effects
Clojure
General purpose language hosted on JVM, JavaScript & CLR
Clojure / ClojureScript
A hosted language with simple interoperability with the host language
- (java.Util.Date.)
- (js/alert “Client side apps are easier in Clojure”)
Clojure - basic syntax for this talk
( ) ;; an empty list. The first element of a list is evaluated as a function call
(function-name data) ;; call a function with the data as its argument
(def name “data-or-value”) ;; assign (bind) a name to a data or legal value
:keyword-name ;; a keyword is a name that points to itself
;; Thread-first macro - chain function calls, passing the result of each call as the first
argument to the next function. The ,,, indicates where the resulting argument goes.
(-> (function-a “data”)
(function-b ,,,) ;; In Clojure commas , are whitespace
(function-c ,,, “data”))
Persistent Data Structures
- List, Vector, Map & Set
Clojure’s built-in data structures are all immutable
- returning a new data structure when a function is applied
(list 1 2 3 4 5) ‘(“fish” “chips” 42)
(vec ‘(1 2 3 4)) [1 2 3 4]
{:key “value”} {:name “John” :skill “conferencing”}
(set ‘(1 2 3 4 4)) #{1 2 3 4}
Persistent Data Structures - shared memory
Each function creates a new vector
Memory space for values is shared
between each vector
Persistent Data Structures -
shared memory
By sharing memory you
can apply functions
over and over again
effectively
Values persist until
they are no longer
referenced
Higher Order Functions
Functions always return a value & can be used as an argument to another function
Composing functions together
Example: current value of the Clojure project from the configuration file
- `slurp` in the project file, convert into a string and return the value at index 2
Polymorphism
Functions evaluate different algorithms based on arity of arguments
Recursion & Polymorphism
Process a collection of values by feeding the remaining elements back to the function
- the sum function is polymorphic, it has different behaviours that could be
evaluated depending on if passed 1 or 2 arguments
Recursion - tail call optomisation
Protect the heap space from blowing by using the recur function
Using recur in the last line is the same as calling sum, however the memory required
from the previous sum function call is over-written in memory. So only 1 memory slot
is used instead of 10 billion
Lazy Evaluation
Only return a value when necessary
● maintain precision
● optomise evaluation
Sequence / List Comprehension
Iterate over collections
Sequence / List Comprehension
Iterating through a range of generated values to create a list of 2 value vectors
Immutability - local binding
Assignments made locally are immutable
- words is a local binding to the result of running the function upper-case on “Hello
World”
- letter->clack is a function that converts a character to a code
Concurrency is Easier
Concurrency is much easier to write and reason about because of
- Immutability by default
- Persistent Data Structures
- values are immutable
- functional isolation & pure functions
- state changes managed atomically (software transactional memory)
- core.async library allows you to write asynchronous code as easily as sequential
code
Safe State changes
Changing state safely by not changing it
● Persistent data structures
● Local bindings
Changing state safely by changing it atomically
● Software Transactional Memory (STM)
○ Gives an mechanism like an in-memory atomic database that manages mutable state changes
under the covers
● Atoms
● core.async
Concurrency syntax - atoms
An online card game has players that can join and have their winnings tracked
Concurrency syntax - atoms
The join-game function adds players to the atom by their name, but only up to 2
players
Concurrency syntax - refs for sync updates
The join-game-safely adds players to the ref and alters their account & game account
Putting it all together
Let's find all the most common words used in a popular Science Fiction novel
Tools to learn Clojure
inspire them & build up their motivation
Clojure support in many different tools
Leiningen - Clojure powered
build automation
Get into Functional Programming with Clojure
LightTable - Instarepl
Emacs & Spacemacs
Figwheel (flappy birds example)
Get into Functional Programming with Clojure
Examples, examples, examples
we learn by example...
Over 20 Books on Clojure...
Where to start with Clojure will be different...
Example:
I typically suggested BraveClojure.com as a starting
point, however many people prefer LivingClojure or
ClojureScript Unraveled...
Help people understand the relevance of a book and if
it's the right thing for them at that time.
Clojure.org & ClojureDocs.org
Get into Functional Programming with Clojure
Github
Clojure-through-code Git repository
http://practical.li/clojure-webapps
Get into Functional Programming with Clojure
Testing your Clojure skills...
Get into Functional Programming with Clojure
Clojurian Community in Person
Probably the most active language-specific
developer communities in London
Learning by teaching others
I really started thinking in Clojure when I started talking to & teaching others
- Coding dojos
- talks on Clojure (starting with the basics, showing the art of the possible)
- moving on to running conferences
- workshops at hack days
Overtone live performance - MetaX
Overtone live performance - MetaX
Take your own journey into Clojure
Thank you
@jr0cket
jr0cket.co.uk
@jr0cket
@Heroku
@SalesforceDevs
#Trailhead
In a galaxy far, far away… London, UK

More Related Content

What's hot (20)

CoffeeScript By Example
CoffeeScript By ExampleCoffeeScript By Example
CoffeeScript By Example
Christopher Bartling
 
Java fork join
Java fork joinJava fork join
Java fork join
Masud Hasan
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger
 
Test Driven Development and JUnit
Test Driven Development and JUnitTest Driven Development and JUnit
Test Driven Development and JUnit
Somenath Mukhopadhyay
 
Building Fast, Modern Web Applications with Node.js and CoffeeScript
Building Fast, Modern Web Applications with Node.js and CoffeeScriptBuilding Fast, Modern Web Applications with Node.js and CoffeeScript
Building Fast, Modern Web Applications with Node.js and CoffeeScript
royaldark
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartFunctional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smart
Chen Fisher
 
Java 7
Java 7Java 7
Java 7
Tomasz Wrobel
 
Fork and join framework
Fork and join frameworkFork and join framework
Fork and join framework
Minh Tran
 
Mule esb object_to_jackson_json
Mule esb object_to_jackson_jsonMule esb object_to_jackson_json
Mule esb object_to_jackson_json
Davide Rapacciuolo
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Dive
davanum
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015
Ben Lesh
 
Design patterns with kotlin
Design patterns with kotlinDesign patterns with kotlin
Design patterns with kotlin
Alexey Soshin
 
Design patterns with kotlin
Design patterns with kotlinDesign patterns with kotlin
Design patterns with kotlin
Alexey Soshin
 
Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design Patterns
Robert Brown
 
Declarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetationDeclarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetation
Om Shankar
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
nklmish
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
Matteo Battaglio
 
Sane Sharding with Akka Cluster
Sane Sharding with Akka ClusterSane Sharding with Akka Cluster
Sane Sharding with Akka Cluster
miciek
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
Mario Fusco
 
ORMs in Golang
ORMs in GolangORMs in Golang
ORMs in Golang
Ikenna Okpala
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger
 
Building Fast, Modern Web Applications with Node.js and CoffeeScript
Building Fast, Modern Web Applications with Node.js and CoffeeScriptBuilding Fast, Modern Web Applications with Node.js and CoffeeScript
Building Fast, Modern Web Applications with Node.js and CoffeeScript
royaldark
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smartFunctional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smart
Chen Fisher
 
Fork and join framework
Fork and join frameworkFork and join framework
Fork and join framework
Minh Tran
 
Mule esb object_to_jackson_json
Mule esb object_to_jackson_jsonMule esb object_to_jackson_json
Mule esb object_to_jackson_json
Davide Rapacciuolo
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Dive
davanum
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015
Ben Lesh
 
Design patterns with kotlin
Design patterns with kotlinDesign patterns with kotlin
Design patterns with kotlin
Alexey Soshin
 
Design patterns with kotlin
Design patterns with kotlinDesign patterns with kotlin
Design patterns with kotlin
Alexey Soshin
 
Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design Patterns
Robert Brown
 
Declarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetationDeclarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetation
Om Shankar
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
nklmish
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
Matteo Battaglio
 
Sane Sharding with Akka Cluster
Sane Sharding with Akka ClusterSane Sharding with Akka Cluster
Sane Sharding with Akka Cluster
miciek
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
Mario Fusco
 

Viewers also liked (18)

Spring MVC - QConSP
Spring MVC - QConSPSpring MVC - QConSP
Spring MVC - QConSP
Eduardo Bregaida
 
Cultura da empresa - um problema na adoção ágil
Cultura da empresa - um problema na adoção ágilCultura da empresa - um problema na adoção ágil
Cultura da empresa - um problema na adoção ágil
Eduardo Bregaida
 
Java Generics - Quiz Questions
Java Generics - Quiz QuestionsJava Generics - Quiz Questions
Java Generics - Quiz Questions
Ganesh Samarthyam
 
Software Architecture - Quiz Questions
Software Architecture - Quiz QuestionsSoftware Architecture - Quiz Questions
Software Architecture - Quiz Questions
Ganesh Samarthyam
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in Clojure
Troy Miles
 
DDD + BDD + TDD + Scrum
DDD + BDD + TDD + ScrumDDD + BDD + TDD + Scrum
DDD + BDD + TDD + Scrum
Eduardo Bregaida
 
DDD - Linguagem Ubíqua
DDD - Linguagem UbíquaDDD - Linguagem Ubíqua
DDD - Linguagem Ubíqua
Eduardo Bregaida
 
Introdução aos computadores e à World Wide Web
Introdução aos computadores e à World Wide WebIntrodução aos computadores e à World Wide Web
Introdução aos computadores e à World Wide Web
Cícero Quarto
 
DDD + BDD + TDD - RF 2015
DDD + BDD + TDD - RF 2015 DDD + BDD + TDD - RF 2015
DDD + BDD + TDD - RF 2015
Eduardo Bregaida
 
Rethink programming: a functional approach
Rethink programming: a functional approachRethink programming: a functional approach
Rethink programming: a functional approach
Francesco Bruni
 
Scrum - IMES 2013 (Remodelada)
Scrum - IMES 2013 (Remodelada)Scrum - IMES 2013 (Remodelada)
Scrum - IMES 2013 (Remodelada)
Eduardo Bregaida
 
Fuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional ProgrammingFuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional Programming
Shine Xavier
 
Sailing with Java 8 Streams
Sailing with Java 8 StreamsSailing with Java 8 Streams
Sailing with Java 8 Streams
Ganesh Samarthyam
 
Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for Maintainability
Marcin Stepien
 
The Ideas of Clojure - Things I learn from Clojure
The Ideas of Clojure - Things I learn from ClojureThe Ideas of Clojure - Things I learn from Clojure
The Ideas of Clojure - Things I learn from Clojure
Hsuan Fu Lien
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
Damian Jureczko
 
Java 8 Date and Time API
Java 8 Date and Time APIJava 8 Date and Time API
Java 8 Date and Time API
Sualeh Fatehi
 
Deep Learning through Examples
Deep Learning through ExamplesDeep Learning through Examples
Deep Learning through Examples
Sri Ambati
 
Cultura da empresa - um problema na adoção ágil
Cultura da empresa - um problema na adoção ágilCultura da empresa - um problema na adoção ágil
Cultura da empresa - um problema na adoção ágil
Eduardo Bregaida
 
Java Generics - Quiz Questions
Java Generics - Quiz QuestionsJava Generics - Quiz Questions
Java Generics - Quiz Questions
Ganesh Samarthyam
 
Software Architecture - Quiz Questions
Software Architecture - Quiz QuestionsSoftware Architecture - Quiz Questions
Software Architecture - Quiz Questions
Ganesh Samarthyam
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in Clojure
Troy Miles
 
Introdução aos computadores e à World Wide Web
Introdução aos computadores e à World Wide WebIntrodução aos computadores e à World Wide Web
Introdução aos computadores e à World Wide Web
Cícero Quarto
 
DDD + BDD + TDD - RF 2015
DDD + BDD + TDD - RF 2015 DDD + BDD + TDD - RF 2015
DDD + BDD + TDD - RF 2015
Eduardo Bregaida
 
Rethink programming: a functional approach
Rethink programming: a functional approachRethink programming: a functional approach
Rethink programming: a functional approach
Francesco Bruni
 
Scrum - IMES 2013 (Remodelada)
Scrum - IMES 2013 (Remodelada)Scrum - IMES 2013 (Remodelada)
Scrum - IMES 2013 (Remodelada)
Eduardo Bregaida
 
Fuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional ProgrammingFuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional Programming
Shine Xavier
 
Functional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for MaintainabilityFunctional Programming in Java - Code for Maintainability
Functional Programming in Java - Code for Maintainability
Marcin Stepien
 
The Ideas of Clojure - Things I learn from Clojure
The Ideas of Clojure - Things I learn from ClojureThe Ideas of Clojure - Things I learn from Clojure
The Ideas of Clojure - Things I learn from Clojure
Hsuan Fu Lien
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
Damian Jureczko
 
Java 8 Date and Time API
Java 8 Date and Time APIJava 8 Date and Time API
Java 8 Date and Time API
Sualeh Fatehi
 
Deep Learning through Examples
Deep Learning through ExamplesDeep Learning through Examples
Deep Learning through Examples
Sri Ambati
 
Ad

Similar to Get into Functional Programming with Clojure (20)

Fun with Functional Programming in Clojure
Fun with Functional Programming in ClojureFun with Functional Programming in Clojure
Fun with Functional Programming in Clojure
Codemotion
 
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Codemotion
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
John Stevenson
 
A Taste of Clojure
A Taste of ClojureA Taste of Clojure
A Taste of Clojure
David Leung
 
Clojure concurrency
Clojure concurrencyClojure concurrency
Clojure concurrency
Alex Navis
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
John Stevenson
 
Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners
Paddy Lock
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are Wrong
Mario Fusco
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
Ted Leung
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
JAX London
 
React native
React nativeReact native
React native
Mohammed El Rafie Tarabay
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
lavparmar007
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
Jagan Mohan Bishoyi
 
Functional (web) development with Clojure
Functional (web) development with ClojureFunctional (web) development with Clojure
Functional (web) development with Clojure
Henrik Eneroth
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
anshunjain
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
Renzo Borgatti
 
All of javascript
All of javascriptAll of javascript
All of javascript
Togakangaroo
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
Abbas Raza
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overview
stasimus
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
Fun with Functional Programming in Clojure
Fun with Functional Programming in ClojureFun with Functional Programming in Clojure
Fun with Functional Programming in Clojure
Codemotion
 
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Codemotion
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
John Stevenson
 
A Taste of Clojure
A Taste of ClojureA Taste of Clojure
A Taste of Clojure
David Leung
 
Clojure concurrency
Clojure concurrencyClojure concurrency
Clojure concurrency
Alex Navis
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
John Stevenson
 
Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners Clojure Fundamentals Course For Beginners
Clojure Fundamentals Course For Beginners
Paddy Lock
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are Wrong
Mario Fusco
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
Ted Leung
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
JAX London
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
lavparmar007
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
Jagan Mohan Bishoyi
 
Functional (web) development with Clojure
Functional (web) development with ClojureFunctional (web) development with Clojure
Functional (web) development with Clojure
Henrik Eneroth
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
anshunjain
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
Renzo Borgatti
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
Abbas Raza
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overview
stasimus
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
Ad

More from John Stevenson (20)

ClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of ClojureClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of Clojure
John Stevenson
 
Confessions of a developer community builder
Confessions of a developer community builderConfessions of a developer community builder
Confessions of a developer community builder
John Stevenson
 
Introduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with ClojurescriptIntroduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with Clojurescript
John Stevenson
 
Communication improbable
Communication improbableCommunication improbable
Communication improbable
John Stevenson
 
Getting into public speaking at conferences
Getting into public speaking at conferencesGetting into public speaking at conferences
Getting into public speaking at conferences
John Stevenson
 
Guiding people into Clojure
Guiding people into ClojureGuiding people into Clojure
Guiding people into Clojure
John Stevenson
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
John Stevenson
 
So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?
John Stevenson
 
Trailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App CloudTrailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App Cloud
John Stevenson
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
John Stevenson
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
John Stevenson
 
Dreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version ControlDreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version Control
John Stevenson
 
Salesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - IntroductionSalesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - Introduction
John Stevenson
 
Heroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & servicesHeroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & services
John Stevenson
 
Developers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformDevelopers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 Platform
John Stevenson
 
Developer week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overviewDeveloper week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overview
John Stevenson
 
Dreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developersDreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developers
John Stevenson
 
Dreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to HerokuDreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to Heroku
John Stevenson
 
Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...
Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...
Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...
John Stevenson
 
Building a great mobile experience on the force.com platforms
Building a great mobile experience on the force.com platformsBuilding a great mobile experience on the force.com platforms
Building a great mobile experience on the force.com platforms
John Stevenson
 
ClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of ClojureClojureX Conference 2017 - 10 amazing years of Clojure
ClojureX Conference 2017 - 10 amazing years of Clojure
John Stevenson
 
Confessions of a developer community builder
Confessions of a developer community builderConfessions of a developer community builder
Confessions of a developer community builder
John Stevenson
 
Introduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with ClojurescriptIntroduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with Clojurescript
John Stevenson
 
Communication improbable
Communication improbableCommunication improbable
Communication improbable
John Stevenson
 
Getting into public speaking at conferences
Getting into public speaking at conferencesGetting into public speaking at conferences
Getting into public speaking at conferences
John Stevenson
 
Guiding people into Clojure
Guiding people into ClojureGuiding people into Clojure
Guiding people into Clojure
John Stevenson
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
John Stevenson
 
So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?So you want to run a developer event, are you crazy?
So you want to run a developer event, are you crazy?
John Stevenson
 
Trailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App CloudTrailhead live - Overview of Salesforce App Cloud
Trailhead live - Overview of Salesforce App Cloud
John Stevenson
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
John Stevenson
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
John Stevenson
 
Dreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version ControlDreamforce14 Metadata Management with Git Version Control
Dreamforce14 Metadata Management with Git Version Control
John Stevenson
 
Salesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - IntroductionSalesforce Summer of Hacks London - Introduction
Salesforce Summer of Hacks London - Introduction
John Stevenson
 
Heroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & servicesHeroku Introduction: Scaling customer facing apps & services
Heroku Introduction: Scaling customer facing apps & services
John Stevenson
 
Developers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 PlatformDevelopers guide to the Salesforce1 Platform
Developers guide to the Salesforce1 Platform
John Stevenson
 
Developer week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overviewDeveloper week EMEA - Salesforce1 Mobile App overview
Developer week EMEA - Salesforce1 Mobile App overview
John Stevenson
 
Dreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developersDreamforce 13 developer session: Git for Force.com developers
Dreamforce 13 developer session: Git for Force.com developers
John Stevenson
 
Dreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to HerokuDreamforce 13 developer session: Introduction to Heroku
Dreamforce 13 developer session: Introduction to Heroku
John Stevenson
 
Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...
Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...
Salesforce CCT Munich 2013 Introducing heroku - elastic, polyglot platform as...
John Stevenson
 
Building a great mobile experience on the force.com platforms
Building a great mobile experience on the force.com platformsBuilding a great mobile experience on the force.com platforms
Building a great mobile experience on the force.com platforms
John Stevenson
 

Recently uploaded (20)

From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Agile Software Engineering Methodologies
Agile Software Engineering MethodologiesAgile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Safe Software
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Agile Software Engineering Methodologies
Agile Software Engineering MethodologiesAgile Software Engineering Methodologies
Agile Software Engineering Methodologies
Gaurav Sharma
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Safe Software
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 

Get into Functional Programming with Clojure

  • 1. Get into Functional Programming with Clojure by John Stevenson @jr0cket clojure.practical.li
  • 3. Why Functional Programming it's not just because it's really fun...
  • 4. OO Software in action Josh Smith - Tweet Original Gif
  • 5. The Complexity Iceberg - @krisajenkins ● complexity is very dangerous when hidden ● You can't know what a function does for certain if it has side effects
  • 7. Pure Functions The results of the function are purely determined by its initial output and its own code - no external influence, a function only uses local values - referential transparency (the function can be replaced by its value)
  • 8. Impure Functions - side causes The results of the function are purely determined by its initial output and its own code - behaviour externally influenced and non-deterministic
  • 9. Eliminating Side Effects Functional programming is about eliminating side effects where you can, controlling them where you can't - @krisajenkins The features in Functional Programming come from a desire to reduce side effects
  • 10. Clojure General purpose language hosted on JVM, JavaScript & CLR
  • 11. Clojure / ClojureScript A hosted language with simple interoperability with the host language - (java.Util.Date.) - (js/alert “Client side apps are easier in Clojure”)
  • 12. Clojure - basic syntax for this talk ( ) ;; an empty list. The first element of a list is evaluated as a function call (function-name data) ;; call a function with the data as its argument (def name “data-or-value”) ;; assign (bind) a name to a data or legal value :keyword-name ;; a keyword is a name that points to itself ;; Thread-first macro - chain function calls, passing the result of each call as the first argument to the next function. The ,,, indicates where the resulting argument goes. (-> (function-a “data”) (function-b ,,,) ;; In Clojure commas , are whitespace (function-c ,,, “data”))
  • 13. Persistent Data Structures - List, Vector, Map & Set Clojure’s built-in data structures are all immutable - returning a new data structure when a function is applied (list 1 2 3 4 5) ‘(“fish” “chips” 42) (vec ‘(1 2 3 4)) [1 2 3 4] {:key “value”} {:name “John” :skill “conferencing”} (set ‘(1 2 3 4 4)) #{1 2 3 4}
  • 14. Persistent Data Structures - shared memory Each function creates a new vector Memory space for values is shared between each vector
  • 15. Persistent Data Structures - shared memory By sharing memory you can apply functions over and over again effectively Values persist until they are no longer referenced
  • 16. Higher Order Functions Functions always return a value & can be used as an argument to another function
  • 17. Composing functions together Example: current value of the Clojure project from the configuration file - `slurp` in the project file, convert into a string and return the value at index 2
  • 18. Polymorphism Functions evaluate different algorithms based on arity of arguments
  • 19. Recursion & Polymorphism Process a collection of values by feeding the remaining elements back to the function - the sum function is polymorphic, it has different behaviours that could be evaluated depending on if passed 1 or 2 arguments
  • 20. Recursion - tail call optomisation Protect the heap space from blowing by using the recur function Using recur in the last line is the same as calling sum, however the memory required from the previous sum function call is over-written in memory. So only 1 memory slot is used instead of 10 billion
  • 21. Lazy Evaluation Only return a value when necessary ● maintain precision ● optomise evaluation
  • 22. Sequence / List Comprehension Iterate over collections
  • 23. Sequence / List Comprehension Iterating through a range of generated values to create a list of 2 value vectors
  • 24. Immutability - local binding Assignments made locally are immutable - words is a local binding to the result of running the function upper-case on “Hello World” - letter->clack is a function that converts a character to a code
  • 25. Concurrency is Easier Concurrency is much easier to write and reason about because of - Immutability by default - Persistent Data Structures - values are immutable - functional isolation & pure functions - state changes managed atomically (software transactional memory) - core.async library allows you to write asynchronous code as easily as sequential code
  • 26. Safe State changes Changing state safely by not changing it ● Persistent data structures ● Local bindings Changing state safely by changing it atomically ● Software Transactional Memory (STM) ○ Gives an mechanism like an in-memory atomic database that manages mutable state changes under the covers ● Atoms ● core.async
  • 27. Concurrency syntax - atoms An online card game has players that can join and have their winnings tracked
  • 28. Concurrency syntax - atoms The join-game function adds players to the atom by their name, but only up to 2 players
  • 29. Concurrency syntax - refs for sync updates The join-game-safely adds players to the ref and alters their account & game account
  • 30. Putting it all together Let's find all the most common words used in a popular Science Fiction novel
  • 31. Tools to learn Clojure inspire them & build up their motivation
  • 32. Clojure support in many different tools
  • 33. Leiningen - Clojure powered build automation
  • 39. Examples, examples, examples we learn by example...
  • 40. Over 20 Books on Clojure... Where to start with Clojure will be different... Example: I typically suggested BraveClojure.com as a starting point, however many people prefer LivingClojure or ClojureScript Unraveled... Help people understand the relevance of a book and if it's the right thing for them at that time.
  • 47. Testing your Clojure skills...
  • 49. Clojurian Community in Person Probably the most active language-specific developer communities in London
  • 50. Learning by teaching others I really started thinking in Clojure when I started talking to & teaching others - Coding dojos - talks on Clojure (starting with the basics, showing the art of the possible) - moving on to running conferences - workshops at hack days
  • 53. Take your own journey into Clojure