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
220
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
290
Rethinking "State Management" - TW Geeknight
tamizhvendan
1
570
Other Decks in Programming
See All in Programming
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
ドメインイベント増えすぎ問題
h0r15h0
2
310
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
220
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
330
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
Refactor your code - refactor yourself
xosofox
1
260
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
2
240
php-conference-japan-2024
tasuku43
0
280
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
Being A Developer After 40
akosma
87
590k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Why Our Code Smells
bkeepers
PRO
335
57k
Agile that works and the tools we love
rasmusluckow
328
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Mobile First: as difficult as doing things right
swwweet
222
9k
Fireside Chat
paigeccino
34
3.1k
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!