Intro to Clojure

Intro to Clojure

Slides of my Lecture in the Academic Computer Science week - UFF 2015

Ed35943d3199ea37b1b60c39615e8163?s=128

Raphael Amorim

November 26, 2015
Tweet

Transcript

  1. CLOJURE Intro to @raphamundi

  2. None
  3. Raphael Amorim This is me :P

  4. WHAT’S CLOJURE ?

  5. WHAT’S CLOJURE? Clojure is a dynamic programming language that targets

    the Java Virtual Machine (and the CLR, and JavaScript).
  6. WHO’S USING CLOJURE? Akamai, Appvise, Citigroup, Amazon, eBay, Heroku, Groupon,

    Netflix, Nubank, Salesforce, Walmart Labs, Zendesk […] http://clojure.org/Companies
  7. TAKING NOTES.

  8. - Started in 2007 - Created by Rich Hickey -

    Under Eclipse Public License TAKING NOTES.
  9. “ 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.
  10. FUNCIONAL PARADIGM?

  11. Back to the Past.

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

    Past.
  13. Lisp - 1958 Introduced a programming language able to deal

    with mathematical notation Back to the Past.
  14. 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.
  15. “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.
  16. 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.
  17. Definitions

  18. Treats computation as the evaluation of mathematical functions and avoids

    changing-state and mutable data.
  19. So…

  20. Take values and return values.

  21. Same argument, same result.

  22. Testing is easier, because there’s no state.

  23. NO SIDE EFFECTS.

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

  25. Syntax?

  26. - Numbers ( 1, 3, 5, 85 ) - Character

    ( \h, \r, \a ) - String ( “barbante” ) - Boolean ( true, false ) - Symbol ( ‘a, ‘b, ‘c )
  27. - Keywords ( :bad, :cool, :ugly ) - null (

    nil )
  28. 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
  29. 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
  30. Clojure REPL

  31. There’s NO interpreter

  32. "Laziness is a virtue"

  33. "Laziness is a virtue"

  34. Clojure Concurrency?

  35. Clojure Concurrency

  36. Clojure Concurrency

  37. Today… To avoid Deadlocks:

  38. Timeout and Retry? Specific Lock Order? Coarse Locks?

  39. “ Locks are the Enemy ”

  40. STM Software Transactional Memory

  41. NO BLOCKING

  42. NO LOCKS

  43. PERSISTENT COLLECTIONS

  44. Clojure IS much more…

  45. • 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
  46. • http://www.braveclojure.com/getting-started/ References

  47. Thanks!! @raphamundi