SlideShare a Scribd company logo
Clojure ))))
How not to be afraid of parentheses
Dmytro Bignyak
Me
Dmytro Bignyak
GitHub: deril
Twitter: @derilok
It is not about
• in Ruby it takes 5 lines of code but in Clojure only 4
• I show you much code, how cool Clojure is
Clojure ≠ Closure
I ♥ Clojure
Is that easy?
(defn select
"Returns a set of the elements for which pred is true"
{:added "1.0"}
[pred xset]
(reduce (fn [s k] (if (pred k) s (disj s k)))
xset xset))
Clojure is very
powerful
• It is a functional language
• It has functional advantages
• Clojure can used as functional style
(map (partial * 10) [1 2 3]) ; => [10 20 30]
• It also can be used for structures
(defrecord Color [red green blue])
(def b (assoc a :alpha 0.1))
; b => {:alpha 0.1, :red 0.5 :green 0.6, :blue 0.7}
Clojure is very useful
when you want some
ASYNC
Clojure has 4 types of links
1. var (thread local)
2. atom (can be synchronically changed, but not
coordinately)
3. agent (async state; analogue actor)
4. ref (can be synchronically and coordinately
changed)
var
(def a 123)
(println a) ; => 123
atom
(let [x (atom 0)]
(println @x) ; => 0
(swap! x inc)
(println @x)) ; => 1
agent
(def a (agent 0)) ; initial state
(send a inc)
(println @a) ; => 1
(send a (fn [x] (Thread/sleep 100) (inc x)))
(println @a) ; => 1
; in 100ms
(println @a) ; => 2
• Agents change their state asynchronically
• In any time you can call deref and get the state of
agent
Clojure can be used for MVCC
(Multiversion Concurrency Control)
(def account1 (ref 100)
(def account2 (ref 0))
(dosync
(alter account1 - 30)
(alter account2 + 30))
(println @account1) ; => 70
(println @account2) ; => 30
(dosync
(alter account1 * 0)
(alter account2 / 0)) ; => ArithmeticException
; values weren’t changed
(println @account1) ; => 70
(println @account2) ; => 30
I prefer core.async
Example core.async
(defonce log-chan (chan))
(defn loop-worker [msg]
(println msg))
(go-loop []
(let [msg (<! log-chan)]
(loop-worker msg)
(recur)))
Clojure (as all Lisps) is very
powerful in metaprogramming
(defmacro unless [pred a b]
`(if (not ~pred)
~a
~b))
(unless (> 1 10)
(println "1 > 10. ok")
(println "1 < 10. wat"))
Language is nothing
without infrastructure
• Clojure uses JVM
• Eclipse, IDEA plugins
• Leiningen building tool
• Web frameworks (LuminusWeb, Noir)
• Async servers (https://github.com/ztellman/aleph)
ClojureScript
(silver bullet for
JavaScript)
What’s next?
(println "Thank you!")

More Related Content

What's hot (20)

PPTX
Linked list without animation
Lovelyn Rose
 
PDF
Леонид Шевцов «Clojure в деле»
DataArt
 
PDF
The Ring programming language version 1.7 book - Part 85 of 196
Mahmoud Samir Fayed
 
PPTX
JVM Architecture - Java
Ganesh kumar reddy
 
PDF
Activity Recognition Through Complex Event Processing: First Findings
Sylvain Hallé
 
PDF
Swift - Krzysztof Skarupa
Sunscrapers
 
PPTX
Welcome vibrant-technology-navimumbai
Vibrant Technologies & Computers
 
PDF
Welcome vibrant-technology-navimumbai
Vibrant Technologies & Computers
 
PDF
The Ring programming language version 1.9 book - Part 27 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 25 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 12 of 88
Mahmoud Samir Fayed
 
PDF
Rcpp11 genentech
Romain Francois
 
PDF
ClojureScript for the web
Michiel Borkent
 
PDF
Clojure functions examples
Jackson dos Santos Olveira
 
TXT
Snake.c
Vijay Singh
 
PDF
Introduction to Go for Java Programmers
Kalpa Pathum Welivitigoda
 
DOC
Ds 2 cycle
Chaitanya Kn
 
PDF
ClojureScript loves React, DomCode May 26 2015
Michiel Borkent
 
PDF
Understanding the nodejs event loop
Saurabh Kumar
 
DOCX
Program membalik kata
haqiemisme
 
Linked list without animation
Lovelyn Rose
 
Леонид Шевцов «Clojure в деле»
DataArt
 
The Ring programming language version 1.7 book - Part 85 of 196
Mahmoud Samir Fayed
 
JVM Architecture - Java
Ganesh kumar reddy
 
Activity Recognition Through Complex Event Processing: First Findings
Sylvain Hallé
 
Swift - Krzysztof Skarupa
Sunscrapers
 
Welcome vibrant-technology-navimumbai
Vibrant Technologies & Computers
 
Welcome vibrant-technology-navimumbai
Vibrant Technologies & Computers
 
The Ring programming language version 1.9 book - Part 27 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 25 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 12 of 88
Mahmoud Samir Fayed
 
Rcpp11 genentech
Romain Francois
 
ClojureScript for the web
Michiel Borkent
 
Clojure functions examples
Jackson dos Santos Olveira
 
Snake.c
Vijay Singh
 
Introduction to Go for Java Programmers
Kalpa Pathum Welivitigoda
 
Ds 2 cycle
Chaitanya Kn
 
ClojureScript loves React, DomCode May 26 2015
Michiel Borkent
 
Understanding the nodejs event loop
Saurabh Kumar
 
Program membalik kata
haqiemisme
 

Viewers also liked (20)

PPTX
Building component based rails applications. part 1.
Pivorak MeetUp
 
PDF
The Silver Bullet Syndrome by Alexey Vasiliev
Pivorak MeetUp
 
PDF
GIS on Rails
Pivorak MeetUp
 
PDF
Overcommit for #pivorak
Pivorak MeetUp
 
PDF
Lightweight APIs in mRuby
Pivorak MeetUp
 
PDF
Functional Immutable CSS
Pivorak MeetUp
 
PPTX
Права інтелектуальної власності в IT сфері.
Pivorak MeetUp
 
PDF
"5 skills to master" by Alexander Skakunov
Pivorak MeetUp
 
PDF
Espec |> Elixir BDD
Pivorak MeetUp
 
PDF
"Ruby meets Event Sourcing" by Anton Paisov
Pivorak MeetUp
 
PDF
UDD: building polyglot anti-framework by Marek Piasecki
Pivorak MeetUp
 
PPT
Digital Nomading on Rails
Pivorak MeetUp
 
PDF
Trailblazer Introduction by Nick Sutterer
Pivorak MeetUp
 
PPTX
Building Component Based Rails Applications. Part 2.
Pivorak MeetUp
 
PDF
Andriy Vandakurov about "Frontend. Global domination"
Pivorak MeetUp
 
PDF
“Object Oriented Ruby” by Michał Papis.
Pivorak MeetUp
 
PDF
Building Web-API without Rails, Registration or SMS
Pivorak MeetUp
 
PDF
"Meet rom_rb & dry_rb" by Piotr Solnica
Pivorak MeetUp
 
PDF
From Rails legacy to DDD - Pivorak, Lviv
Andrzej Krzywda
 
PDF
Pivorak How to write better sentences in English
Pivorak MeetUp
 
Building component based rails applications. part 1.
Pivorak MeetUp
 
The Silver Bullet Syndrome by Alexey Vasiliev
Pivorak MeetUp
 
GIS on Rails
Pivorak MeetUp
 
Overcommit for #pivorak
Pivorak MeetUp
 
Lightweight APIs in mRuby
Pivorak MeetUp
 
Functional Immutable CSS
Pivorak MeetUp
 
Права інтелектуальної власності в IT сфері.
Pivorak MeetUp
 
"5 skills to master" by Alexander Skakunov
Pivorak MeetUp
 
Espec |> Elixir BDD
Pivorak MeetUp
 
"Ruby meets Event Sourcing" by Anton Paisov
Pivorak MeetUp
 
UDD: building polyglot anti-framework by Marek Piasecki
Pivorak MeetUp
 
Digital Nomading on Rails
Pivorak MeetUp
 
Trailblazer Introduction by Nick Sutterer
Pivorak MeetUp
 
Building Component Based Rails Applications. Part 2.
Pivorak MeetUp
 
Andriy Vandakurov about "Frontend. Global domination"
Pivorak MeetUp
 
“Object Oriented Ruby” by Michał Papis.
Pivorak MeetUp
 
Building Web-API without Rails, Registration or SMS
Pivorak MeetUp
 
"Meet rom_rb & dry_rb" by Piotr Solnica
Pivorak MeetUp
 
From Rails legacy to DDD - Pivorak, Lviv
Andrzej Krzywda
 
Pivorak How to write better sentences in English
Pivorak MeetUp
 
Ad

Similar to Pivorak Clojure by Dmytro Bignyak (20)

PDF
Clojure 1.1 And Beyond
Mike Fogus
 
ODP
Getting started with Clojure
John Stevenson
 
PDF
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
tdc-globalcode
 
PPTX
Clojure 7-Languages
Pierre de Lacaze
 
PDF
'Getting' Clojure - '(parentheses are just hugs for your code)
Gary Trakhman
 
PDF
Clojure class
Aysylu Greenberg
 
PDF
A Taste of Clojure
David Leung
 
PPTX
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Pramati Technologies
 
PDF
Introduction to Clojure
Renzo Borgatti
 
PDF
Exploring Clojurescript
Luke Donnet
 
ODP
Clojure basics
Knoldus Inc.
 
PDF
HelsinkiJS - Clojurescript for Javascript Developers
Juho Teperi
 
PDF
From Java to Parellel Clojure - Clojure South 2019
Leonardo Borges
 
ODP
Clojure presentation
Tikal Knowledge
 
PDF
Clojure - LISP on the JVM
Tikal Knowledge
 
PDF
Clojure made-simple - John Stevenson
JAX London
 
PDF
Introduction to Clojure
Baishampayan Ghose
 
PDF
Functional web with clojure
John Stevenson
 
PDF
Clojure and The Robot Apocalypse
elliando dias
 
PPTX
Why clojure(script) matters
Claudiu Apetrei
 
Clojure 1.1 And Beyond
Mike Fogus
 
Getting started with Clojure
John Stevenson
 
TDC2016POA | Trilha Programacao Funcional - Considere usar Clojure/ClojureScr...
tdc-globalcode
 
Clojure 7-Languages
Pierre de Lacaze
 
'Getting' Clojure - '(parentheses are just hugs for your code)
Gary Trakhman
 
Clojure class
Aysylu Greenberg
 
A Taste of Clojure
David Leung
 
Clojure through the eyes of a Java Nut | [Mixed Nuts] at Pramati Technologies
Pramati Technologies
 
Introduction to Clojure
Renzo Borgatti
 
Exploring Clojurescript
Luke Donnet
 
Clojure basics
Knoldus Inc.
 
HelsinkiJS - Clojurescript for Javascript Developers
Juho Teperi
 
From Java to Parellel Clojure - Clojure South 2019
Leonardo Borges
 
Clojure presentation
Tikal Knowledge
 
Clojure - LISP on the JVM
Tikal Knowledge
 
Clojure made-simple - John Stevenson
JAX London
 
Introduction to Clojure
Baishampayan Ghose
 
Functional web with clojure
John Stevenson
 
Clojure and The Robot Apocalypse
elliando dias
 
Why clojure(script) matters
Claudiu Apetrei
 
Ad

More from Pivorak MeetUp (20)

PDF
Lisp(Lots of Irritating Superfluous Parentheses)
Pivorak MeetUp
 
PDF
Some strange stories about mocks.
Pivorak MeetUp
 
PDF
Business-friendly library for inter-service communication
Pivorak MeetUp
 
PDF
How i was a team leader once
Pivorak MeetUp
 
PDF
Rails MVC by Sergiy Koshovyi
Pivorak MeetUp
 
PDF
Introduction to Rails by Evgeniy Hinyuk
Pivorak MeetUp
 
PPTX
Ruby OOP (in Ukrainian)
Pivorak MeetUp
 
PDF
Testing in Ruby
Pivorak MeetUp
 
PDF
Ruby Summer Course by #pivorak & OnApp - OOP Basics in Ruby
Pivorak MeetUp
 
PDF
The Saga Pattern: 2 years later by Robert Pankowecki
Pivorak MeetUp
 
PDF
Data and Bounded Contexts by Volodymyr Byno
Pivorak MeetUp
 
PDF
Successful Remote Development by Alex Rozumii
Pivorak MeetUp
 
PDF
Origins of Elixir programming language
Pivorak MeetUp
 
PDF
Multi language FBP with Flowex by Anton Mishchuk
Pivorak MeetUp
 
PDF
Detective story of one clever user - Lightning Talk By Sergiy Kukunin
Pivorak MeetUp
 
PDF
CryptoParty: Introduction by Olexii Markovets
Pivorak MeetUp
 
PDF
How to make first million by 30 (or not, but tryin') - by Marek Piasecki
Pivorak MeetUp
 
PDF
GIS on Rails by Oleksandr Kychun
Pivorak MeetUp
 
PDF
Unikernels - Keep It Simple to the Bare Metal
Pivorak MeetUp
 
PDF
HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
Pivorak MeetUp
 
Lisp(Lots of Irritating Superfluous Parentheses)
Pivorak MeetUp
 
Some strange stories about mocks.
Pivorak MeetUp
 
Business-friendly library for inter-service communication
Pivorak MeetUp
 
How i was a team leader once
Pivorak MeetUp
 
Rails MVC by Sergiy Koshovyi
Pivorak MeetUp
 
Introduction to Rails by Evgeniy Hinyuk
Pivorak MeetUp
 
Ruby OOP (in Ukrainian)
Pivorak MeetUp
 
Testing in Ruby
Pivorak MeetUp
 
Ruby Summer Course by #pivorak & OnApp - OOP Basics in Ruby
Pivorak MeetUp
 
The Saga Pattern: 2 years later by Robert Pankowecki
Pivorak MeetUp
 
Data and Bounded Contexts by Volodymyr Byno
Pivorak MeetUp
 
Successful Remote Development by Alex Rozumii
Pivorak MeetUp
 
Origins of Elixir programming language
Pivorak MeetUp
 
Multi language FBP with Flowex by Anton Mishchuk
Pivorak MeetUp
 
Detective story of one clever user - Lightning Talk By Sergiy Kukunin
Pivorak MeetUp
 
CryptoParty: Introduction by Olexii Markovets
Pivorak MeetUp
 
How to make first million by 30 (or not, but tryin') - by Marek Piasecki
Pivorak MeetUp
 
GIS on Rails by Oleksandr Kychun
Pivorak MeetUp
 
Unikernels - Keep It Simple to the Bare Metal
Pivorak MeetUp
 
HTML Canvas tips & tricks - Lightning Talk by Roman Rodych
Pivorak MeetUp
 

Recently uploaded (20)

PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 

Pivorak Clojure by Dmytro Bignyak

  • 1. Clojure )))) How not to be afraid of parentheses Dmytro Bignyak
  • 3. It is not about • in Ruby it takes 5 lines of code but in Clojure only 4 • I show you much code, how cool Clojure is
  • 6. Is that easy? (defn select "Returns a set of the elements for which pred is true" {:added "1.0"} [pred xset] (reduce (fn [s k] (if (pred k) s (disj s k))) xset xset))
  • 8. • It is a functional language • It has functional advantages
  • 9. • Clojure can used as functional style (map (partial * 10) [1 2 3]) ; => [10 20 30] • It also can be used for structures (defrecord Color [red green blue]) (def b (assoc a :alpha 0.1)) ; b => {:alpha 0.1, :red 0.5 :green 0.6, :blue 0.7}
  • 10. Clojure is very useful when you want some ASYNC
  • 11. Clojure has 4 types of links 1. var (thread local) 2. atom (can be synchronically changed, but not coordinately) 3. agent (async state; analogue actor) 4. ref (can be synchronically and coordinately changed)
  • 13. atom (let [x (atom 0)] (println @x) ; => 0 (swap! x inc) (println @x)) ; => 1
  • 14. agent (def a (agent 0)) ; initial state (send a inc) (println @a) ; => 1 (send a (fn [x] (Thread/sleep 100) (inc x))) (println @a) ; => 1 ; in 100ms (println @a) ; => 2
  • 15. • Agents change their state asynchronically • In any time you can call deref and get the state of agent
  • 16. Clojure can be used for MVCC (Multiversion Concurrency Control) (def account1 (ref 100) (def account2 (ref 0)) (dosync (alter account1 - 30) (alter account2 + 30)) (println @account1) ; => 70 (println @account2) ; => 30 (dosync (alter account1 * 0) (alter account2 / 0)) ; => ArithmeticException ; values weren’t changed (println @account1) ; => 70 (println @account2) ; => 30
  • 18. Example core.async (defonce log-chan (chan)) (defn loop-worker [msg] (println msg)) (go-loop [] (let [msg (<! log-chan)] (loop-worker msg) (recur)))
  • 19. Clojure (as all Lisps) is very powerful in metaprogramming (defmacro unless [pred a b] `(if (not ~pred) ~a ~b)) (unless (> 1 10) (println "1 > 10. ok") (println "1 < 10. wat"))
  • 20. Language is nothing without infrastructure
  • 21. • Clojure uses JVM • Eclipse, IDEA plugins • Leiningen building tool • Web frameworks (LuminusWeb, Noir) • Async servers (https://github.com/ztellman/aleph)