SlideShare a Scribd company logo
1 of 49
Download to read offline
Clojure


    John Vlachoyiannis
         @jonromero
   jon@emotionull.com
Http://jon.is.emotionull.com
What is Clojure?
Ok, what is Lisp?
“Lisp is worth learning for the profound
  enlightenment experience you will have
when you finally get it; that experience will
make you a better programmer for the rest
of your days, even if you never actually use
              Lisp itself a lot."


   Eric S. Raymond, "How to Become a
                Hacker".
“LISP stands for: Lots of Insane Stupid
            Parentheses”

             Anonymous
The Truth about Lisp
LISt Processing
              LIS
●   Second oldest high-level language (first is
    Fortran)
●   Code as Data (Homoiconic)
●   Perfect for Domain-specific languages
    (DSL)
●   Exploratory programming
Clojure
●   Lisp in JVM
●   Concurrent programming
●   Dynamic Development (REPL)
●   Lazy sequences
●   No side effects   (almost)
Enter Clojure
Everything is code
(println "Hello World")




function        argument
Everything is data
(println "Hello World")
list


       symbol          string
●   Integers – 1234567891234
●   Doubles – 3.14. BigDecimals – 3.14M
●   Ratios – 22/4
●   Strings – '”foo”, Character – a b c
●   Symbols – foo, Keywords :foo
●   Booleans – true false, Null – nil
●   Regex patterns – #”[a-zA-Z0-9]|
Data structures
●   Lists
   (1 2 3 4), (foo bar baz), (list 1 2 3)
    ●


● Vectors


   [1 2 3], [foo bar], (vector 1 2 3)
    ●


● Maps


   {:a 1 :b 2 :c 3}
    ●


● Sets


    ●   #{foo bar}
“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
clojure might be a better
      java than java
public class StringUtils {
   public static boolean isBlank(String str) {
      int strLen;
      if (str == null || (strLen = str.length()) == 0) {
          return true;
      }
      for (int i = 0; i < strLen; i++) {
          if ((Character.isWhitespace(str.charAt(i)) ==
false)) {
              return false;
          }
      }
      return true;
   }
}
public class StringUtils {
   public isBlank(str) {
      if (str == null || (strLen = str.length()) == 0) {
          return true;
      }
      for (i = 0; i < strLen; i++) {
          if ((Character.isWhitespace(str.charAt(i)) ==
false)) {
              return false;
          }
      }
      return true;
   }
}
public isBlank(str) {
  if (str == null || (strLen = str.length()) == 0) {
      return true;
  }
  for (i = 0; i < strLen; i++) {
      if ((Character.isWhitespace(str.charAt(i)) == false))
          return false;
      }
  }
  return true;
}
public isBlank(str) {
  if (str == null || (strLen = str.length()) == 0) {
      return true;
  }

    every (ch in str) {
       Character.isWhitespace(ch);
    }
    return true;
}
public isBlank(str) {
  every (ch in str) {
      Character.isWhitespace(ch);
  }
}
(defn blank? [s]
  (every? #(Character/isWhitespace %) s))
Clojure vs Java code
●   Side-effect free      ●   Error prone
●   Easy to (unit) test   ●   Not so easy
●   Lazy collection       ●   Only one element
●   Any element           ●   Only with chars
●   Slower                ●   Faster
●   Data manipulation     ●   If/for/while code
●   Exploratory           ●   Design Is Law
Clojure is a functional language
●   Functions are first-class objects
●   Data is immutable
●   Functions are pure
So what?
●   Simple: no loops, variables or mutable
    state
●   Thread-safe: no locking
●   Parallelizable: map/reduce anyone?
●   Generic: data is always data
●   Easy to test: same input, same output
user=> (println "hello world")
| hello world
-> nil
user=> (defn hello [name]
           (str "Hello, " name))
#'user/hello
(hello "Clojure")
(.toUpperCase “hello”)
(str “hello” “ “ “world”)
(+ 1 3 4 (* 5 6))
(defn greeting
"Returns a greeting of the form 'Hello, username.'"
[username]
(str "Hello, " username))
(greeting "world")
user=> (doc greeting)
              -------------------------
               exploring/greeting
                  ([username])
Returns a greeting of the form 'Hello, username.'
(defn is-small? [number]
   (if (< number 100)
          "yes" ))
(is-small? 50)
     "yes"
(is-small? 50000)
       nil
(defn is-small? [number]
   (if (< number 100)
           "yes"
           "no" ))
Solving problems
●   Experiment with the problem
●   Create your data structures
●   Data transformations
●   Write code that writes code for you
    (macros)
●   Create a mini language (a DSL)
Java in Clojure
●   Yeap
Clojure in Java
●   Yeap
Clojure in Clojure
●   Yeap, yeap
Java in Clojure


java           new Widget(“foo”)

clojure        (Widget. “foo”)




java           dialog.show()

clojure        (.show dialog)
Tools
●   Emacs + SLIME
●   ViMClojure
●   Enclojure + Intellij IDEA
●   Counterclockwise + Eclipse
●   Leiningen
Clojure is not a just a new language
Is another, simplier way to solve problems
Thanks! Questions?
   @jonromero

More Related Content

What's hot

Tour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processorTour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processorTatu Saloranta
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202Mahmoud Samir Fayed
 
Learning groovy -EU workshop
Learning groovy  -EU workshopLearning groovy  -EU workshop
Learning groovy -EU workshopadam1davis
 
Head First Java Chapter 1
Head First Java Chapter 1Head First Java Chapter 1
Head First Java Chapter 1Tom Henricksen
 
Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Joachim Baumann
 
Python internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvandPython internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvandirpycon
 
Simple Jackson with DropWizard
Simple Jackson with DropWizardSimple Jackson with DropWizard
Simple Jackson with DropWizardTatu Saloranta
 
Jackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVJackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVTatu Saloranta
 
Writing Groovy DSLs
Writing Groovy DSLsWriting Groovy DSLs
Writing Groovy DSLsadam1davis
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1Troy Miles
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobikrmboya
 
Structure and interpretation of computer programs modularity, objects, and ...
Structure and interpretation of computer programs   modularity, objects, and ...Structure and interpretation of computer programs   modularity, objects, and ...
Structure and interpretation of computer programs modularity, objects, and ...bdemchak
 
C# Starter L03-Utilities
C# Starter L03-UtilitiesC# Starter L03-Utilities
C# Starter L03-UtilitiesMohammad Shaker
 

What's hot (20)

Tour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processorTour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processor
 
The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202The Ring programming language version 1.8 book - Part 7 of 202
The Ring programming language version 1.8 book - Part 7 of 202
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
 
Learning groovy -EU workshop
Learning groovy  -EU workshopLearning groovy  -EU workshop
Learning groovy -EU workshop
 
Head First Java Chapter 1
Head First Java Chapter 1Head First Java Chapter 1
Head First Java Chapter 1
 
Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)Introduction to Groovy (Serbian Developer Conference 2013)
Introduction to Groovy (Serbian Developer Conference 2013)
 
Python internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvandPython internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvand
 
Fluent14
Fluent14Fluent14
Fluent14
 
Just Kotlin
Just KotlinJust Kotlin
Just Kotlin
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Simple Jackson with DropWizard
Simple Jackson with DropWizardSimple Jackson with DropWizard
Simple Jackson with DropWizard
 
Jackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVJackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSV
 
Writing Groovy DSLs
Writing Groovy DSLsWriting Groovy DSLs
Writing Groovy DSLs
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
 
Programming with Freedom & Joy
Programming with Freedom & JoyProgramming with Freedom & Joy
Programming with Freedom & Joy
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
 
Structure and interpretation of computer programs modularity, objects, and ...
Structure and interpretation of computer programs   modularity, objects, and ...Structure and interpretation of computer programs   modularity, objects, and ...
Structure and interpretation of computer programs modularity, objects, and ...
 
C# Starter L03-Utilities
C# Starter L03-UtilitiesC# Starter L03-Utilities
C# Starter L03-Utilities
 
Hackersnl
HackersnlHackersnl
Hackersnl
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 

Similar to Getting Started with Clojure

Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android DevelopmentSpeck&Tech
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)Andrés Viedma Peláez
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - StockholmJan Kronquist
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersMiles Sabin
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersSkills Matter
 
Ceylon - the language and its tools
Ceylon - the language and its toolsCeylon - the language and its tools
Ceylon - the language and its toolsMax Andersen
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersMiles Sabin
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with ClojureJohn Stevenson
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanJimin Hsieh
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Tudor Dragan
 

Similar to Getting Started with Clojure (20)

Clojure class
Clojure classClojure class
Clojure class
 
Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android Development
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java Developers
 
Ceylon - the language and its tools
Ceylon - the language and its toolsCeylon - the language and its tools
Ceylon - the language and its tools
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Music as data
Music as dataMusic as data
Music as data
 
Scala
ScalaScala
Scala
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Getting started with Clojure
Getting started with ClojureGetting started with Clojure
Getting started with Clojure
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
 
Clojure
ClojureClojure
Clojure
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
 

More from John Vlachoyiannis

Making gazillion with cryptocurrencies
Making gazillion with cryptocurrenciesMaking gazillion with cryptocurrencies
Making gazillion with cryptocurrenciesJohn Vlachoyiannis
 
The most epic advice to become an angel investor
The most epic advice to become an angel investorThe most epic advice to become an angel investor
The most epic advice to become an angel investorJohn Vlachoyiannis
 
Music as Data - Ignite 2011 SF
Music as Data - Ignite 2011 SFMusic as Data - Ignite 2011 SF
Music as Data - Ignite 2011 SFJohn Vlachoyiannis
 
This is Appengine! 300 reasons to love Google AppEngine
This is Appengine! 300 reasons to love Google AppEngineThis is Appengine! 300 reasons to love Google AppEngine
This is Appengine! 300 reasons to love Google AppEngineJohn Vlachoyiannis
 
Rain up presentation (erlang factory)
Rain up presentation (erlang factory)Rain up presentation (erlang factory)
Rain up presentation (erlang factory)John Vlachoyiannis
 

More from John Vlachoyiannis (6)

Making gazillion with cryptocurrencies
Making gazillion with cryptocurrenciesMaking gazillion with cryptocurrencies
Making gazillion with cryptocurrencies
 
The most epic advice to become an angel investor
The most epic advice to become an angel investorThe most epic advice to become an angel investor
The most epic advice to become an angel investor
 
Music as Data - Ignite 2011 SF
Music as Data - Ignite 2011 SFMusic as Data - Ignite 2011 SF
Music as Data - Ignite 2011 SF
 
This is Appengine! 300 reasons to love Google AppEngine
This is Appengine! 300 reasons to love Google AppEngineThis is Appengine! 300 reasons to love Google AppEngine
This is Appengine! 300 reasons to love Google AppEngine
 
Rain up presentation (erlang factory)
Rain up presentation (erlang factory)Rain up presentation (erlang factory)
Rain up presentation (erlang factory)
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 

Recently uploaded

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 

Recently uploaded (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 

Getting Started with Clojure

  • 1. Clojure John Vlachoyiannis @jonromero jon@emotionull.com Http://jon.is.emotionull.com
  • 3. Ok, what is Lisp?
  • 4. “Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot." Eric S. Raymond, "How to Become a Hacker".
  • 5. “LISP stands for: Lots of Insane Stupid Parentheses” Anonymous
  • 7. LISt Processing LIS ● Second oldest high-level language (first is Fortran) ● Code as Data (Homoiconic) ● Perfect for Domain-specific languages (DSL) ● Exploratory programming
  • 8. Clojure ● Lisp in JVM ● Concurrent programming ● Dynamic Development (REPL) ● Lazy sequences ● No side effects (almost)
  • 14. Integers – 1234567891234 ● Doubles – 3.14. BigDecimals – 3.14M ● Ratios – 22/4 ● Strings – '”foo”, Character – a b c ● Symbols – foo, Keywords :foo ● Booleans – true false, Null – nil ● Regex patterns – #”[a-zA-Z0-9]|
  • 15. Data structures ● Lists (1 2 3 4), (foo bar baz), (list 1 2 3) ● ● Vectors [1 2 3], [foo bar], (vector 1 2 3) ● ● Maps {:a 1 :b 2 :c 3} ● ● Sets ● #{foo bar}
  • 16. “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
  • 17. clojure might be a better java than java
  • 18. public class StringUtils { public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if ((Character.isWhitespace(str.charAt(i)) == false)) { return false; } } return true; } }
  • 19. public class StringUtils { public isBlank(str) { if (str == null || (strLen = str.length()) == 0) { return true; } for (i = 0; i < strLen; i++) { if ((Character.isWhitespace(str.charAt(i)) == false)) { return false; } } return true; } }
  • 20. public isBlank(str) { if (str == null || (strLen = str.length()) == 0) { return true; } for (i = 0; i < strLen; i++) { if ((Character.isWhitespace(str.charAt(i)) == false)) return false; } } return true; }
  • 21. public isBlank(str) { if (str == null || (strLen = str.length()) == 0) { return true; } every (ch in str) { Character.isWhitespace(ch); } return true; }
  • 22. public isBlank(str) { every (ch in str) { Character.isWhitespace(ch); } }
  • 23. (defn blank? [s] (every? #(Character/isWhitespace %) s))
  • 24. Clojure vs Java code ● Side-effect free ● Error prone ● Easy to (unit) test ● Not so easy ● Lazy collection ● Only one element ● Any element ● Only with chars ● Slower ● Faster ● Data manipulation ● If/for/while code ● Exploratory ● Design Is Law
  • 25. Clojure is a functional language ● Functions are first-class objects ● Data is immutable ● Functions are pure
  • 27. Simple: no loops, variables or mutable state ● Thread-safe: no locking ● Parallelizable: map/reduce anyone? ● Generic: data is always data ● Easy to test: same input, same output
  • 28. user=> (println "hello world") | hello world -> nil
  • 29. user=> (defn hello [name] (str "Hello, " name)) #'user/hello
  • 32. (str “hello” “ “ “world”)
  • 33. (+ 1 3 4 (* 5 6))
  • 34. (defn greeting "Returns a greeting of the form 'Hello, username.'" [username] (str "Hello, " username))
  • 36. user=> (doc greeting) ------------------------- exploring/greeting ([username]) Returns a greeting of the form 'Hello, username.'
  • 37. (defn is-small? [number] (if (< number 100) "yes" ))
  • 38. (is-small? 50) "yes"
  • 40. (defn is-small? [number] (if (< number 100) "yes" "no" ))
  • 41. Solving problems ● Experiment with the problem ● Create your data structures ● Data transformations ● Write code that writes code for you (macros) ● Create a mini language (a DSL)
  • 45. Java in Clojure java new Widget(“foo”) clojure (Widget. “foo”) java dialog.show() clojure (.show dialog)
  • 46. Tools ● Emacs + SLIME ● ViMClojure ● Enclojure + Intellij IDEA ● Counterclockwise + Eclipse ● Leiningen
  • 47. Clojure is not a just a new language
  • 48. Is another, simplier way to solve problems
  • 49. Thanks! Questions? @jonromero