SlideShare a Scribd company logo
Playing with Elixir/Phoenix
Anton Sakharov, CTO @ MLSDev
Elixir / Phoenix
This talk is not about
Elixir syntax or Phoenix cool features
The best way to master new technology
or framework is
to develop something simple but
not useless
* IMHO
Internal company website: Quote Pad
● Post quotes
● View quotes (latest / best)
● Vote for quotes (like / dislike)
● Email subscription to new quotes
Features
Old Quote Pad
● Written in 2012 by iOS developer in order to learn Ruby on Rails
● Rails 3.2.6
● SQLite in production ¯_(ツ)_/¯
● Email/password authentication using Devise gem
● Non-responsive UI
● No moderation functionality
● No admin area/dashboard
New Quote Pad
● Elixir/Phoenix
● Authentication via Google Apps / G Suite / whatever they name it tomorrow
● Amazon RDS / PostgreSQL
● UI facelift, make it responsive
● Moderation, admin. dashboard, blah-blah-blah...
● Migrate data/content
Learning curve
1. Elixir
2. Phoenix
3. Libraries
4. Deployment
5. …
6. PROFIT!!!
First steps
and things to avoid
Do not jump to Phoenix
straight away
Learn Elixir first
https://elixir-lang.org -> GUIDES
Do not learn Elixir and
Phoenix by tutorials and
videos only
1. You'll stay a Script Kiddie
2. Tutorials are probably outdated
This book is about Phoenix 1.2.
Current Phoenix is 1.3; 1.4 is about to be released
http://phoenixframework.org/
Before you go on ...
Must-read documentation
● Elixir guides (mentioned earlier)
● Phoenix guides and docs
● Plug (Rack / Middleware in Rails world)
● Ecto (ActiveRecord in Rails world)
https://hexdocs.pm
Pitfalls
● Do Elixir stuff non-Elixir way
● Do Phoenix stuff Rails-way
● Tend to OOP
● Erlang OTP gives you a lot out of the box, keep it in mind
● On the other hand, there are not that many
production-ready packages yet (like RubyGems)
Pitfalls
Do Elixir stuff non-Elixir way
Non-Elixir:
list = Enum.map(1..100_000, &(&1 * 3))
list = Enum.filter(list, odd?)
list = Enum.sum(list)
Elixir:
list =
1..100_000
|> Enum.map(&(&1 * 3))
|> Enum.filter(odd?)
|> Enum.sum
Elixir:
def sum_list([head | tail], acc) do
sum_list(tail, head + acc)
end
def sum_list([], acc) do
acc
end
Non-Elixir:
sum = 0;
for (i=0; i<sizeof(array); i++)
sum += array[i]
Do Elixir stuff non-Elixir way
Do Phoenix stuff kind of Rails-way
defmodule User do
schema "users" do
# ...
field :quote_count, :integer, virtual: true
end
# ...
end
# …
def list_users(user, params) do
page = User |> Repo.paginate(params)
# Don't do this ;)
%{page | entries: Enum.map(page,
fn u -> %User{u | quote_count: Quotes.user_quote_count(u)} end)}
end
OOP habits
user.update(%{role: "admin"}) # this is not Elixir ;)
Users.update(user, %{role: "admin"}) # this is!
What about background jobs ?
Not too many production-ready stuff available yet
● from simple things like URL validators
● to advanced like Devise for Rails
Bodyguard
Authorize plug
Data migration
● dump SQLite database: `sqlite3 dbname.sqlite3 .dump > dump.sql`
● remove `AUTOINCREMENT`
● varchar(255) -> `CHARACTER VARYING(255)`
● datetime -> `TIMESTAMP WITHOUT TIME ZONE`
● ` (backtick) -> ' (single quote)
● '' (empty string) -> `NULL` for empty date/time
● ...
Deployment
● Distillery
● edeliver
● .env
● nginx in reverse proxy mode
● SSL certificate
● Docker
● AWS ECS
● …
● WAIT!
rel/config.exs
Deployment pitfalls
● Erlang binaries: Mac OS X vs Linux
● Erlang versions: brew vs apt-get
● t2.micro (1 GB RAM) fails to build Erlang from source:
virtual memory exhausted
● it takes sooooo long to build Erlang from source…
Deployment pitfalls
DEMO
Links
https://elixir-lang.org/
http://www.phoenixframework.org/
https://github.com/h4cc/awesome-elixir/
https://hex.pm
https://hexdocs.pm/
https://github.com/mlsdev/
Any questions?
Thank you!

More Related Content

Similar to Playing with Elixir/Phoenix

Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
brien_wankel
 
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212
Mahmoud Samir Fayed
 
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Codemotion
 
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Thuy_Dang
 
Ample SDK: A tour de force
Ample SDK: A tour de forceAmple SDK: A tour de force
Ample SDK: A tour de force
Sergey Ilinsky
 
Flex And Rails
Flex And RailsFlex And Rails
Flex And Rails
Tony Hillerson
 
Intro to Elixir talk
Intro to Elixir talkIntro to Elixir talk
Intro to Elixir talk
Carlos I. Peña
 
Elixir introduction
Elixir introductionElixir introduction
Elixir introduction
Al Sayed Gamal
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
Talbott Crowell
 
Wider than rails
Wider than railsWider than rails
Wider than rails
Alexey Nayden
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
Mikkel Flindt Heisterberg
 
Elixir introd
Elixir introdElixir introd
Elixir introd
dennis zhuang
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
Luke Donnet
 
Awesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir TasksAwesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir Tasks
Jonathan Magen
 
Introduction to meta-programming in scala
Introduction to meta-programming in scalaIntroduction to meta-programming in scala
Introduction to meta-programming in scala
Alessandro Marrella
 
Introducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASHIntroducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASH
devbash
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
brian_dailey
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
IT Weekend
 
Zen and the Art of Code Maintenance
Zen and the Art of Code MaintenanceZen and the Art of Code Maintenance
Zen and the Art of Code Maintenance
Jemuel Young
 
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Codemotion
 

Similar to Playing with Elixir/Phoenix (20)

Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
 
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212
 
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
 
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEAShell scripting - By Vu Duy Tu from eXo Platform SEA
Shell scripting - By Vu Duy Tu from eXo Platform SEA
 
Ample SDK: A tour de force
Ample SDK: A tour de forceAmple SDK: A tour de force
Ample SDK: A tour de force
 
Flex And Rails
Flex And RailsFlex And Rails
Flex And Rails
 
Intro to Elixir talk
Intro to Elixir talkIntro to Elixir talk
Intro to Elixir talk
 
Elixir introduction
Elixir introductionElixir introduction
Elixir introduction
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
Elixir introd
Elixir introdElixir introd
Elixir introd
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
Awesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir TasksAwesome Concurrency with Elixir Tasks
Awesome Concurrency with Elixir Tasks
 
Introduction to meta-programming in scala
Introduction to meta-programming in scalaIntroduction to meta-programming in scala
Introduction to meta-programming in scala
 
Introducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASHIntroducing Elixir and OTP at the Erlang BASH
Introducing Elixir and OTP at the Erlang BASH
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Zen and the Art of Code Maintenance
Zen and the Art of Code MaintenanceZen and the Art of Code Maintenance
Zen and the Art of Code Maintenance
 
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
Erik Wendel - Beyond JavaScript Frameworks: Writing Reliable Web Apps With El...
 

Recently uploaded

UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
devvsandy
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 

Recently uploaded (20)

UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 

Playing with Elixir/Phoenix