Functional Programming in 40 minutes @russolsen Functional - - PowerPoint PPT Presentation
Functional Programming in 40 minutes @russolsen Functional - - PowerPoint PPT Presentation
Functional Programming in 40 minutes @russolsen Functional Programming in 40 minutes @russolsen Functional Programming Functional Programming Clojure spin Functional Programming 40 Minutes? What is it? What's it like? Does it work?
Functional Programming
in 40 minutes @russolsen
Functional Programming
in 40 minutes @russolsen
Functional Programming
Functional Programming
Clojure spin
Functional Programming
40 Minutes?
What is it? What's it like? Does it work?
What is it? What's it like? Does it work?
FORGET
Everything You Know About Programming
What Do You Know?
FORGET
Everything You Know About Programming
REALLY?
Functional Programming
Everything You Know About Programming
Refactor
It Works But...
Mess
What About Programming?
During the type erasure process, the Java compiler erases all type parameters and replaces each with its first bound if the type parameter is bounded,
- r Object if the type parameter
is unbounded.
https://docs.oracle.com/javase/tutorial/java/generics/genTypes.htmlDuring the type erasure process, the Java compiler erases all type parameters and replaces each with its first bound if the type parameter is bounded,
- r Object if the type
parameter is unbounded.
Protected methods: a protected method is similar to a private method, with the addition that it can be called with, or without, an explicit receiver, but that receiver is always self (it’s defining class) or an
- bject that inherits from self .
A friend function of a class is defined
- utside that class' scope but it has the
right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.
https://www.tutorialspoint.com/cplusplus/cpp_friend_functions.htmMessy?
f(x)
1 2 3 4 5 2 4 6 8 10
f(x)
1 2 3 4 5 2 4 6 8 10
Procedures Subroutines Functions Methods
5 10 3 6
5 42 3 6 10 ??
5 10 3 6
5 10 3 6
f(x)
A Thing
f(x)
A Thing I Can Make
f(x)
1st Class
Look at Input Produce Output
No Side Effects
x = ['a','b','c'] y = a(x) x = ?
x = ['a','b','c'] y = x = ?
c(a(x) + b(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + b(x)) + d(x) / c(a(x) + b(x)) + d(x) * e(x) + g(x) + h(x) * floor(b(x)) + 16 * a(x) - ceil(g(x) - c(a(x) + b(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + b(x)) + d(x) / c(a(x) + b(x)) + d(x) * e(x) + g(x) + h(x) * floor(b(x)) + 16 * a(x)f(x)
Problem
a b c
a b c
a Q c
x = ['a','b','c'] y = x = ?
c(a(x) + b(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + b(x)) + d(x) / c(a(x) + b(x)) + d(x) * e(x) + g(x) + h(x) * floor(b(x)) + 16 * a(x) - ceil(g(x) - c(a(x) + b(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + b(x)) + d(x) / c(a(x) + b(x)) + d(x) * e(x) + g(x) + h(x) * floor(b(x)) + 16 * a(x)x[2] = 'Q'
y = t + c(a(x) + b(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + d(x) * e(x) - 4 * (q(x) - f(x)) + b(x)) + d(x) / c(a(x) + b(x)) + d(x) * e(x) + g(x) + h(x) * floor(b(x)) + 16 * a(x)Immutable
a b c a Q c
Problem
Copies Copies Copies
- p
- p
- p
Persistent Data Structures
- p
- p
- Q
- Q
- Q
3
3
f(x)
Problem
Side Effects
SIDE EFFECTS
EFFECTS
Russ Olsen russ@russolsen.com57
Atoms
57
f(x)
Atoms
58
f(x)
Atoms
59
f(x) g(x)
Atoms
59
f(x) g(x)
Atoms
g(x)
some_code(queue)
Agents/Actors
f(x) g(x)
f(x)
What is it? What's it like? Does it work?
Magic
Magic
You still have
- ff-by-one
errors
You still have REDUNDANT code
BAD CODE
The database is
STILL DOWN
Threads!
What is it? What's it like? Does it work?
pedestal.io
What is Pedestal?
Pedestal is a set of libraries that we use to build services and- applications. It runs in the back end and can serve up whole
18,706
lines
28
protocols
+
8
bridges to the stateful world
9
Record types
+
1
multi method
+
944
functions
f(x)
f(x)
YES
Questions?
@russolsen