SlideShare a Scribd company logo
1 of 71
Download to read offline
Clojure
About me
• humble software engineer @allegro
• kung fu master in spare time
• Almost none of those thoughts are mine.
Presumably there are no new thoughts after
Aristotle. For sure after 1970…
What we think we are
doing?
Computer science
What do we do?
What do we really do?
What we really do
Meet Rich
Who
• Object Oriented?
• Functional Programming?
• What does it mean?
stolen 

from
Uncle

Bob
Async is everywhere
OO vs functional
Quiz
)}; )}; )}; )}; )}; )};
Most frequent code in JS
Most frequent code in Clojure
) ) ) ) ) ) ) )
First impressions
Quick intro to clojure
John McCarty
• Lisp
• interpreters
• high-level metaprogramming
• garbage collection
• dynamic programming
• functional programming
• programming with recursive
functions
• …
Quick intro to clojure
• f(x,y) -> (f x y)
• deleteOffer(2, :force) -> (delete-offer 2 :force)
function params
(def x 1) int x = 1;
(fn [x] (* x x)(def f ))
(f 5)
(defn f [x] (* x x))
Quick intro to clojure
• List

(1 2 3 4 5) (adrian krzychu wojtek) (list 1 2 3)
• Vectors

[1 2 3 4 5] [fred ethel lucy]
• Map 

{:a 1, :b 2, :c 3} {1 “ethel” 2 “fred}
• Sets

#{fred ethel lucy}
• Everything nested

Persistent data structure
Tail recursion
show some code!
(defn neighbours [[x y]]
(for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])]
[(+ dx x) (+ dy y)]))
(defn step [cells]
(set (for [[loc n] (frequencies (mapcat neighbours cells))
:when (or (= n 3) (and (= n 2) (cells loc)))]
loc)))
code from Christophe Grand
stolen from Rich Hickey
stolen from Rich Hickey
stolen from Rich Hickey
stolen from Rich Hickey
The same? Json
def builder = new groovy.json.JsonBuilder()
def root = builder.people {
person {
firstName 'Krzysztof'
lastName 'Kaczmarek'
}
}
(json {:person {
:firstName “Krzysztof”
:lastName “Kaczmarek”}})
Groovy Clojure
The same? Config
offerCoreStockService:
serviceAddress: service://offercore-stock-service
offerCoreService:
serviceAddress: service://offercore-service-server
{:offerCoreStockService
:serviceAddress “service://offercore-stock-service”
:offerCoreService
:serviceAddress “service://offercore-service-server”}
YML Clojure (edn)
The same?
– Greenspun's tenth rule
“Any sufficiently complicated C or Fortran
program contains an ad hoc, informally-
specified, bug-ridden, slow implementation of
half of Common Lisp.”
@RestController @EnableAutoConfiguration 

public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();


@RequestMapping("/greeting") public Greeting greeting(
@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.getAndIncrement(),
} }
String.format(template, name));
example provided by P. Kapała
@RestController @EnableAutoConfiguration 

public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();


@RequestMapping("/greeting") public Greeting greeting(
@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.getAndIncrement(),
} }
String.format(template, name));
example provided by P. Kapała
(def counter (atom 0))
(defn greet [target] 

{:id (swap! counter inc)
:name (str "Hello, " (or target "World") "!")})
(defroutes app-routes 

(GET "/greeting" {params :params}
(response (greet (:name params))))
(route/not-found "Not Found"))
example provided by P. Kapała
(def counter (atom 0))
(defn greet [target] 

{:id (swap! counter inc)
:name (str "Hello, " (or target "World") "!")})
(defroutes app-routes 

(GET "/greeting" {params :params}
(response (greet (:name params))))
(route/not-found "Not Found"))
example provided by P. Kapała
–-- Dr. Alan Kay, 2003.
“OOP to me means only messaging, local
retention and protection and hiding of state-
process, and extreme late-binding of all things. It
can be done in Smalltalk and in LISP. There are
possibly other systems in which this is possible,
but I'm not aware of them.”
–Rich Hickey
“Not everything is awesome.”
Fear - dynamic typing
Report createReport(Data data) {…}
vs
(create-report data)
Fear: Refactoring
Clojure w allegro
Success story?
• Simple rest service
• 2000 lines of code in java
• 150 lines of code in clojure (one 27” screen)
• most people exp: 1/5 of codebase
Java interop
(. Array new)
(. MyAwesomeService doJava “foo” “bar”)
Adoption
Last language?
ClojureScript
• Hosted
• Hello world => 2 LOC in JS
• Is it slow?
• Debugging
• > 2300 watchers
• 68 contributors
Clojure.async
• queues in app
• making app simpler to reason about
Clojure.async
First go
block
>! my queue <!
second go
block
How to learn
4clojure.org
Hype is coming
–Adrian Cockroft
“A lot of the best programmers and the most
productive programmers I know are writing
everything in Clojure and swearing by it, and
then just producing ridiculously sophisticated
things in a very short time. And that programmer
productivity matters. “
http://thenewstack.io/the-new-stack-makers-adrian-cockcroft-on-sun-netflix-clojure-
go-docker-and-more/
Q & A?
krzysztof.kaczmarek@me.com

More Related Content

What's hot

PyData Berlin Meetup
PyData Berlin MeetupPyData Berlin Meetup
PyData Berlin MeetupSteffen Wenz
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88Mahmoud Samir Fayed
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance PythonIan Ozsvald
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemSages
 
CommonJS: JavaScript Everywhere
CommonJS: JavaScript EverywhereCommonJS: JavaScript Everywhere
CommonJS: JavaScript EverywhereKris Kowal
 
Stripe CTF3 wrap-up
Stripe CTF3 wrap-upStripe CTF3 wrap-up
Stripe CTF3 wrap-upStripe
 
Coq to Rubyによる証明駆動開発@名古屋ruby会議02
Coq to Rubyによる証明駆動開発@名古屋ruby会議02Coq to Rubyによる証明駆動開発@名古屋ruby会議02
Coq to Rubyによる証明駆動開発@名古屋ruby会議02Hiroki Mizuno
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring ClojurescriptLuke Donnet
 
Garbage collector in python
Garbage collector in pythonGarbage collector in python
Garbage collector in pythonIbrahim Kasim
 
Coqによる証明駆動開発
Coqによる証明駆動開発Coqによる証明駆動開発
Coqによる証明駆動開発Hiroki Mizuno
 
ClojureScript: The Good Parts
ClojureScript: The Good PartsClojureScript: The Good Parts
ClojureScript: The Good PartsKent Ohashi
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the webMichiel Borkent
 
Jakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheelJakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheeltcurdt
 
Rust tutorial from Boston Meetup 2015-07-22
Rust tutorial from Boston Meetup 2015-07-22Rust tutorial from Boston Meetup 2015-07-22
Rust tutorial from Boston Meetup 2015-07-22nikomatsakis
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureMike Fogus
 
Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»DataArt
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
(Fun clojure)
(Fun clojure)(Fun clojure)
(Fun clojure)Timo Sulg
 

What's hot (20)

PyData Berlin Meetup
PyData Berlin MeetupPyData Berlin Meetup
PyData Berlin Meetup
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88
 
Full Stack Clojure
Full Stack ClojureFull Stack Clojure
Full Stack Clojure
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemWprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
Wprowadzenie do technologii Big Data / Intro to Big Data Ecosystem
 
CommonJS: JavaScript Everywhere
CommonJS: JavaScript EverywhereCommonJS: JavaScript Everywhere
CommonJS: JavaScript Everywhere
 
Stripe CTF3 wrap-up
Stripe CTF3 wrap-upStripe CTF3 wrap-up
Stripe CTF3 wrap-up
 
Coq to Rubyによる証明駆動開発@名古屋ruby会議02
Coq to Rubyによる証明駆動開発@名古屋ruby会議02Coq to Rubyによる証明駆動開発@名古屋ruby会議02
Coq to Rubyによる証明駆動開発@名古屋ruby会議02
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
Coffee script
Coffee scriptCoffee script
Coffee script
 
Garbage collector in python
Garbage collector in pythonGarbage collector in python
Garbage collector in python
 
Coqによる証明駆動開発
Coqによる証明駆動開発Coqによる証明駆動開発
Coqによる証明駆動開発
 
ClojureScript: The Good Parts
ClojureScript: The Good PartsClojureScript: The Good Parts
ClojureScript: The Good Parts
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the web
 
Jakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheelJakarta Commons - Don't re-invent the wheel
Jakarta Commons - Don't re-invent the wheel
 
Rust tutorial from Boston Meetup 2015-07-22
Rust tutorial from Boston Meetup 2015-07-22Rust tutorial from Boston Meetup 2015-07-22
Rust tutorial from Boston Meetup 2015-07-22
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of Clojure
 
Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»Леонид Шевцов «Clojure в деле»
Леонид Шевцов «Clojure в деле»
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
(Fun clojure)
(Fun clojure)(Fun clojure)
(Fun clojure)
 

Viewers also liked

[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemy
[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemy[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemy
[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemyPROIDEA
 
MCE^3 - C. Todd Lombardo - Organizational Dynamics of Innovation
MCE^3 - C. Todd Lombardo -  Organizational Dynamics of InnovationMCE^3 - C. Todd Lombardo -  Organizational Dynamics of Innovation
MCE^3 - C. Todd Lombardo - Organizational Dynamics of InnovationPROIDEA
 
4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor Farafonow
4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor Farafonow4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor Farafonow
4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor FarafonowPROIDEA
 
Atmosphere 2016 - Justin arbuckle - A tale of the constructors
Atmosphere 2016 - Justin arbuckle  - A tale of the constructorsAtmosphere 2016 - Justin arbuckle  - A tale of the constructors
Atmosphere 2016 - Justin arbuckle - A tale of the constructorsPROIDEA
 
[4developers2016] - Security in the era of modern applications and services (...
[4developers2016] - Security in the era of modern applications and services (...[4developers2016] - Security in the era of modern applications and services (...
[4developers2016] - Security in the era of modern applications and services (...PROIDEA
 
Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016
Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016
Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016PROIDEA
 
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars PROIDEA
 
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław BorekPLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław BorekPROIDEA
 
Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...
Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...
Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...PROIDEA
 
4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał Gruca
4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał Gruca4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał Gruca
4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał GrucaPROIDEA
 
PLNOG15: Virtualization and automation of network and security services in Da...
PLNOG15: Virtualization and automation of network and security services in Da...PLNOG15: Virtualization and automation of network and security services in Da...
PLNOG15: Virtualization and automation of network and security services in Da...PROIDEA
 
PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...
PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...
PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...PROIDEA
 
PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...
PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...
PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...PROIDEA
 
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The Pipeline
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The PipelineDOD 2016 - Sebastian Krzyszkowiak - Jenkins: The Pipeline
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The PipelinePROIDEA
 
PLNOG 17 - Tomás Strašák - Latencja jest decydentem
PLNOG 17 - Tomás Strašák - Latencja jest decydentemPLNOG 17 - Tomás Strašák - Latencja jest decydentem
PLNOG 17 - Tomás Strašák - Latencja jest decydentemPROIDEA
 
infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"
infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"
infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"PROIDEA
 
infraxstructure: Jarosław Zieliński i Sławomir Stanek "Wojna o Wirtualizację...
infraxstructure: Jarosław Zieliński i Sławomir Stanek  "Wojna o Wirtualizację...infraxstructure: Jarosław Zieliński i Sławomir Stanek  "Wojna o Wirtualizację...
infraxstructure: Jarosław Zieliński i Sławomir Stanek "Wojna o Wirtualizację...PROIDEA
 
PLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław Burnejko
PLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław BurnejkoPLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław Burnejko
PLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław BurnejkoPROIDEA
 

Viewers also liked (18)

[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemy
[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemy[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemy
[CONFidence 2016] Leszek Miś - Honey(pot) flavored hunt for cyber enemy
 
MCE^3 - C. Todd Lombardo - Organizational Dynamics of Innovation
MCE^3 - C. Todd Lombardo -  Organizational Dynamics of InnovationMCE^3 - C. Todd Lombardo -  Organizational Dynamics of Innovation
MCE^3 - C. Todd Lombardo - Organizational Dynamics of Innovation
 
4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor Farafonow
4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor Farafonow4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor Farafonow
4Developers 2015: Parę słów o odpowiedzialności projektanta UX - Igor Farafonow
 
Atmosphere 2016 - Justin arbuckle - A tale of the constructors
Atmosphere 2016 - Justin arbuckle  - A tale of the constructorsAtmosphere 2016 - Justin arbuckle  - A tale of the constructors
Atmosphere 2016 - Justin arbuckle - A tale of the constructors
 
[4developers2016] - Security in the era of modern applications and services (...
[4developers2016] - Security in the era of modern applications and services (...[4developers2016] - Security in the era of modern applications and services (...
[4developers2016] - Security in the era of modern applications and services (...
 
Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016
Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016
Konrad Kokosa - Pamięć w .NET - od ogólu do szczegółu- 4developers2016
 
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
MCE^3 - Jorge D. Ortiz - Fuentes - Escape From Mars
 
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław BorekPLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
PLNOG14: Service orchestration in provider network, Tail-f - Przemysław Borek
 
Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...
Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...
Atmosphere Conference 2015: Building And Releasing A Massively Multiplayer On...
 
4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał Gruca
4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał Gruca4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał Gruca
4Developers 2015: Refactoring za duże pieniądze, pierwsze kroki - Michał Gruca
 
PLNOG15: Virtualization and automation of network and security services in Da...
PLNOG15: Virtualization and automation of network and security services in Da...PLNOG15: Virtualization and automation of network and security services in Da...
PLNOG15: Virtualization and automation of network and security services in Da...
 
PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...
PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...
PLNOG 17 - Konrad Kulikowski - Cisco WAE - Wan Automation Engine - Co SDN moż...
 
PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...
PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...
PLNOG 17 - Marcin Aronowski - Technologie dostępowe dla IoT. Jak się w tym ws...
 
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The Pipeline
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The PipelineDOD 2016 - Sebastian Krzyszkowiak - Jenkins: The Pipeline
DOD 2016 - Sebastian Krzyszkowiak - Jenkins: The Pipeline
 
PLNOG 17 - Tomás Strašák - Latencja jest decydentem
PLNOG 17 - Tomás Strašák - Latencja jest decydentemPLNOG 17 - Tomás Strašák - Latencja jest decydentem
PLNOG 17 - Tomás Strašák - Latencja jest decydentem
 
infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"
infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"
infraxstructure: Stas Levitan, "Always On" business in cloud - 2016"
 
infraxstructure: Jarosław Zieliński i Sławomir Stanek "Wojna o Wirtualizację...
infraxstructure: Jarosław Zieliński i Sławomir Stanek  "Wojna o Wirtualizację...infraxstructure: Jarosław Zieliński i Sławomir Stanek  "Wojna o Wirtualizację...
infraxstructure: Jarosław Zieliński i Sławomir Stanek "Wojna o Wirtualizację...
 
PLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław Burnejko
PLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław BurnejkoPLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław Burnejko
PLNOG16: Microsoft Azure dla Inżynierów Sieciowych, Mirosław Burnejko
 

Similar to Atmosphere 2016 - Krzysztof Kaczmarek - Don't fear the brackets - Clojure in the eyes of Java Developer

Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software DevelopmentNaveenkumar Muguda
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - StockholmJan Kronquist
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Charles Nutter
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийSigma Software
 
Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable LispAstrails
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to GoJaehue Jang
 
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티JaeYeoul Ahn
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with ClojureJohn Stevenson
 
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...Codemotion
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011Thadeu Russo
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]RootedCON
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformationLars Marius Garshol
 
Clojure/conj 2017
Clojure/conj 2017Clojure/conj 2017
Clojure/conj 2017Darren Kim
 

Similar to Atmosphere 2016 - Krzysztof Kaczmarek - Don't fear the brackets - Clojure in the eyes of Java Developer (20)

Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
Clojure intro
Clojure introClojure intro
Clojure intro
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
 
Ruby is an Acceptable Lisp
Ruby is an Acceptable LispRuby is an Acceptable Lisp
Ruby is an Acceptable Lisp
 
iSoligorsk #3 2013
iSoligorsk #3 2013iSoligorsk #3 2013
iSoligorsk #3 2013
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
Go 프로그래밍 소개 - 장재휴, DomainDriven커뮤니티
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
 
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
Jose Selvi - Side-Channels Uncovered [rootedvlc2018]
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
Clojure/conj 2017
Clojure/conj 2017Clojure/conj 2017
Clojure/conj 2017
 

Recently uploaded

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Atmosphere 2016 - Krzysztof Kaczmarek - Don't fear the brackets - Clojure in the eyes of Java Developer

  • 2. About me • humble software engineer @allegro • kung fu master in spare time • Almost none of those thoughts are mine. Presumably there are no new thoughts after Aristotle. For sure after 1970…
  • 3. What we think we are doing? Computer science
  • 4.
  • 6. What do we really do?
  • 9.
  • 10.
  • 11. Who • Object Oriented? • Functional Programming? • What does it mean?
  • 12.
  • 14.
  • 17.
  • 18. Quiz )}; )}; )}; )}; )}; )}; Most frequent code in JS Most frequent code in Clojure ) ) ) ) ) ) ) )
  • 20.
  • 21. Quick intro to clojure
  • 22. John McCarty • Lisp • interpreters • high-level metaprogramming • garbage collection • dynamic programming • functional programming • programming with recursive functions • …
  • 23. Quick intro to clojure • f(x,y) -> (f x y) • deleteOffer(2, :force) -> (delete-offer 2 :force) function params
  • 24. (def x 1) int x = 1; (fn [x] (* x x)(def f )) (f 5) (defn f [x] (* x x))
  • 25. Quick intro to clojure • List
 (1 2 3 4 5) (adrian krzychu wojtek) (list 1 2 3) • Vectors
 [1 2 3 4 5] [fred ethel lucy] • Map 
 {:a 1, :b 2, :c 3} {1 “ethel” 2 “fred} • Sets
 #{fred ethel lucy} • Everything nested

  • 28.
  • 29.
  • 31. (defn neighbours [[x y]] (for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])] [(+ dx x) (+ dy y)])) (defn step [cells] (set (for [[loc n] (frequencies (mapcat neighbours cells)) :when (or (= n 3) (and (= n 2) (cells loc)))] loc))) code from Christophe Grand
  • 34.
  • 35.
  • 36.
  • 39. The same? Json def builder = new groovy.json.JsonBuilder() def root = builder.people { person { firstName 'Krzysztof' lastName 'Kaczmarek' } } (json {:person { :firstName “Krzysztof” :lastName “Kaczmarek”}}) Groovy Clojure
  • 40. The same? Config offerCoreStockService: serviceAddress: service://offercore-stock-service offerCoreService: serviceAddress: service://offercore-service-server {:offerCoreStockService :serviceAddress “service://offercore-stock-service” :offerCoreService :serviceAddress “service://offercore-service-server”} YML Clojure (edn)
  • 42. – Greenspun's tenth rule “Any sufficiently complicated C or Fortran program contains an ad hoc, informally- specified, bug-ridden, slow implementation of half of Common Lisp.”
  • 43.
  • 44. @RestController @EnableAutoConfiguration 
 public class GreetingController { private static final String template = "Hello, %s!"; private final AtomicLong counter = new AtomicLong(); 
 @RequestMapping("/greeting") public Greeting greeting( @RequestParam(value="name", defaultValue="World") String name) { return new Greeting(counter.getAndIncrement(), } } String.format(template, name)); example provided by P. Kapała
  • 45. @RestController @EnableAutoConfiguration 
 public class GreetingController { private static final String template = "Hello, %s!"; private final AtomicLong counter = new AtomicLong(); 
 @RequestMapping("/greeting") public Greeting greeting( @RequestParam(value="name", defaultValue="World") String name) { return new Greeting(counter.getAndIncrement(), } } String.format(template, name)); example provided by P. Kapała
  • 46. (def counter (atom 0)) (defn greet [target] 
 {:id (swap! counter inc) :name (str "Hello, " (or target "World") "!")}) (defroutes app-routes 
 (GET "/greeting" {params :params} (response (greet (:name params)))) (route/not-found "Not Found")) example provided by P. Kapała
  • 47. (def counter (atom 0)) (defn greet [target] 
 {:id (swap! counter inc) :name (str "Hello, " (or target "World") "!")}) (defroutes app-routes 
 (GET "/greeting" {params :params} (response (greet (:name params)))) (route/not-found "Not Found")) example provided by P. Kapała
  • 48. –-- Dr. Alan Kay, 2003. “OOP to me means only messaging, local retention and protection and hiding of state- process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.”
  • 49.
  • 51. Fear - dynamic typing Report createReport(Data data) {…} vs (create-report data)
  • 54.
  • 55. Success story? • Simple rest service • 2000 lines of code in java • 150 lines of code in clojure (one 27” screen) • most people exp: 1/5 of codebase
  • 56. Java interop (. Array new) (. MyAwesomeService doJava “foo” “bar”)
  • 59. ClojureScript • Hosted • Hello world => 2 LOC in JS • Is it slow? • Debugging • > 2300 watchers • 68 contributors
  • 60. Clojure.async • queues in app • making app simpler to reason about
  • 61. Clojure.async First go block >! my queue <! second go block
  • 64.
  • 66. –Adrian Cockroft “A lot of the best programmers and the most productive programmers I know are writing everything in Clojure and swearing by it, and then just producing ridiculously sophisticated things in a very short time. And that programmer productivity matters. “ http://thenewstack.io/the-new-stack-makers-adrian-cockcroft-on-sun-netflix-clojure- go-docker-and-more/
  • 67.
  • 68.
  • 69.
  • 70.