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

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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging 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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
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
 
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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
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
 
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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 

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