SlideShare a Scribd company logo
1 of 9
Download to read offline
Clojure
Since	
  2007
About Clojure
• A	
  dynamic,	
  predominantly	
  functional	
  descendent	
  of	
  
Lisp	
  
• Runs	
  on	
  the	
  JVM	
  (and	
  on	
  JavaScript	
  &	
  CLR)	
  
• Multithreading-­‐friendly:	
  Immutable,	
  thread-­‐safe	
  
data	
  structures	
  with	
  value	
  semantics;	
  Software	
  
Transactional	
  Memory	
  
• Compiled	
  but	
  dynamic:	
  Anything	
  you	
  can	
  do	
  at	
  
compile	
  time,	
  you	
  can	
  do	
  at	
  runtime	
  
• Code-­‐as-­‐data	
  :	
  “homo-­‐iconicity”	
  &	
  metaprogramming	
  
• And	
  ...	
  polymorphism,	
  reactive	
  agents,	
  optional	
  
type	
  hinting,	
  constant-­‐space	
  recursive	
  looping
Looks like Lisp:
(ns	
  fizzbuzz.core)	
  
!
(defn	
  fizzbuzzat	
  [i]	
  
	
  	
  	
  	
  	
  	
  (cond	
  
	
  	
  	
  	
  	
  	
  	
  	
  (=	
  0	
  (rem	
  i	
  15))	
  "fizzbuzz"	
  
	
  	
  	
  	
  	
  	
  	
  	
  (=	
  0	
  (rem	
  i	
  	
  3))	
  "fizz"	
  
	
  	
  	
  	
  	
  	
  	
  	
  (=	
  0	
  (rem	
  i	
  	
  5))	
  "buzz"	
  
	
  	
  	
  	
  	
  	
  	
  	
  :else	
  i))	
  
(defn	
  fizzbuzz	
  [n]	
  
	
   (take	
  n	
  	
  
	
  	
  	
  	
   (map	
  fizzbuzzat	
  (iterate	
  inc	
  1))))	
  
!
!
(fizzbuzz	
  16)	
  
;;Result: (1 2 "fizz" 4 "buzz" "fizz" 7 8 "fizz"
"buzz" 11 "fizz" 13 14 "fizzbuzz" 16)
Reading Lisp!
Lisp has 1 main structure - the
list.
Evaluate a list by taking the first
item as a function; and all the
rest as parameters.
namespace fizzbuzz.core
define function fizzbuzzat with parameter: i
Condition: if i divided by 15 has remainder
0, then return “fizzbuzz”; else if i divides by 3
return fizz; else if i divides by 5 return buzz;
else return i
define function fizz buzz with parameter n
take: take just the first n of the
following (presumably long) sequence
map: change each item in the
following sequence by applying the
function fizzbuzzat to it. Return the
sequence of changed items
It all starts here:

iterate means: take the seed value of 1; apply the function inc (for increment-by-1)
to it; then apply inc to that; then again forever. This gives us the (infinite ) sequence
1,2,3,4,5,6,… etc
Clojure	
  
!
Your	
  first	
  10	
  
minutes:

!
http://tryclj.com	
  
Immutability &
Value types as the norm
(ns	
  eg.core)	
  
!
(defn	
  try-­‐to-­‐mutate	
  [	
  x	
  ]	
  
	
  	
  (let	
  [x	
  (conj	
  x	
  ’LOTS)]	
  	
  
	
   	
   	
   	
   	
   ;;	
  joins	
  ‘LOTS’	
  to	
  x	
  
	
  	
  	
  	
  x))	
  
(let	
  [x	
  [1	
  2	
  3]]	
  
	
  	
  (try-­‐to-­‐mutate	
  x	
  )	
  	
  
	
  	
  (print	
  "x	
  is	
  :	
  "	
  x	
  "n"	
  ))	
  	
  
	
   	
   	
   	
   ;;	
  result:	
  “x	
  is	
  :	
  [1	
  2	
  3]”	
  
!
;;	
  State	
  is	
  a	
  series	
  of	
  immutable	
  values	
  over	
  
;;	
  time
function try-to-mutate will compile and
run, but won’t actually mutate x. The x
created by (let [x …] will be a new x,
which hides, not changes, the parameter
also called x
1. let x be [1,2,3]
2. call try-to-mutate on x
3. print it.
Behold. x is still [1,2,3]. There is no
syntax for changing a value.
Meta-programming
& macros
;;A	
  simple	
  example	
  looks	
  just	
  like	
  a	
  function	
  
!
(defmacro	
  hello	
  [x]	
  
	
  	
  (str	
  "Hello,	
  "	
  x))	
  
!
;;	
  But	
  macros	
  extend	
  the	
  compiler.	
  
;;	
  You	
  can	
  add	
  new	
  keywords,	
  constructs	
  and	
  
;;	
  grammar	
  to	
  the	
  language	
  
!
(defmacro	
  unless	
  
	
  	
  	
  [condition	
  &	
  forms]	
  
	
  	
  	
  	
  	
  `(if	
  (not	
  ~condition)	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  ~@forms))	
  
!
(unless	
  (<	
  age	
  18)	
  (applytojoin	
  name	
  email	
  ))	
  
macros in lisp-languages are not weedy things as in
other languages. They can change the language
extensively, adding new keywords and new syntax
Software transactional
memory
;;	
  Very	
  like	
  database	
  transactions	
  with	
  transaction	
  	
  
;;	
  isolation	
  level	
  set	
  to	
  Snapshot.	
  
;;	
  A	
  threads	
  sees	
  the	
  'snapshot'	
  of	
  all	
  values	
  that	
  were	
  	
  
;;	
  there	
  when	
  the	
  transaction	
  started.	
  No	
  locks	
  are	
  used,	
  	
  
;;	
  it’s	
  all	
  optimistic	
  using	
  'row	
  versions’	
  	
  
;;	
  and	
  will	
  retry	
  repeatedly	
  if	
  a	
  collision	
  occurs	
  
;;	
  Transactions	
  are	
  of	
  course	
  ACID	
  (in	
  memory)	
  
!
(def	
  myEntity	
  (ref	
  ["Initial	
  Value"	
  1	
  2	
  3]))	
  	
  
!
(ref-­‐set	
  myEntity	
  	
  ["Very	
  new	
  value"])	
  
;;	
  throws	
  an	
  IllegalStateException,	
  no	
  transaction	
  running	
  
!
;;	
  Use	
  dosync	
  to	
  wrap	
  it	
  in	
  a	
  transaction	
  
(dosync	
  
	
  	
  (ref-­‐set	
  myEntity	
  ["New	
  Value"	
  4	
  5	
  6])	
  
	
  	
  )
Comments on OO/FP
• “Mutable	
  Shared	
  State	
  is	
  the	
  new	
  spaghetti	
  code”	
  
• “OO	
  was	
  born	
  of	
  simulation	
  &	
  now	
  used	
  for	
  
everything,	
  even	
  when	
  inappropriate”	
  
• “An	
  identity	
  is	
  an	
  entity	
  that	
  has	
  a	
  state,	
  which	
  
is	
  its	
  value	
  at	
  a	
  point	
  in	
  time.	
  And	
  a	
  value	
  is	
  
something	
  that	
  doesn't	
  change.”	
  
• “It	
  is	
  better	
  to	
  have	
  100	
  functions	
  operate	
  on	
  one	
  
data	
  structure	
  than	
  to	
  have	
  10	
  functions	
  operate	
  on	
  
10	
  data	
  structures.”	
  -­‐	
  Alan	
  J.	
  Perlis	
  
• You	
  need	
  Entities/Identity	
  much	
  less	
  than	
  you	
  think	
  
-­‐	
  90%	
  of	
  the	
  time,	
  values	
  are	
  all	
  you	
  really	
  want	
  
• OO	
  hides	
  state	
  away.	
  FP	
  pushes	
  state	
  out:	
  it’s	
  an	
  
injected	
  dependency.
quotes
in
quotes
are
by
Rich
Hickey
Clojure	
  
!
Your	
  first	
  10	
  minutes:	
  
http://tryclj.com	
  
!
The	
  next	
  10	
  hours:	
  
http://
clojurescriptkoans.com	
  
	
  	
  
http://clojurekoans.com	
  
google://clojure+xxx

More Related Content

What's hot

Optimizing Communicating Event-Loop Languages with Truffle
Optimizing Communicating Event-Loop Languages with TruffleOptimizing Communicating Event-Loop Languages with Truffle
Optimizing Communicating Event-Loop Languages with TruffleStefan Marr
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
Kotlin workshop 2018-06-11
Kotlin workshop 2018-06-11Kotlin workshop 2018-06-11
Kotlin workshop 2018-06-11Åsa Pehrsson
 
DevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingDevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingHenri Tremblay
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronouskang taehun
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesDominic Graefen
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Divedavanum
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring ClojurescriptLuke Donnet
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Insidejeffz
 
Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...
Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...
Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...Stefan Marr
 
Why Is Concurrent Programming Hard? And What Can We Do about It?
Why Is Concurrent Programming Hard? And What Can We Do about It?Why Is Concurrent Programming Hard? And What Can We Do about It?
Why Is Concurrent Programming Hard? And What Can We Do about It?Stefan Marr
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and SimpleBen Mabey
 
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019Rafał Leszko
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
Reactive Programming and RxJS
Reactive Programming and RxJSReactive Programming and RxJS
Reactive Programming and RxJSDenis Gorbunov
 

What's hot (19)

Clojure functions v
Clojure functions vClojure functions v
Clojure functions v
 
Optimizing Communicating Event-Loop Languages with Truffle
Optimizing Communicating Event-Loop Languages with TruffleOptimizing Communicating Event-Loop Languages with Truffle
Optimizing Communicating Event-Loop Languages with Truffle
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Kotlin workshop 2018-06-11
Kotlin workshop 2018-06-11Kotlin workshop 2018-06-11
Kotlin workshop 2018-06-11
 
DevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingDevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programming
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronous
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love Parantheses
 
Oslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep DiveOslo.versioned objects - Deep Dive
Oslo.versioned objects - Deep Dive
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
 
Clojure
ClojureClojure
Clojure
 
Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...
Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...
Tracing versus Partial Evaluation: Which Meta-Compilation Approach is Better ...
 
Why Is Concurrent Programming Hard? And What Can We Do about It?
Why Is Concurrent Programming Hard? And What Can We Do about It?Why Is Concurrent Programming Hard? And What Can We Do about It?
Why Is Concurrent Programming Hard? And What Can We Do about It?
 
iSoligorsk #3 2013
iSoligorsk #3 2013iSoligorsk #3 2013
iSoligorsk #3 2013
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and Simple
 
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Clojure & Scala
Clojure & ScalaClojure & Scala
Clojure & Scala
 
Reactive Programming and RxJS
Reactive Programming and RxJSReactive Programming and RxJS
Reactive Programming and RxJS
 

Similar to Clojure (and some lisp) in 10 mins for OO developers

The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
 
I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?sbjug
 
A Taste of Clojure
A Taste of ClojureA Taste of Clojure
A Taste of ClojureDavid Leung
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of JavascriptSamuel Abraham
 
Indic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndicThreads
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011Patrick Walton
 
Trends in programming languages
Trends in programming languagesTrends in programming languages
Trends in programming languagesAntya Dev
 
Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)William Farrell
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debuggerIulian Dragos
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with ClojureJohn Stevenson
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)jaxLondonConference
 
Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...
Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...
Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...Novell
 
Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languagesStarTech Conference
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypseelliando dias
 

Similar to Clojure (and some lisp) in 10 mins for OO developers (20)

The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)The Evolution of Async-Programming on .NET Platform (.Net China, C#)
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
 
I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?
 
A Taste of Clojure
A Taste of ClojureA Taste of Clojure
A Taste of Clojure
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
 
Clojure class
Clojure classClojure class
Clojure class
 
Indic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvmIndic threads pune12-polyglot & functional programming on jvm
Indic threads pune12-polyglot & functional programming on jvm
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011
 
Trends in programming languages
Trends in programming languagesTrends in programming languages
Trends in programming languages
 
Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)Building Hermetic Systems (without Docker)
Building Hermetic Systems (without Docker)
 
Clojure intro
Clojure introClojure intro
Clojure intro
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debugger
 
Get into Functional Programming with Clojure
Get into Functional Programming with ClojureGet into Functional Programming with Clojure
Get into Functional Programming with Clojure
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
 
Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...
Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...
Working with XSLT, XPath and ECMA Scripts: Make It Simpler with Novell Identi...
 
Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languages
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
 
JavaScript Looping Statements
JavaScript Looping StatementsJavaScript Looping Statements
JavaScript Looping Statements
 

More from Chris F Carroll

Software Technical Design for Information Security: A short intro for Tech Le...
Software Technical Design for Information Security: A short intro for Tech Le...Software Technical Design for Information Security: A short intro for Tech Le...
Software Technical Design for Information Security: A short intro for Tech Le...Chris F Carroll
 
What is Security, anyway? Software architecture for information security part...
What is Security, anyway? Software architecture for information security part...What is Security, anyway? Software architecture for information security part...
What is Security, anyway? Software architecture for information security part...Chris F Carroll
 
Deep Learning in 90 seconds. With a side of Algorithm Bias
Deep Learning in 90 seconds. With a side of Algorithm BiasDeep Learning in 90 seconds. With a side of Algorithm Bias
Deep Learning in 90 seconds. With a side of Algorithm BiasChris F Carroll
 
Agile Software Architecture
Agile Software ArchitectureAgile Software Architecture
Agile Software ArchitectureChris F Carroll
 
Software Architecture: Why and What?
Software Architecture: Why and What?Software Architecture: Why and What?
Software Architecture: Why and What?Chris F Carroll
 
Doing Architecture with Agile Teams IASA UK Summit 2013
Doing Architecture with Agile Teams IASA UK Summit 2013Doing Architecture with Agile Teams IASA UK Summit 2013
Doing Architecture with Agile Teams IASA UK Summit 2013Chris F Carroll
 
XP-Manchester 2013 Software Architecture for Agile Developers Intro
XP-Manchester 2013 Software Architecture for Agile Developers IntroXP-Manchester 2013 Software Architecture for Agile Developers Intro
XP-Manchester 2013 Software Architecture for Agile Developers IntroChris F Carroll
 

More from Chris F Carroll (7)

Software Technical Design for Information Security: A short intro for Tech Le...
Software Technical Design for Information Security: A short intro for Tech Le...Software Technical Design for Information Security: A short intro for Tech Le...
Software Technical Design for Information Security: A short intro for Tech Le...
 
What is Security, anyway? Software architecture for information security part...
What is Security, anyway? Software architecture for information security part...What is Security, anyway? Software architecture for information security part...
What is Security, anyway? Software architecture for information security part...
 
Deep Learning in 90 seconds. With a side of Algorithm Bias
Deep Learning in 90 seconds. With a side of Algorithm BiasDeep Learning in 90 seconds. With a side of Algorithm Bias
Deep Learning in 90 seconds. With a side of Algorithm Bias
 
Agile Software Architecture
Agile Software ArchitectureAgile Software Architecture
Agile Software Architecture
 
Software Architecture: Why and What?
Software Architecture: Why and What?Software Architecture: Why and What?
Software Architecture: Why and What?
 
Doing Architecture with Agile Teams IASA UK Summit 2013
Doing Architecture with Agile Teams IASA UK Summit 2013Doing Architecture with Agile Teams IASA UK Summit 2013
Doing Architecture with Agile Teams IASA UK Summit 2013
 
XP-Manchester 2013 Software Architecture for Agile Developers Intro
XP-Manchester 2013 Software Architecture for Agile Developers IntroXP-Manchester 2013 Software Architecture for Agile Developers Intro
XP-Manchester 2013 Software Architecture for Agile Developers Intro
 

Recently uploaded

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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

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
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Clojure (and some lisp) in 10 mins for OO developers

  • 2. About Clojure • A  dynamic,  predominantly  functional  descendent  of   Lisp   • Runs  on  the  JVM  (and  on  JavaScript  &  CLR)   • Multithreading-­‐friendly:  Immutable,  thread-­‐safe   data  structures  with  value  semantics;  Software   Transactional  Memory   • Compiled  but  dynamic:  Anything  you  can  do  at   compile  time,  you  can  do  at  runtime   • Code-­‐as-­‐data  :  “homo-­‐iconicity”  &  metaprogramming   • And  ...  polymorphism,  reactive  agents,  optional   type  hinting,  constant-­‐space  recursive  looping
  • 3. Looks like Lisp: (ns  fizzbuzz.core)   ! (defn  fizzbuzzat  [i]              (cond                  (=  0  (rem  i  15))  "fizzbuzz"                  (=  0  (rem  i    3))  "fizz"                  (=  0  (rem  i    5))  "buzz"                  :else  i))   (defn  fizzbuzz  [n]     (take  n             (map  fizzbuzzat  (iterate  inc  1))))   ! ! (fizzbuzz  16)   ;;Result: (1 2 "fizz" 4 "buzz" "fizz" 7 8 "fizz" "buzz" 11 "fizz" 13 14 "fizzbuzz" 16) Reading Lisp! Lisp has 1 main structure - the list. Evaluate a list by taking the first item as a function; and all the rest as parameters. namespace fizzbuzz.core define function fizzbuzzat with parameter: i Condition: if i divided by 15 has remainder 0, then return “fizzbuzz”; else if i divides by 3 return fizz; else if i divides by 5 return buzz; else return i define function fizz buzz with parameter n take: take just the first n of the following (presumably long) sequence map: change each item in the following sequence by applying the function fizzbuzzat to it. Return the sequence of changed items It all starts here:
 iterate means: take the seed value of 1; apply the function inc (for increment-by-1) to it; then apply inc to that; then again forever. This gives us the (infinite ) sequence 1,2,3,4,5,6,… etc
  • 4. Clojure   ! Your  first  10   minutes:
 ! http://tryclj.com  
  • 5. Immutability & Value types as the norm (ns  eg.core)   ! (defn  try-­‐to-­‐mutate  [  x  ]      (let  [x  (conj  x  ’LOTS)]               ;;  joins  ‘LOTS’  to  x          x))   (let  [x  [1  2  3]]      (try-­‐to-­‐mutate  x  )        (print  "x  is  :  "  x  "n"  ))             ;;  result:  “x  is  :  [1  2  3]”   ! ;;  State  is  a  series  of  immutable  values  over   ;;  time function try-to-mutate will compile and run, but won’t actually mutate x. The x created by (let [x …] will be a new x, which hides, not changes, the parameter also called x 1. let x be [1,2,3] 2. call try-to-mutate on x 3. print it. Behold. x is still [1,2,3]. There is no syntax for changing a value.
  • 6. Meta-programming & macros ;;A  simple  example  looks  just  like  a  function   ! (defmacro  hello  [x]      (str  "Hello,  "  x))   ! ;;  But  macros  extend  the  compiler.   ;;  You  can  add  new  keywords,  constructs  and   ;;  grammar  to  the  language   ! (defmacro  unless        [condition  &  forms]            `(if  (not  ~condition)                      ~@forms))   ! (unless  (<  age  18)  (applytojoin  name  email  ))   macros in lisp-languages are not weedy things as in other languages. They can change the language extensively, adding new keywords and new syntax
  • 7. Software transactional memory ;;  Very  like  database  transactions  with  transaction     ;;  isolation  level  set  to  Snapshot.   ;;  A  threads  sees  the  'snapshot'  of  all  values  that  were     ;;  there  when  the  transaction  started.  No  locks  are  used,     ;;  it’s  all  optimistic  using  'row  versions’     ;;  and  will  retry  repeatedly  if  a  collision  occurs   ;;  Transactions  are  of  course  ACID  (in  memory)   ! (def  myEntity  (ref  ["Initial  Value"  1  2  3]))     ! (ref-­‐set  myEntity    ["Very  new  value"])   ;;  throws  an  IllegalStateException,  no  transaction  running   ! ;;  Use  dosync  to  wrap  it  in  a  transaction   (dosync      (ref-­‐set  myEntity  ["New  Value"  4  5  6])      )
  • 8. Comments on OO/FP • “Mutable  Shared  State  is  the  new  spaghetti  code”   • “OO  was  born  of  simulation  &  now  used  for   everything,  even  when  inappropriate”   • “An  identity  is  an  entity  that  has  a  state,  which   is  its  value  at  a  point  in  time.  And  a  value  is   something  that  doesn't  change.”   • “It  is  better  to  have  100  functions  operate  on  one   data  structure  than  to  have  10  functions  operate  on   10  data  structures.”  -­‐  Alan  J.  Perlis   • You  need  Entities/Identity  much  less  than  you  think   -­‐  90%  of  the  time,  values  are  all  you  really  want   • OO  hides  state  away.  FP  pushes  state  out:  it’s  an   injected  dependency. quotes in quotes are by Rich Hickey
  • 9. Clojure   ! Your  first  10  minutes:   http://tryclj.com   ! The  next  10  hours:   http:// clojurescriptkoans.com       http://clojurekoans.com   google://clojure+xxx