functional, concurrent, distributedprogramming for the rest of usELIXIR
View Slide
@whatyouhide
LET'S BUILD ALANGUAGE
Language formodern systems
concurrentdistributedfault-tolerantextensible
don't give to devs,enable devs
VM
NO TYPESYSTEM
CONCURRENCY
threads are heavy
schedulersVM processes
memorymemory
IMMUTABLEDATA
MESSAGE PASSING
send(pid, message)receive do...end+
patternmatching
{1, _} = some_tuple
receive do{1, _} -> ...{_, _} -> ...end
case expression dopattern1 -> ...pattern2 -> ..._ -> ...end
ISOLATED MEMORYMESSAGE PASSING+
def loop(state) doreceive donew_state -> loop(new_state)endend
DISTRIBUTION
node 1 node 2
FAULTTOLERANCE
acceptor
link
linktrap crash
linktrap crashtrap crash
SUPERVISORS
SYNTAX
github.com/josevalim/lego-lang
def(double_sum(a, b), do: (=(c, +(a, b))*(c, 2)))
if(>(a, b), do: a, else: b)
macros functions+
less parens?
def(double_sum(a, b), do: (c = a + bc * 2))
def double_sum(a, b), do: (c = a + bc * 2)
def double_sum(a, b) doc = a + bc * 2end
if a > b doaelsebend
literals and containers
[1, 2, 3][](1, 2, 3)
def add(a, b), do: a + b
defmacro def(call, keywords)add(a, b)do: (a + b)
case expression dotrue -> branch1else -> branch2end
defmacro if(condition, do: branch1, else: branch2) doquote docase unquote(condition) dotrue -> unquote(branch1)false -> unquote(branch2)endendend
CONLCLUSION
PLOT TWIST...we builtELIXIR
concurrentdistrubutedfault-tolerantextensible
elixir-lang.org@whatyouhide