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 Clojure Small Intro

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 Clojure Small Intro (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

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 

Recently uploaded (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

Clojure Small Intro

  • 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