Disclaimer #1
It’s hard to tell “is this language
functional?”
We will talk about: Erlang, Scala, Clojure,
Haskell
Slide 5
Slide 5 text
Disclaimer #2
Web is only one way to communicate.
We will talk “mostly” about web.
I assume that you know what “Web” is.
Note, that it changes really fast.
Slide 6
Slide 6 text
Modern web
challenges
•real-time
notifications
•chats and other RT
messaging systems
•real-time activity
stream
•collaborative
documents editing
•task board for team
•multi-player
Bomberman (* or
your favorite game)
Slide 7
Slide 7 text
Concurrency...
Concurrency is the composition of
independently executing computations.
Concurrency is a way to structure
software, ...
(c) Rob Pike “Concurrency is not
parallelism”
Slide 8
Slide 8 text
Concurrency is
hard
when independent computations depend
on each other
Slide 9
Slide 9 text
WTF???
how independent computations can
depend on each other?
Slide 10
Slide 10 text
Why should I
care?
I’m just coding Python/Ruby/PHP/
Node.js...
Slide 11
Slide 11 text
Classical
web dev
•Many OS
processes
•Database to
store data
•....
•You are
welcome in
the world of
concurrency!
Slide 12
Slide 12 text
So what?
•Race condition on
your data
•Real-time is hard
(databases are not
designed for this)
•Leaking abstractions
•Independency is
expensive
•No tests
•No control
Slide 13
Slide 13 text
Java
& .NET
web dev
•Threads instead of
processes (VM as
OS???)
•You can use
memory for data
collaboration
•Necessity to
control access to
shared data leads
you to locks/
mutex/semaphores
Slide 14
Slide 14 text
So what?
•Independency is
still too expensive
•Still hard to test
•Still hard to
control
•Locks are not so
good abstraction
Slide 15
Slide 15 text
Event-
driven
web dev
•Single-thread
environment
•Event-based context
switching loop
•Not so “independent”
as we want
•Errors are hard to
manage
•It’s hard to keep code
simple to read
Slide 16
Slide 16 text
Do you
need more
problems?
•request-reply doesn’t
work (almost at all)
•concurrency is hard
•fault-tolerance is hard
•vertical scaling is hard
(as well as horizontal)
•everything should
have been done
yesterday
Slide 17
Slide 17 text
How to deal
with
concurrency?
Slide 18
Slide 18 text
Story about
developers
and tasks
board
•Locks: what is locks
and why it’s not a
good idea?
•Message passing:
how to
communicate and
what are the
benefits?
•STM: how to
collaborate
efficiently and not
lose control?
Slide 19
Slide 19 text
From theory to
practice
Slide 20
Slide 20 text
Concurrency
•Erlang
•Scala
•others
•Clojure
•Haskell
•others
Communication Collaboration
And why do FP “features” matter?
Slide 21
Slide 21 text
Erlang
•message-passing
concurrency
•multi-core support
•distributed systems
•“super” stable VM (VM
as OS!)
•“hard to break”
something
•interactive development
Slide 22
Slide 22 text
Scala
• JVM based, high
performance
• (mostly) functional paradigm
• expressive type system
(ADT & TI)
• “less code with more
results”
• message-passing
concurrency (prev. Akka)
• ... XML is native Scala type
Clojure
•FP, lisp-family
•STM concurrency
model
•modern language
•interactive development
•macros
•JavaScript compiler
•huge web stack
Slide 25
Slide 25 text
Haskell
•FP, “ML-family”
•green threads and STM
•expressive type system
•high level of code
modularity and
composability
•compact declarative
syntax
•compile-time program
verification
Slide 26
Slide 26 text
IWBYP
http://iwbyp.chris-granger.com/
Slide 27
Slide 27 text
How to
start?
•do not wait!
•do not hesitate!
•do not panic!!!
•do something simple
•do something
interesting
•find problem (pain?)
and solve it