Top Banner
Clojure & Functional Programming? Eric Normand
12

Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

May 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Clojure &Functional Programming?

Eric Normand

Page 2: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Outline

Eric Normand FunctionalProgramming

Clojure Clojure SYNC

Page 3: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Eric Normand

• UNO Alumnus (Bachelor’s and Masters)

• Functional programming (Lisp) since

2001

• Got into Clojure in 2008

• Professional FP 2010-present

• Teaches Functional Programming and

Clojure

@ericnormand - lispcast.com

Who am I?

Page 4: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Three DomainsFunctional Programming

Functional Programming is a programming paradigm that views solutions to problems in terms of three domains. All objects in

the solution fall into one of these three domains.

Actions are the broadest domain. It is

composed of anything that depends

on when it is run or how many times

it is run.

ActionsCalculations are the domain of

mathematical computation and

other “pure” calculations. They

depend on execution to be

understood.

CalculationsData is the domain of inert values.

They depend on interpretation to be

understood.

Data

Page 5: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Actions1

the process of doing something, typically to achieve an aim

• Send an email

• Launch a missile

• Modify or read global mutable state

• Read from disk

• Send a web request

Examples

Depend on when they are run or how many times they are run. They change

the world.

Criterion

Concurrency guarantees

• Idenpotence

• Transactional properties

• Freedom from side-effects

• Exactly-once reads

Discipline

Page 6: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Calculations2

computation from inputs to outputs

• Summing numbers

• Statistical calculations

• Transforming from one format to another

Examples

Depend on being run to know what they do. They are opaque.Criterion

Pure functions

• Rely only on arguments

• Return a value

• No side-effects

Discipline

Page 7: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Data3

factual information used as a basis for reasoning, discussion, or calculation

• Numbers

• Lists

• Dictionaries

• Tables

• Strings

Examples

Depend on interpretation. They are inert. Criterion

Immutability

• Copy-on-write

• Persistent data structures

• Append-only data stores

Discipline

Page 8: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Functional Programming

Clojure

Clojure is a Lisp

Lisp is a family of

programming

languages invented

in 1958 by John

McCarthy.

Written by Rich Hickey

First released in

2007.

Designed to be hosted

Clojure is designed

to be hosted on the

JVM. It now also

compiles to

JavaScript.

Data-Orientation

Concurrency

Page 9: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Atoms

Queues

Communicating Sequential

Processes

Concurrency PrimitivesActions

Functional Programming Clojure

Page 10: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Data transformation

Pipelining

Higher-order functions

Rich core libraryCalculations

Functional Programming Clojure

Page 11: Clojure & Functional Programming? - LispCastlispcast.com/wp-content/uploads/2018/10/Clojure... · Functional Programming Clojure Clojure is a Lisp Lisp is a family of programming

Atomic values

Collections

Immutable DataData

Functional Programming Clojure

123{}[]

“abc”