21. Dining Philosophers
• A philosopher is either hungry
or thinking
• If he is hungry, he picks up a
chopsticks on either side of
him and eats for a while.
• When he is done, he puts
them down
23. • java 6 has java.util.concurrent package.
• This package has great features
• Use case :
• XBRL instance creation ( 5-6 financial table in
parallel by Executer Tasks)
• Load tests 75 —> 150 concurrent user
26. Functional Programming
• Imperative program has series of statements that
changes global state when executed
• A functional programming ( aka FP) computation as
evaluation of expression.
• Those expressions are built from pure
mathematical functions
• Side effect free
27. • FP is useful for concurrency because lack of side
effect makes reasoning about thread safety much
easier.
• FP allows parallelism to be represented directly.
• If data is immutable ( not shared mutable state) can
be accessed by multiple threads without any kind
of locking.
28. History of FP
• FP invented in 1930s, Lambda Calculus
• in 1950s, LISP was created by John McCarthy
• in 1970s, ML was created Robin Milner and David
Turner.
• in 1987, Haskell began with a consensus (open
standards)
29. Haskell Basic Features
• Pure Function
• First Class and higher order function
• Recursion
• Immutable
• Lazy evaluation
35. Elixir
• Created by Jose Valim in 2012
• Syntax is similar to Ruby
• Runs on Erlang Virtual
Machine (BEAM)
• Functional
• Erlang process (actor)
36.
37. Use Case : Pinterest
• 14000 notification per seconds
• Runs on 15 server( old one runs on 30 server)
• Pinterest API : response time is about 500 µs
https://engineering.pinterest.com/blog/introducing-new-open-source-tools-elixir-community
38. Use Case : Whatsapp
• Run on Erlang BEAM/OTP
• 1+ Million user signup per day
• 50 Million messages per day
• 14 Million active users per day
• Total 450 Million users
• >8000 cores
• > 70Million Erlang messages per day
• 2 Million connection per server
http://highscalability.com/blog/2014/2/26/the-whatsapp-architecture-facebook-bought-for-19-billion.html
41. Bonus - 1
• Clojure
• Created by Rich Hickey in
2007
• Inspired by LISP
• Runs on JVM
• Clojure Agent: shared access
to mutable state.
• No blocking receive
42. Bonus - 2
• Is FP (Haskell) ready for
industry ?
• Linq invented by Eric Meijer
• Scala, F# , Swift, even Java
8 has FP features
43. Bonus - 3
• I love imperative style, which
programming language may I
use ?
• GOLANG :
• is invented after multi core
• Has Garbage Collector
• Has go-routine & chain