SlideShare a Scribd company logo
One of the Most Popular Course on Clojure -
Clojure Fundamentals For Beginners
Write shorter codes that do so much more with
Clojure. Clojure is the perfect blend of a
general-purpose programming language and a
functional programming language. Created by
Rich Hickey, the programming language
combines the interactive development of a
scripting language with that of a robust
infrastructure for multi-threading programming.
This course covers the fundamentals of Clojure
as well as teach you how to start coding using
the language. The following slides will let you
know, all that the course encompasses.
Clojure and Java
Clojure runs on the JVM.
Java is an incredibly verbose language that has only limited support for functions
via lambda’s
Clojure is an incredibly terse language
By incorporating Clojure into Java code we can greatly reduce the verbosity and allow important
functional tools like recursion
By incorporating Java into Clojure code allows use of Java’s extensive native functionality and
its enormous ecosystem
The ability to use Java classes, objects, and methods is called Java interop
http://clojure.org/reference/java_interop
Clojure and JavaScript
Developers don't just write assembly to write a desktop applications it is just not feasable.
JavaScript is ubiquitous.
Developers use compilers to take a high level language to assembly
Is Javascript like the assembly language of the web.
Javascript is a high-level, dynamic language
Writing high-performance JavaScript is a challenge
Javascript does not really have shared memory model, it has webworkers
can only pass very limited set of data, strings or JSON objects
By using Compilers we can take JavaScript to output JavaScript as properly formed and
otherwise cross-browser compatible code
Clojure Application Packaging
Software Engineering Build Tools
compiling computer source code into binary code
packaging binary code
running tests
deployment to production systems
creating documentation and/or release notes
Uber Jar
Package your Clojure project into one self-contained file. (a Java “uber” jar file.)
The JVM has a classloader, which takes the compiled bytecode and loads it into the running
JVM. If the byte code for your dependencies is not available at runtime then your application
fails with a “class not found exception”.
“Uber jar” is a jar file of all Clojure source code compiled to bytecode and all the projects
dependencies.
Clojure Functions
Function defn
( defn square [x] ( * x x))
https://clojuredocs.org/clojure.core/range
( range 10)
Higher order function ‘map‘
(map square ( range 10) )
Core functions data flow for expressions
Core function = str
(def myMap {:firstKey "firstValue", :secKey "secValue"})
(str "first key value: " (:firstKey myMap ) " second key value: " (:secKey myMap ))
Higher order function ‘apply ‘
(apply str [ "one" "two" "three" ]) is the same as : (str "one" "two" "three")
(str [ "one" "two" "three" ])
Clojure Macros
Macros use the source code as data (input) like functions use data
"thread-first" macro
(-> "first" (str " last"))
(str "first" " last")
"thread-last" macro
(->> " last" (str " first"))
Thread macro takes an expression to a form f(source code) -> source code
‘->’ : “term” ===> Form
‘-->’ : “term” ===> Form
inserts the first term as the first /last item in second form
inserts the first form as the first /last item in second form
Clojure Memory Model
Clojure is a dialect of Lisp that runs on the JVM.
(Common Language Runtime (like JVM) and Javascript engines)
Objectives
What is a memory model why is it needed
JMM what is it how does it work
STM what is it how does it work
Clojure Process core-async
Summary Clojure Concurrency
Vars
Immutable by default
Mutable call dynamic (def ^:dynamic *my-str-type*
"mutable variable")
As a mutable variable have thread local scope
(visibility)
Atoms
Are visible (synchronised)
(def my-atom (atom 10)) de-reference @my-atom
(reset! my-atom 12) functional (swap! my-atom
update )
Use swap! in STM block
STM
Refs
Agents
Refs
ACID Transcational Atoms
Update with alter in synchronised block
(dosync (translate-point ))
Agents
Refs that update asynchronously (def
my-agent (agent 10))
No strict consistency for reads
(send my-agent update-my-agent)
Clojure Web Applications
Ring is a Clojure web applications library inspired by Python's WSGI and Ruby's Rack
Compojure is a rest api for rapid development of web applications in Clojure
https://github.com/weavejester/compojure
In compojure, each route is an HTTP method paired with a URL-matching pattern
Compojure route definitions are just functions configured for Ring (accept request
maps and return response maps)
1. Use a template lein new compojure eddy_comp
2. run the Ring web server lein ring server
3. defroutes site-defaults src/eddy_compjure/handler.clj
4. :keys :plugins :ring project.clj
5. Access the context root localhost:3000
6. JSON https://github.com/dakrone/cheshire
7. ClojureScript configuration
8. ClojureScript rest client
Functional Composition
Arity
arity 2
(def make-a-set
(fn ([x] #{x})
([x y] #{x y})))
(make-a-set 1)
(make-a-set 1 2)
Variadic functions
(defn var-args [x & rest] (apply str
(butlast rest) ) )
(var-args 0 1 2 3 4)
Currying
Currying is a way to generate a new function with an
argument partially applied
partial is a way of currying
partial
https://clojuredocs.org/clojure.core/partial
(def make-a-set (fn ([x y] #{x y})))
( (partial make-a-set 2) 3 )
What if we want to create a function not just a form
(def make-a-set-5 (partial make-a-set 5))
(make-a-set-5 10)
Clojure Concurrent tools: Atoms, Refs, Vars
Objectives
1. What is a memory model why is it needed
2. JMM what is it how does it work
3. STM what is it how does it work
Result
1. memory model is a set of rules implemented in hardware and software that controls
the way variables are updated during program execution by multiple threads of
execution
2. Java memory model (JMM) is a set of low level concurrency artifacts (locks, atomic
variables and synchronisation(visibility) ) combined with high level frameworks
(Executor Service, Futures, ForkJoin, …...) to implement a memory model.
3. Software Transactional Memory (STM) an ACID transactional system for how a
variable that is shared between threads updates, STM is implemented with the low
Functional recipe: Pure functions with Immutable Data Structures
Pure Functions
Side effects = changes that functions make in addition to their return value
Pure functions do not depend on external data sources and do not provoke side effects of any kind.
When invoked with a set of arguments, will always respond with
the same return value
Higher-Order Functions
● Takes one or more functions as arguments
● Returns a function as a result
Clojure has families of higher order functions <==> Clojure Abstractions
Eg sequence functions map reduce filter
sequence <==> Data Structure Abstraction {sequence}
Gradle Environment
1 install gradle
.bashrc
export GRADLE_HOME=/home/ubu/gradle
export PATH=$PATH:$GRADLE_HOME/bin
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
.bashrc
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export GRADLE_HOME=/home/ubu/gradle
export PATH=$PATH:$GRADLE_HOME/bin
source .bashrc
Leiningen Environment
Software Engineering Build Tools
Compiling computer source code into binary code
Packaging binary code
Running tests
Deployment to production systems
Creating documentation and/or release notes
Objectives
1. Install leningen
2. Understand Leiningen project layout
3. Understand Leiningen build script (dependencies ect ..)
4. Run the clojure repl
Functional Recursive Data Flow
Recursion is one of the fundamental techniques
used in functional programming.
Review
Function literal
((fn [x y] #{x y}) 1 2)
Function arity 2
(def make-a-set
(fn ([x] #{x})
([x y] #{x y})))
(make-a-set 1)
(make-a-set 1 2)
def special form is a way to assign a symbolic name to a piece of Clojure data
www.eduonix.com
https://www.eduonix.com/courses/Software-Development/clojure-fundamentals-for-beginners

More Related Content

What's hot

iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS Multithreading
Richa Jain
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in Practice
Alina Dolgikh
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
Khaled AlGhazaly
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test tools
Allan Huang
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
yohanbeschi
 
Java Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and TrendsJava Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and Trends
Carol McDonald
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and Simple
Ben Mabey
 
Basics of Java Concurrency
Basics of Java ConcurrencyBasics of Java Concurrency
Basics of Java Concurrency
kshanth2101
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and Concurrency
Anton Keks
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
maksym220889
 
Threading in iOS / Cocoa Touch
Threading in iOS / Cocoa TouchThreading in iOS / Cocoa Touch
Threading in iOS / Cocoa Touch
mobiledeveloperpl
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
yoavwix
 
Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors Framework
Arun Mehra
 
JVM
JVMJVM
The Java memory model made easy
The Java memory model made easyThe Java memory model made easy
The Java memory model made easy
Rafael Winterhalter
 
Loom and concurrency latest
Loom and concurrency latestLoom and concurrency latest
Loom and concurrency latest
Srinivasan Raghavan
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
Danairat Thanabodithammachari
 
Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design Patterns
Robert Brown
 
Multithreading in Java
Multithreading in JavaMultithreading in Java
Multithreading in Java
Appsterdam Milan
 

What's hot (20)

iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS Multithreading
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in Practice
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test tools
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 
Java Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and TrendsJava Concurrency, Memory Model, and Trends
Java Concurrency, Memory Model, and Trends
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and Simple
 
Basics of Java Concurrency
Basics of Java ConcurrencyBasics of Java Concurrency
Basics of Java Concurrency
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and Concurrency
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 
Threading in iOS / Cocoa Touch
Threading in iOS / Cocoa TouchThreading in iOS / Cocoa Touch
Threading in iOS / Cocoa Touch
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
 
Java Multithreading Using Executors Framework
Java Multithreading Using Executors FrameworkJava Multithreading Using Executors Framework
Java Multithreading Using Executors Framework
 
JVM
JVMJVM
JVM
 
The Java memory model made easy
The Java memory model made easyThe Java memory model made easy
The Java memory model made easy
 
Loom and concurrency latest
Loom and concurrency latestLoom and concurrency latest
Loom and concurrency latest
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
 
Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design Patterns
 
Multithreading in Java
Multithreading in JavaMultithreading in Java
Multithreading in Java
 

Viewers also liked

autocad_lt_2005_biblia_minta
autocad_lt_2005_biblia_mintaautocad_lt_2005_biblia_minta
autocad_lt_2005_biblia_mintaKrist P
 
Critical Thinking like a breeze
Critical Thinking like a breezeCritical Thinking like a breeze
Critical Thinking like a breeze
Ahmed Reda Kraiz
 
Cbse school in abu dhabi
Cbse school in abu dhabiCbse school in abu dhabi
Cbse school in abu dhabi
GIIS AbuDhabi
 
Owuor African
Owuor AfricanOwuor African
Owuor African
Charles Owuor
 
“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...
“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...
“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...
iosrjce
 
Freddah M
Freddah MFreddah M
eTrøndelag
eTrøndelageTrøndelag
eTrøndelag
SKILLS+ project
 
MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data
MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data
MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data
Access Innovations, Inc.
 
Torq bak overview presentation from infographic
Torq bak overview presentation from infographicTorq bak overview presentation from infographic
Torq bak overview presentation from infographicNick Sharples
 
Group Communication
Group CommunicationGroup Communication
Group Communication
Sara Spahić
 
Famine in somalia
Famine in somaliaFamine in somalia
Famine in somalia
Hectorgutierrez2016
 
TVSCA 2008
TVSCA 2008TVSCA 2008
TVSCA 2008
Paul Tate
 
Is Accounting just for Compliance?
Is Accounting just for Compliance?Is Accounting just for Compliance?
Is Accounting just for Compliance?
Joyce Lim
 
KR Workshop 1 - Ontologies
KR Workshop 1 - OntologiesKR Workshop 1 - Ontologies
KR Workshop 1 - Ontologies
Michele Pasin
 
ICT Sector Assessment, Free Trade Agreement Signature, IESC, USAID
ICT Sector Assessment, Free Trade Agreement Signature, IESC, USAIDICT Sector Assessment, Free Trade Agreement Signature, IESC, USAID
ICT Sector Assessment, Free Trade Agreement Signature, IESC, USAID
Mehdi Sif
 
The basics of purchasing
The basics of purchasingThe basics of purchasing
The basics of purchasing
Fiezha 1401
 
XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D...
 XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D... XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D...
XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D...
The Linux Foundation
 
Building 3D Morphable Models from 2D Images
Building 3D Morphable Models from 2D ImagesBuilding 3D Morphable Models from 2D Images
Building 3D Morphable Models from 2D Images
Shanglin Yang
 

Viewers also liked (18)

autocad_lt_2005_biblia_minta
autocad_lt_2005_biblia_mintaautocad_lt_2005_biblia_minta
autocad_lt_2005_biblia_minta
 
Critical Thinking like a breeze
Critical Thinking like a breezeCritical Thinking like a breeze
Critical Thinking like a breeze
 
Cbse school in abu dhabi
Cbse school in abu dhabiCbse school in abu dhabi
Cbse school in abu dhabi
 
Owuor African
Owuor AfricanOwuor African
Owuor African
 
“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...
“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...
“An Assessment of Voltage Stability based on Line Voltage Stability Indices a...
 
Freddah M
Freddah MFreddah M
Freddah M
 
eTrøndelag
eTrøndelageTrøndelag
eTrøndelag
 
MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data
MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data
MAIChem - The Indexing Solution for Chemical and Pharmaceutical Data
 
Torq bak overview presentation from infographic
Torq bak overview presentation from infographicTorq bak overview presentation from infographic
Torq bak overview presentation from infographic
 
Group Communication
Group CommunicationGroup Communication
Group Communication
 
Famine in somalia
Famine in somaliaFamine in somalia
Famine in somalia
 
TVSCA 2008
TVSCA 2008TVSCA 2008
TVSCA 2008
 
Is Accounting just for Compliance?
Is Accounting just for Compliance?Is Accounting just for Compliance?
Is Accounting just for Compliance?
 
KR Workshop 1 - Ontologies
KR Workshop 1 - OntologiesKR Workshop 1 - Ontologies
KR Workshop 1 - Ontologies
 
ICT Sector Assessment, Free Trade Agreement Signature, IESC, USAID
ICT Sector Assessment, Free Trade Agreement Signature, IESC, USAIDICT Sector Assessment, Free Trade Agreement Signature, IESC, USAID
ICT Sector Assessment, Free Trade Agreement Signature, IESC, USAID
 
The basics of purchasing
The basics of purchasingThe basics of purchasing
The basics of purchasing
 
XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D...
 XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D... XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D...
XPDS16: Patch review for non-maintainers - George Dunlap, Citrix Systems R&D...
 
Building 3D Morphable Models from 2D Images
Building 3D Morphable Models from 2D ImagesBuilding 3D Morphable Models from 2D Images
Building 3D Morphable Models from 2D Images
 

Similar to Clojure Fundamentals Course For Beginners

ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
JAX London
 
Effective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjectsEffective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjects
Srikanth Shenoy
 
Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)
Md. Mujahid Islam
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
Nicola Pedot
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
elliando dias
 
Java1
Java1Java1
Java
Java Java
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_en
George Birbilis
 
React native
React nativeReact native
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
John Stevenson
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
Kumaraswamy M
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
Jonathan Fine
 
Signal Framework
Signal FrameworkSignal Framework
Signal Framework
Aurora Softworks
 
G pars
G parsG pars
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
John Stevenson
 
Java solution
Java solutionJava solution
Java solution
1Arun_Pandey
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
chrisriceuk
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
FAKHRUN NISHA
 

Similar to Clojure Fundamentals Course For Beginners (20)

ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Effective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjectsEffective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjects
 
Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)Object Oriented Methodology in Java (Lecture-1)
Object Oriented Methodology in Java (Lecture-1)
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
It pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_enIt pro dev_birbilis_20101127_en
It pro dev_birbilis_20101127_en
 
React native
React nativeReact native
React native
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Signal Framework
Signal FrameworkSignal Framework
Signal Framework
 
G pars
G parsG pars
G pars
 
Clojure for Java developers
Clojure for Java developersClojure for Java developers
Clojure for Java developers
 
Java solution
Java solutionJava solution
Java solution
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 

More from Paddy Lock

An Inforgraphic to Learn React Native
An Inforgraphic to Learn React NativeAn Inforgraphic to Learn React Native
An Inforgraphic to Learn React Native
Paddy Lock
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
Paddy Lock
 
Docker for Professionals: The Practical Guide
Docker for Professionals: The Practical GuideDocker for Professionals: The Practical Guide
Docker for Professionals: The Practical Guide
Paddy Lock
 
Getting started with React and Redux
Getting started with React and ReduxGetting started with React and Redux
Getting started with React and Redux
Paddy Lock
 
Beginners Guide to Modeling with Maya
Beginners Guide to Modeling with MayaBeginners Guide to Modeling with Maya
Beginners Guide to Modeling with Maya
Paddy Lock
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Paddy Lock
 
PPT on Angular 2 Development Tutorial
PPT on Angular 2 Development TutorialPPT on Angular 2 Development Tutorial
PPT on Angular 2 Development Tutorial
Paddy Lock
 
PPT on Photoshop
PPT on PhotoshopPPT on Photoshop
PPT on Photoshop
Paddy Lock
 
Advance Javascript for Coders
Advance Javascript for CodersAdvance Javascript for Coders
Advance Javascript for Coders
Paddy Lock
 
A Complete Guide For Effective Business Communication – A Course from Eduonix
A Complete Guide For Effective  Business Communication – A Course from EduonixA Complete Guide For Effective  Business Communication – A Course from Eduonix
A Complete Guide For Effective Business Communication – A Course from Eduonix
Paddy Lock
 
Linux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixLinux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on Eduonix
Paddy Lock
 
Infographic on Scala Programming Language
Infographic on Scala Programming LanguageInfographic on Scala Programming Language
Infographic on Scala Programming Language
Paddy Lock
 
Presentation on Eduonix
 Presentation on Eduonix Presentation on Eduonix
Presentation on Eduonix
Paddy Lock
 

More from Paddy Lock (13)

An Inforgraphic to Learn React Native
An Inforgraphic to Learn React NativeAn Inforgraphic to Learn React Native
An Inforgraphic to Learn React Native
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
 
Docker for Professionals: The Practical Guide
Docker for Professionals: The Practical GuideDocker for Professionals: The Practical Guide
Docker for Professionals: The Practical Guide
 
Getting started with React and Redux
Getting started with React and ReduxGetting started with React and Redux
Getting started with React and Redux
 
Beginners Guide to Modeling with Maya
Beginners Guide to Modeling with MayaBeginners Guide to Modeling with Maya
Beginners Guide to Modeling with Maya
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
PPT on Angular 2 Development Tutorial
PPT on Angular 2 Development TutorialPPT on Angular 2 Development Tutorial
PPT on Angular 2 Development Tutorial
 
PPT on Photoshop
PPT on PhotoshopPPT on Photoshop
PPT on Photoshop
 
Advance Javascript for Coders
Advance Javascript for CodersAdvance Javascript for Coders
Advance Javascript for Coders
 
A Complete Guide For Effective Business Communication – A Course from Eduonix
A Complete Guide For Effective  Business Communication – A Course from EduonixA Complete Guide For Effective  Business Communication – A Course from Eduonix
A Complete Guide For Effective Business Communication – A Course from Eduonix
 
Linux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixLinux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on Eduonix
 
Infographic on Scala Programming Language
Infographic on Scala Programming LanguageInfographic on Scala Programming Language
Infographic on Scala Programming Language
 
Presentation on Eduonix
 Presentation on Eduonix Presentation on Eduonix
Presentation on Eduonix
 

Recently uploaded

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 

Recently uploaded (20)

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 

Clojure Fundamentals Course For Beginners

  • 1. One of the Most Popular Course on Clojure - Clojure Fundamentals For Beginners Write shorter codes that do so much more with Clojure. Clojure is the perfect blend of a general-purpose programming language and a functional programming language. Created by Rich Hickey, the programming language combines the interactive development of a scripting language with that of a robust infrastructure for multi-threading programming. This course covers the fundamentals of Clojure as well as teach you how to start coding using the language. The following slides will let you know, all that the course encompasses.
  • 2. Clojure and Java Clojure runs on the JVM. Java is an incredibly verbose language that has only limited support for functions via lambda’s Clojure is an incredibly terse language By incorporating Clojure into Java code we can greatly reduce the verbosity and allow important functional tools like recursion By incorporating Java into Clojure code allows use of Java’s extensive native functionality and its enormous ecosystem The ability to use Java classes, objects, and methods is called Java interop http://clojure.org/reference/java_interop
  • 3. Clojure and JavaScript Developers don't just write assembly to write a desktop applications it is just not feasable. JavaScript is ubiquitous. Developers use compilers to take a high level language to assembly Is Javascript like the assembly language of the web. Javascript is a high-level, dynamic language Writing high-performance JavaScript is a challenge Javascript does not really have shared memory model, it has webworkers can only pass very limited set of data, strings or JSON objects By using Compilers we can take JavaScript to output JavaScript as properly formed and otherwise cross-browser compatible code
  • 4. Clojure Application Packaging Software Engineering Build Tools compiling computer source code into binary code packaging binary code running tests deployment to production systems creating documentation and/or release notes Uber Jar Package your Clojure project into one self-contained file. (a Java “uber” jar file.) The JVM has a classloader, which takes the compiled bytecode and loads it into the running JVM. If the byte code for your dependencies is not available at runtime then your application fails with a “class not found exception”. “Uber jar” is a jar file of all Clojure source code compiled to bytecode and all the projects dependencies.
  • 5. Clojure Functions Function defn ( defn square [x] ( * x x)) https://clojuredocs.org/clojure.core/range ( range 10) Higher order function ‘map‘ (map square ( range 10) ) Core functions data flow for expressions Core function = str (def myMap {:firstKey "firstValue", :secKey "secValue"}) (str "first key value: " (:firstKey myMap ) " second key value: " (:secKey myMap )) Higher order function ‘apply ‘ (apply str [ "one" "two" "three" ]) is the same as : (str "one" "two" "three") (str [ "one" "two" "three" ])
  • 6. Clojure Macros Macros use the source code as data (input) like functions use data "thread-first" macro (-> "first" (str " last")) (str "first" " last") "thread-last" macro (->> " last" (str " first")) Thread macro takes an expression to a form f(source code) -> source code ‘->’ : “term” ===> Form ‘-->’ : “term” ===> Form inserts the first term as the first /last item in second form inserts the first form as the first /last item in second form
  • 7. Clojure Memory Model Clojure is a dialect of Lisp that runs on the JVM. (Common Language Runtime (like JVM) and Javascript engines) Objectives What is a memory model why is it needed JMM what is it how does it work STM what is it how does it work
  • 8. Clojure Process core-async Summary Clojure Concurrency Vars Immutable by default Mutable call dynamic (def ^:dynamic *my-str-type* "mutable variable") As a mutable variable have thread local scope (visibility) Atoms Are visible (synchronised) (def my-atom (atom 10)) de-reference @my-atom (reset! my-atom 12) functional (swap! my-atom update ) Use swap! in STM block STM Refs Agents Refs ACID Transcational Atoms Update with alter in synchronised block (dosync (translate-point )) Agents Refs that update asynchronously (def my-agent (agent 10)) No strict consistency for reads (send my-agent update-my-agent)
  • 9. Clojure Web Applications Ring is a Clojure web applications library inspired by Python's WSGI and Ruby's Rack Compojure is a rest api for rapid development of web applications in Clojure https://github.com/weavejester/compojure In compojure, each route is an HTTP method paired with a URL-matching pattern Compojure route definitions are just functions configured for Ring (accept request maps and return response maps) 1. Use a template lein new compojure eddy_comp 2. run the Ring web server lein ring server 3. defroutes site-defaults src/eddy_compjure/handler.clj 4. :keys :plugins :ring project.clj 5. Access the context root localhost:3000 6. JSON https://github.com/dakrone/cheshire 7. ClojureScript configuration 8. ClojureScript rest client
  • 10. Functional Composition Arity arity 2 (def make-a-set (fn ([x] #{x}) ([x y] #{x y}))) (make-a-set 1) (make-a-set 1 2) Variadic functions (defn var-args [x & rest] (apply str (butlast rest) ) ) (var-args 0 1 2 3 4) Currying Currying is a way to generate a new function with an argument partially applied partial is a way of currying partial https://clojuredocs.org/clojure.core/partial (def make-a-set (fn ([x y] #{x y}))) ( (partial make-a-set 2) 3 ) What if we want to create a function not just a form (def make-a-set-5 (partial make-a-set 5)) (make-a-set-5 10)
  • 11. Clojure Concurrent tools: Atoms, Refs, Vars Objectives 1. What is a memory model why is it needed 2. JMM what is it how does it work 3. STM what is it how does it work Result 1. memory model is a set of rules implemented in hardware and software that controls the way variables are updated during program execution by multiple threads of execution 2. Java memory model (JMM) is a set of low level concurrency artifacts (locks, atomic variables and synchronisation(visibility) ) combined with high level frameworks (Executor Service, Futures, ForkJoin, …...) to implement a memory model. 3. Software Transactional Memory (STM) an ACID transactional system for how a variable that is shared between threads updates, STM is implemented with the low
  • 12. Functional recipe: Pure functions with Immutable Data Structures Pure Functions Side effects = changes that functions make in addition to their return value Pure functions do not depend on external data sources and do not provoke side effects of any kind. When invoked with a set of arguments, will always respond with the same return value Higher-Order Functions ● Takes one or more functions as arguments ● Returns a function as a result Clojure has families of higher order functions <==> Clojure Abstractions Eg sequence functions map reduce filter sequence <==> Data Structure Abstraction {sequence}
  • 13. Gradle Environment 1 install gradle .bashrc export GRADLE_HOME=/home/ubu/gradle export PATH=$PATH:$GRADLE_HOME/bin export JAVA_HOME=/usr/lib/jvm/java-8-oracle .bashrc export JAVA_HOME=/usr/lib/jvm/java-8-oracle export GRADLE_HOME=/home/ubu/gradle export PATH=$PATH:$GRADLE_HOME/bin source .bashrc
  • 14. Leiningen Environment Software Engineering Build Tools Compiling computer source code into binary code Packaging binary code Running tests Deployment to production systems Creating documentation and/or release notes Objectives 1. Install leningen 2. Understand Leiningen project layout 3. Understand Leiningen build script (dependencies ect ..) 4. Run the clojure repl
  • 15. Functional Recursive Data Flow Recursion is one of the fundamental techniques used in functional programming. Review Function literal ((fn [x y] #{x y}) 1 2) Function arity 2 (def make-a-set (fn ([x] #{x}) ([x y] #{x y}))) (make-a-set 1) (make-a-set 1 2) def special form is a way to assign a symbolic name to a piece of Clojure data