welcome to erlang

22
Welcome to Erlang

Upload: oleg-zinchenko

Post on 06-Aug-2015

114 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Welcome to Erlang

Welcome to Erlang

Page 2: Welcome to Erlang

cystbearErlanger

Symfony expert

MongoDB adept

OSS doerhttps://twitter.com/1cdecoderhttps://github.com/cystbearhttp://trinity.ck.ua/

Page 3: Welcome to Erlang
Page 4: Welcome to Erlang

HOTCODE 2013

https://twitter.com/5hthttps://synrc.com/

Maxim Sokhatskiy

Page 5: Welcome to Erlang

Time to change something

Page 6: Welcome to Erlang

History

Page 8: Welcome to Erlang

Specific use cases

Non OOP paradigm

Naive syntax

No so big community

Lack of libs

Pros / Cons

https://www.erlang-solutions.com/https://synrc.com/https://github.com/tapstershttps://github.com/erlangbureau

Page 9: Welcome to Erlang

Low level thinking!FunctionalFastRobustExpressive syntaxEndless running appsUpdate code on a flyOwn SchedulerProcesses based architectureSupervisor treeNo shared memory

Pros / Cons

Page 10: Welcome to Erlang

Hey, did you heard about FP?

Page 11: Welcome to Erlang

High order functions

Lambda functions

Separation data and functions

Immutable

Lazy

Tail recursion

Algebraic data types

Pattern matching

Functional

https://twitter.com/nikitonskyhttp://tonsky.me/talks/2015-frontendconf/http://tonsky.me/talks/2015-codefest/

Page 12: Welcome to Erlang

Performance

http://slides.com/maximsokhatsky/n2o

Page 13: Welcome to Erlang

Scheduler

http://habrahabr.ru/post/128772/http://habrahabr.ru/post/260065/

Page 14: Welcome to Erlang

Basics

Integer 42 Float 4.2 aka doubleAtom okBinary <<"Erlang-powa">>

Reference #Ref<0.0.0.29>Pid <0.0.42>Port #Port<0.42>Fun #Fun<erl_eval.6.82930912>

Page 15: Welcome to Erlang

Basics2

List [<<42,1,0,90>>, 1, ok]

Tuple {<0.0.16>, 107, 42, ["madness", true]}

we can force lists type and typify turplesnamed tuples =:= records

Page 16: Welcome to Erlang

Example

-module(fib).

-export([fib/1, tail_fib/1]).

fib(0) -> 0;

fib(1) -> 1;

fib(N) -> fib(N - 1) + fib(N - 2).

Page 17: Welcome to Erlang

Example

tail_fib(N)-> tail_fib(N, 0, 0, 0).

tail_fib(N, Acc, Prev, PrevPrev) ->

case Acc of

N -> Prev + PrevPrev;

0 -> tail_fib(N, Acc + 1, 0, 0);

1 -> tail_fib(N, Acc + 1, 1, 0);

_ -> tail_fib(N, Acc + 1, Prev + PrevPrev, Prev)

end.

Page 18: Welcome to Erlang

Example QuickSort

qsort([]) -> [];

qsort([X|Xs]) ->

qsort([Y || Y<-Xs, Y <= X]) ++ [X] ++ qsort([Y || Y<-Xs, Y > X]).

Page 19: Welcome to Erlang

Application Examples

Web SitesRest ServicesVideo StreamingChats

RabbitMQRiak, CouchDB, Hibari, KAI, LeoFS, MnesiaejabberdCowboyWings 3D

PrivatBankGithub Pages / Gist

Page 20: Welcome to Erlang

Future

Page 21: Welcome to Erlang

Functional Thursday

Page 22: Welcome to Erlang