SlideShare a Scribd company logo
PubNative Tracker
Andrew Djoga
PubNative Tracker
Elixir is what would happen if Erlang, Clojure and
Ruby somehow had a baby and it wasn't an
accident.
Devin Torres
open source enthusiast
Immutability
animals = ["capybara", "apple", "lemur"]
List.delete(animals, "apple")
#=> ["capybara", "lemur"]
animals
#=> ["lion", "table", "bear"]
High-order functions
double = fn(i) -> i * 2 end
Enum.map([1, 2, 3], double)
#=> [2, 4, 6]
Pattern matching
[first, second, _] = [
:virginia,
:singapore,
:ireland,
]
first
#=> :virginia
second
#=> :singapore
Pattern matching
list = [1, 2, 3]
[1 | tail] = list
tail
#=> [2, 3]
[2 | _] = list
** (MatchError) no match of right hand side
value: [1, 2, 3]
Collections
Enum.any?(["foo", "bar", “hi"],
fn(s) -> len(s) == 2 end)
#=> true
File.read("path/to/unknown/file")
#=> {:error, "reason"}
map = %{:foo => "bar", :hello => "hi"}
map[:foo]
#=> “bar"
Functions
def square([]), do: []
def square([head | tail]) do
[head * head | square(tail)]
end
square([1, 2, 3])
#=> [1, 4, 9]
Enum.map([1, 2, 3], fn(x) -> x * x end)
#=> [1, 4, 9]
Composition
defmodule Math do
def sum(a, b) do
a + b
end
end
Math.sum(1, 2)
#=> 3
Concurrency
lightweight
isolation
message passing
Concurrent processes with no data sharing
provide a strong measure of fault isolation.
A software error in a concurrent process
should not influence processing in the other
processes in the system.
creator of Erlang
Joe Armstrong
Based on its designated behavior, the actor responds
to incoming messages by send new messages,
spawn new actors and/or changing its future behavior.
Each actor has its own mailbox and isolated state.
Supervisor
children = [
supervisor(Stats.Supervisor),
supervisor(Queue.KafkaSupervisor),
worker(Queue.SQSWorker, [period, []]),
supervisor(Queue.Supervisor),
supervisor(Cache.DBSupervisor),
Plug.Adapters.Cowboy.child_spec(:http, Router, [],
[port: port])
]
supervise(children,
strategy: :one_for_one,
max_restarts: 10,
max_seconds: 1
)
Worker
def handle_cast(:receive, state) do
case :sqs.receive(state.queue) do
[] -> Logger.info("no messages")
messages -> to_kafka(messages)
end
{:noreply, state}
end
def terminate(reason, _) when reason == :normal, do: :ok
def terminate(reason, state) do
Logger.error("#{reason}: #{inspect state}")
:ok
end
tooling
IEx
iex(1)> Weather
...(1)> |> where(city: "Berlin")
...(1)> |> order_by(:temp_lo)
...(1)> |> limit(10)
...(1)> |> Repo.all
Mix
mix new my_app
compile
test
deps.get
ExUnit
test "decodes a base64 without padding chars" do
assert Token.urlsafe_decode64("YWJjZA") == "abcd"
assert Token.urlsafe_decode64("YWJjZA=") == "abcd"
assert Token.urlsafe_decode64("YWJjZA==") == "abcd"
end
➜ tracker mix test test/tracker/api/token_test.exs --trace
Tracker.API.TokenTest
* decodes a base64 without padding chars (8.1ms)
* decodes a base64 in the URLEncoding mode defined in RFC 4648 (0.01ms)
* fixes a token with a double question mark (0.01ms)
* decrypts a token (15.2ms)
* returns error with a broken token (14.8ms)
Finished in 0.1 seconds (0.09s on load, 0.03s on tests)
5 tests, 0 failures
Type Specifications
@spec network(integer) :: {String.t, String.t} | :not_found
def network(id) do
case :ets.lookup(:db_networks, id) do
[{^id, name, url}] -> {name, url}
_ -> :not_found
end
end
Dialyzer is a static analysis tool that identifies software
discrepancies such as type errors, unreachable code,
unnecessary tests, etc in Erlang / Elixir applications.
$ iex --name console@127.0.0.1 --remsh tracker@127.0.0.1
etop
Erlang Top is a tool for presenting information about Erlang
processes similar to the information presented by "top" in
UNIX.
erlang.processes()
Returns a list of process identifiers corresponding to all
the processes currently existing on the local node.
erlang.memory()
Returns a list with information about memory dynamically
allocated by the Erlang emulator.
Built-In Term Storage
ETS tables are implemented as BIFs in the ets
module.
The main design objectives ETS had was to
provide a way to store large amounts of data in
Erlang with constant access time and to have
such storage look as if it were implemented as
processes in order to keep their use simple and
idiomatic.
http://learnyousomeerlang.com
http://elixir-lang.org
http://erlang.org/doc/design_principles/users_guide.html
http://ninenines.eu/docs/en/cowboy/1.0/guide

More Related Content

PDF
Frege is a Haskell for the JVM
KEY
An introduction to Ruby
PDF
Cukeup nyc ian dees on elixir, erlang, and cucumberl
KEY
Clojure入門
PDF
"PostgreSQL and Python" Lightning Talk @EuroPython2014
PDF
CoffeeScript
PDF
Pre-Bootcamp introduction to Elixir
PDF
Ruby 1.9
Frege is a Haskell for the JVM
An introduction to Ruby
Cukeup nyc ian dees on elixir, erlang, and cucumberl
Clojure入門
"PostgreSQL and Python" Lightning Talk @EuroPython2014
CoffeeScript
Pre-Bootcamp introduction to Elixir
Ruby 1.9

What's hot (20)

PDF
Damn Fine CoffeeScript
PDF
Simulator customizing & testing for Xcode 9
PDF
Python postgre sql a wonderful wedding
PDF
Lập trình Python cơ bản
PDF
The Magic Of Elixir
KEY
Hidden treasures of Ruby
PDF
An (Inaccurate) Introduction to Python
PDF
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
PDF
Parse Everything With Elixir
PDF
스위프트를 여행하는 히치하이커를 위한 스타일 안내
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
PDF
7li7w devcon5
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
PPTX
Groovy puzzlers по русски с Joker 2014
PDF
Investigating Python Wats
PPTX
ES6: Features + Rails
PDF
From mysql to MongoDB(MongoDB2011北京交流会)
PDF
[131]해커의 관점에서 바라보기
PDF
How fast ist it really? Benchmarking in practice
Damn Fine CoffeeScript
Simulator customizing & testing for Xcode 9
Python postgre sql a wonderful wedding
Lập trình Python cơ bản
The Magic Of Elixir
Hidden treasures of Ruby
An (Inaccurate) Introduction to Python
Stop Guessing and Start Measuring - Benchmarking in Practice (Lambdadays)
Parse Everything With Elixir
스위프트를 여행하는 히치하이커를 위한 스타일 안내
Building Real Time Systems on MongoDB Using the Oplog at Stripe
7li7w devcon5
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Groovy puzzlers по русски с Joker 2014
Investigating Python Wats
ES6: Features + Rails
From mysql to MongoDB(MongoDB2011北京交流会)
[131]해커의 관점에서 바라보기
How fast ist it really? Benchmarking in practice
Ad

Viewers also liked (8)

PDF
LIArena_141014_9_8
PPTX
Proyecto 1-Aprendiendo sobre las TICs
PDF
Young Employee Award - Clare Bassett
PPTX
Double award pitch
PPTX
2.2. luís gonçalo campos, paulo fernandes, margarida c. coelho
PPTX
2.2. andré pedrosa, helena albuquerque, zélia breda
PPTX
Managing risk through change: charities
PPTX
How to Determine CLIENT LIFETIME VALUE in Five Minutes
LIArena_141014_9_8
Proyecto 1-Aprendiendo sobre las TICs
Young Employee Award - Clare Bassett
Double award pitch
2.2. luís gonçalo campos, paulo fernandes, margarida c. coelho
2.2. andré pedrosa, helena albuquerque, zélia breda
Managing risk through change: charities
How to Determine CLIENT LIFETIME VALUE in Five Minutes
Ad

Similar to PubNative Tracker (20)

KEY
Haskellで学ぶ関数型言語
PDF
Elm: give it a try
PDF
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
PDF
What I learned from Seven Languages in Seven Weeks (IPRUG)
PDF
Useful javascript
PDF
Introduction to Scala
PDF
Introducción a Elixir
PDF
CoffeeScript
PPT
Scala presentation by Aleksandar Prokopec
PDF
Brief tour of psp-std
PDF
여자개발자모임터 6주년 개발 세미나 - Scala Language
PDF
An introduction to property-based testing
PDF
ssh.isdn.test
PDF
PPTX
Groovy puzzlers jug-moscow-part 2
PDF
PPTX
Towards Programming Languages for Reasoning.pptx
PDF
Elixir cheatsheet
PDF
Slaying the Dragon: Implementing a Programming Language in Ruby
Haskellで学ぶ関数型言語
Elm: give it a try
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
What I learned from Seven Languages in Seven Weeks (IPRUG)
Useful javascript
Introduction to Scala
Introducción a Elixir
CoffeeScript
Scala presentation by Aleksandar Prokopec
Brief tour of psp-std
여자개발자모임터 6주년 개발 세미나 - Scala Language
An introduction to property-based testing
ssh.isdn.test
Groovy puzzlers jug-moscow-part 2
Towards Programming Languages for Reasoning.pptx
Elixir cheatsheet
Slaying the Dragon: Implementing a Programming Language in Ruby

Recently uploaded (20)

PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT
Project quality management in manufacturing
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Artificial Intelligence
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
web development for engineering and engineering
PDF
Well-logging-methods_new................
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
introduction to datamining and warehousing
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
PPT on Performance Review to get promotions
PPT
Mechanical Engineering MATERIALS Selection
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Geodesy 1.pptx...............................................
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Project quality management in manufacturing
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Artificial Intelligence
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
web development for engineering and engineering
Well-logging-methods_new................
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Internet of Things (IOT) - A guide to understanding
Automation-in-Manufacturing-Chapter-Introduction.pdf
introduction to datamining and warehousing
Foundation to blockchain - A guide to Blockchain Tech
PPT on Performance Review to get promotions
Mechanical Engineering MATERIALS Selection
Model Code of Practice - Construction Work - 21102022 .pdf
Geodesy 1.pptx...............................................
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...

PubNative Tracker