Slide 1

Slide 1 text

Clojure Lauro Caetano 14/01/2014

Slide 2

Slide 2 text

Just an introduction

Slide 3

Slide 3 text

• Intro (Syntax, Data Structures, Functions) • Persistent Data Structures • Macros • Famous projects • Should I use Clojure? • Learn more.

Slide 4

Slide 4 text

• Clojure is a dynamic programming language that targets the Java Virtual Machine. • Clojure is a dialect of Lisp (code as data). • Functional (features a rich set of immutable, persistent data structure). • When mutable state is needed, Clojure offers a software transactional memory system and reactive Agent system that ensure clean, correct, multithreaded designs.

Slide 5

Slide 5 text

• All operations have this form: (operator operands)

Slide 6

Slide 6 text

• Other languages mixes infix notation, dot operators and parentheses. Example:

Slide 7

Slide 7 text

• Nil, String, numbers, keywords, symbols, collections…

Slide 8

Slide 8 text

• Collections are immutable and persistent.

Slide 9

Slide 9 text

• Maps are similar to dictionaries or hashes in other languages. They are a way of associating some value with some other value.

Slide 10

Slide 10 text

• Vector is similar to an Array.

Slide 11

Slide 11 text

• Lists are similar to vector in that they are linear collections of values.

Slide 12

Slide 12 text

• Sets are collections of unique values.

Slide 13

Slide 13 text

• Functions

Slide 14

Slide 14 text

• Clojure evaluates all function arguments recursively before passing them to the function.

Slide 15

Slide 15 text

• Valid function calls

Slide 16

Slide 16 text

• Persistent Data Structures.

Slide 17

Slide 17 text

• There is no Clojure equivalent for the following Ruby:

Slide 18

Slide 18 text

• Ok.. Immutable, but what about persistent?

Slide 19

Slide 19 text

• While persistence can be achieved by simple copying, this is inefficient in CPU and RAM usage, because most operations make only small changes to a data structure.

Slide 20

Slide 20 text

• A better method is to exploit the similarity between the new and old versions to share structure between them, such as using the same subtree in a number of tree structures. • (Fat Node, Path Copying, A combination)

Slide 21

Slide 21 text

• Macros

Slide 22

Slide 22 text

• Macro is a tool for transforming an arbitrary data structure into one which can be evaluated by Clojure. (Allows new syntax)

Slide 23

Slide 23 text

• the -> (threading macro)

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

• Famous Projects

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

• Should I use Clojure?

Slide 30

Slide 30 text

• Learn. • Improve the way you write code in other languages. • Motivation.

Slide 31

Slide 31 text

• Learn more

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

• References • https://github.com/clojure/clojure • clojure.org • http://en.wikipedia.org/wiki/ Persistent_data_structure • http://www.braveclojure.com/ • http://www.infoq.com/presentations/Value- Identity-State-Rich-Hickey