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
190
Building an E-Commerce Marketplace Middleware in Clojure
tamizhvendan
0
620
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
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
1
310
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
390
現場で役立つモデリング 超入門
masuda220
PRO
13
2.9k
僕がつくった48個のWebサービス達
yusukebe
18
17k
Macとオーディオ再生 2024/11/02
yusukeito
0
210
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
590
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
3.1k
CSC509 Lecture 09
javiergs
PRO
0
110
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
200
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
350
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
240
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
19
1.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
370
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
Writing Fast Ruby
sferik
626
61k
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
Happy Clients
brianwarren
97
6.7k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
Agile that works and the tools we love
rasmusluckow
327
21k
Speed Design
sergeychernyshev
24
570
How STYLIGHT went responsive
nonsquared
95
5.2k
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!