Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Short Tour Of Clojure
Search
Tamizhvendan S
May 23, 2020
Programming
0
210
Short Tour Of Clojure
Tamizhvendan S
May 23, 2020
Tweet
Share
More Decks by Tamizhvendan S
See All by Tamizhvendan S
Let's Talk About Ability
tamizhvendan
0
200
Building an E-Commerce Marketplace Middleware in Clojure
tamizhvendan
0
630
Deep Dive Into Pattern Matching & Destructuring
tamizhvendan
0
380
Demystifying Functional Programming
tamizhvendan
0
350
Concurrent programming with F#
tamizhvendan
2
310
Let's Create MiniSuave
tamizhvendan
0
160
Getting Started in Functional Programming using F#
tamizhvendan
1
210
Hack_n_Learn_Fsharp_Ajira
tamizhvendan
0
280
Rethinking "State Management" - TW Geeknight
tamizhvendan
1
560
Other Decks in Programming
See All in Programming
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.7k
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
Jakarta EE meets AI
ivargrimstad
0
210
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
Better Code Design in PHP
afilina
PRO
0
130
Jakarta EE meets AI
ivargrimstad
0
660
Amazon Qを使ってIaCを触ろう!
maruto
0
410
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Macとオーディオ再生 2024/11/02
yusukeito
0
370
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
A designer walks into a library…
pauljervisheath
204
24k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Statistics for Hackers
jakevdp
796
220k
Documentation Writing (for coders)
carmenintech
65
4.4k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Designing for humans not robots
tammielis
250
25k
Typedesign – Prime Four
hannesfritz
40
2.4k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Transcript
Lead Consultant www.ajira.tech Tamizhvendan S Passionate, Pragmatic and Polyglot Programmer
https://www.demystifyfp.com tamizhvendan (short-tour (of (clojure)))
Credits: https://twitter.com/andreasdotorg/status/570190592610832384
None
None
Credits: https://github.com/tallesl/Rich-Hickey-fanclub Simple Made Easy Hammock Driven Development The Value
of Values Effective Programs
Credits: https://www.artsy.net/artwork/brian-kernighan-hello-world
Hello World in three languages printf("Hello, World!\n"); C System.out.println("Hello, World");
Java println("Hello, World") Scala
Hello World Requirements 1. A String Representation 2. Function/Method
function (argument) Function/Method Invocation
function (argument) Clojure’s way! (function argument)
Hello World in Clojure (println "Hello, World!")
(println "Hello, World!") function argument whitespace Clojure Syntax
Functions with multiple arguments printf("hello, %s\n", "World!"); C System.out.printf("Hello, %s\n",
"World!"); Java printf("Hello, %s\n", "World!") Scala
function (argument1, argument2) Function/Method Invocation
(function argument1, argument2) Clojure’s way! function (argument1, argument2)
(function argument1, argument2) (function argument1 argument2) optional Clojure’s way!
(function argument1 argument2 argument3 …) Clojure’s way!
Consistent Syntax 1. Adding the numbers one, two, three &
four 2. Converting an integer to a string 3. Concatenating two strings 4. Conditional Operator
Adding the numbers one, two, three & four 1 +
2 + 3 + 4 Converting an integer to a string String.valueOf(1) Concatenating two strings "Hello, ".concat("World!")
1 + 2 + 3 + 4 function function function
argument1 argument2 argument3 argument4 Infix Notation
method String.valueOf(1) ClassName argument invoke function Prefix Notation
method "Hello, ".concat("World!") Object argument invoke function Prefix Notation
argument2 true ? "truthy" : "falsy" argument1 separator function argument3
Conditional Operator
function argument2 argument4 argument1 argument3 (+ 1 2 3 4)
Clojure Syntax 1 + 2 + 3 + 4
(String/valueOf 1) function argument1 class name static method argument(s) to
the static method Clojure Syntax String.valueOf(1)
(. "Hello, " concat "World!") function argument1 argument2 argument3 instance
instance method argument(s) to the instance method special form Clojure Syntax "Hello, ".concat("World!")
(if true "truthy" "falsy") function argument1 argument2 argument3 boolean value
value1 value2 special form Clojure Syntax true ? "truthy" : "falsy"
Clojure Syntax
Clojure Form A structure that the Clojure compiler recognise.
Types of Clojure Forms Atomic Data Type - Literals "Hello,
World" 1 1.2 true nil \a :keyword symbol false
Types of Clojure Forms Collection - Literals [1 "2" 3]
'(1 1.2 1.5) {:one 1 :two 2 :three 3} #{1 2 3}
Types of Clojure Forms Expressions (function invocation) (println "Hello, World!")
(println "Hello," "World!") (+ 1 2 3 4) (String/valueOf 1) (. "Hello, " concat "World!")
Literals evaluate to itself user!=> "Hello, World" "Hello, World" user!=>
1 1
Expression always return a value user!=> (println "Hello, Clojure!") Hello,
Clojure! nil output of println function return value of println function
Forms can be nested (println "1 + 1 =" (+
1 1))
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) left to right
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) An expression begins with “(“
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) function symbol println is a variadic function defined in the clojure.core namespace.
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) argument1 string literal literals evaluate to itself
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) An expression begins with “(“ argument2
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) function symbol + is a variadic function defined in the clojure.core namespace.
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) argument1 integer literal literals evaluate to itself
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) argument2 integer literal literals evaluate to itself
Clojure Evaluation Model (println "1 + 1 =" (+ 1
1)) An expression ends with “)“
Clojure Evaluation Model (println "1 + 1 =" 2) All
expressions return a value
Clojure Evaluation Model (println "1 + 1 =" 2) An
expression ends with “)“
Clojure Evaluation Model (println "1 + 1 =" 2) user!=>
(println "1 + 1 =" (+ 1 1)) 1 + 1 = 2 nil output of println function return value of println function
Clojure Evaluation Model Deviations Special Forms if . def let
quote var fn loop recur Macros when condp -> ->> Macros are programs that write programs! try do
Summary f(x) translates to (f x) f(x, y) translates to
(f x y) o.m(x) translates to (. o m x) 1 + 2 + 3 + 4 translates to (+ 1 2 3 4) Prefix Notation
Demo!
Let’s start!