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
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
CSC509 Lecture 09
javiergs
PRO
0
140
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
900
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.3k
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
230
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
flutterkaigi_2024.pdf
kyoheig3
0
150
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
受け取る人から提供する人になるということ
little_rubyist
0
250
Featured
See All Featured
Become a Pro
speakerdeck
PRO
25
5k
The Invisible Side of Design
smashingmag
298
50k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Ruby is Unlike a Banana
tanoku
97
11k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Rails Girls Zürich Keynote
gr2m
94
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
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!