Slide 1

Slide 1 text

CLOJURE Intro to @raphamundi

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Raphael Amorim This is me :P

Slide 4

Slide 4 text

WHAT’S CLOJURE ?

Slide 5

Slide 5 text

WHAT’S CLOJURE? Clojure is a dynamic programming language that targets the Java Virtual Machine (and the CLR, and JavaScript).

Slide 6

Slide 6 text

WHO’S USING CLOJURE? Akamai, Appvise, Citigroup, Amazon, eBay, Heroku, Groupon, Netflix, Nubank, Salesforce, Walmart Labs, Zendesk […] http://clojure.org/Companies

Slide 7

Slide 7 text

TAKING NOTES.

Slide 8

Slide 8 text

- Started in 2007 - Created by Rich Hickey - Under Eclipse Public License TAKING NOTES.

Slide 9

Slide 9 text

“ Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language ” TAKING NOTES.

Slide 10

Slide 10 text

FUNCIONAL PARADIGM?

Slide 11

Slide 11 text

Back to the Past.

Slide 12

Slide 12 text

λ - 1930 The Lambda Calculus Appears Back to the Past.

Slide 13

Slide 13 text

Lisp - 1958 Introduced a programming language able to deal with mathematical notation Back to the Past.

Slide 14

Slide 14 text

Lisp - 1958 Introduced a programming language able to deal with mathematical notation * IPL (Information Processing Language) is sometimes cited as the first computer-based functional programming language. First appeared in 1956. Back to the Past.

Slide 15

Slide 15 text

“Can Programming Be Liberated from the von Neumann Style?” - 1978 John Backus (FORTRAN creator) criticizes hardware architecture based on von Neuman model. Back to the Past.

Slide 16

Slide 16 text

The Boom- 1980 Innovative techniques have been proposed, such as: Lazy Evaluation Emergence of other languages such as: Lazy ML, Orwell, Alfl, Id, Clean, Ponder e Daisy Back to the Past.

Slide 17

Slide 17 text

Definitions

Slide 18

Slide 18 text

Treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.

Slide 19

Slide 19 text

So…

Slide 20

Slide 20 text

Take values and return values.

Slide 21

Slide 21 text

Same argument, same result.

Slide 22

Slide 22 text

Testing is easier, because there’s no state.

Slide 23

Slide 23 text

NO SIDE EFFECTS.

Slide 24

Slide 24 text

NO SIDE EFFECTS. Almost (e.g: I/O)

Slide 25

Slide 25 text

Syntax?

Slide 26

Slide 26 text

- Numbers ( 1, 3, 5, 85 ) - Character ( \h, \r, \a ) - String ( “barbante” ) - Boolean ( true, false ) - Symbol ( ‘a, ‘b, ‘c )

Slide 27

Slide 27 text

- Keywords ( :bad, :cool, :ugly ) - null ( nil )

Slide 28

Slide 28 text

Collections (all of them are immutable) - Lists ( '(1 2 3 4) ) - sequential and counted, not associative - first and rest - Vector ( [ 1 2 101 85 ] ) - sequential, counted and associative - access by key

Slide 29

Slide 29 text

Collections (all of them are immutable) - Maps ( { “raphael” 20, “richard" 25, “chuck” 99 } ) - counted and associative, not sequential - access by key - Sets ( #{“hugo” “raphael” “vianna”} ) - counted, not sequential, not associative - lookup for containment

Slide 30

Slide 30 text

Clojure REPL

Slide 31

Slide 31 text

There’s NO interpreter

Slide 32

Slide 32 text

"Laziness is a virtue"

Slide 33

Slide 33 text

"Laziness is a virtue"

Slide 34

Slide 34 text

Clojure Concurrency?

Slide 35

Slide 35 text

Clojure Concurrency

Slide 36

Slide 36 text

Clojure Concurrency

Slide 37

Slide 37 text

Today… To avoid Deadlocks:

Slide 38

Slide 38 text

Timeout and Retry? Specific Lock Order? Coarse Locks?

Slide 39

Slide 39 text

“ Locks are the Enemy ”

Slide 40

Slide 40 text

STM Software Transactional Memory

Slide 41

Slide 41 text

NO BLOCKING

Slide 42

Slide 42 text

NO LOCKS

Slide 43

Slide 43 text

PERSISTENT COLLECTIONS

Slide 44

Slide 44 text

Clojure IS much more…

Slide 45

Slide 45 text

• Clojure:Functional Concurrency for the JVM - Howard M. Lewis Ship • Clojure: A dynamic programming language for the JVM - Rich Hickey • Intro to Clojure by Balint Erdi ( https://speakerdeck.com/balint/intro- to-clojure ) • Clojure Intro ( http://www.slideshare.net/thnetos/clojure-intro ) • Introduction to Clojure by Renzo Borgatti ( http://pt.slideshare.net/ reborg/introduction-to-clojure-13679039 ) References

Slide 46

Slide 46 text

• http://www.braveclojure.com/getting-started/ References

Slide 47

Slide 47 text

Thanks!! @raphamundi