SlideShare a Scribd company logo
1 of 53
Elixir and Elm – the perfect couple
Tomasz Kowal
What is this talk about?
● Programming web applications
● Patterns applicable not only in Elm and Elixir
– single source of truth
– one directional flows
● How programming languages shape programs?
● Why is it a good idea to use more than one
programming language in your app?
Why new programming languages?
● functional vs imperative
● languages are defined by what is easy to do
● but sometimes even more by what is HARD
++++++++[>++++[>++>+++>++
+>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..++
+.>>.<-.<.+++.------.--------.>>+.>++.
Erlang – made for fault tolerance
● Easy concurrency
● Easy distribution
● Easy debugging
● Easy messaging
● Impossible sharing memory
● Impossible reassigning variables
● Relatively hard string manipulation
Elixir – made for web
● Metaprogramming
● Strings done well
● Inherits all good and bad sides of Erlang
Elm – made for browser
● Static typing
● Almost no runtime exceptions
● Very easy to follow programming model
I hate language comparisons
The Blub paradox
Power continuum
"it is, all other things being equal, a mistake to
program in anything but the most powerful
[programming language]”
- Paul Graham
"it is, all other things being equal, a mistake to
program in anything but the most suitable
language for the problem domain”
- Tomasz Kowal
- interactive frontend
- available backend
Objective measure
„number of things, you need to keep in mind to
understand given code fragment”
„programmers memory consumption”
PMC
Functional languge
def function(arg1, arg2) do
value = some_computations(arg1)
another_value = some_computations(arg2)
value + another_value
end
Functional languge
def function(arg1, arg2) do
value = some_computations(arg1)
another_value = some_computations(arg2)
value + another_value
end
Functional languge
def function(arg1, arg2) do
value = some_computations(arg1)
another_value = some_computations(arg2)
value + another_value
end
Functional languge
def function(arg1, arg2) do
value = some_computations(arg1)
another_value = some_computations(arg2)
value + another_value
end
PMC = 4
OO Language
def method(arg1, arg2) do
value = some_computation(arg1 + property1)
property2 = some_computation(arg2)
value + property2
end
OO Language
property1
property2
def method(arg1, arg2) do
value = some_computation(arg1 + property1)
property2 = some_computation(arg2)
value + property2
end
Building frontend
"modifying document object model by reacting to
events from user and server"
Frontend programming
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
Frontend programming
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
Frontend programming
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
Frontend programming
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
Everything that is syntactically legal that the
compiler will accept will eventually wind up in your
codebase.
- John Carmack
Signals
tHTML
HTML’
HTML’’
Signals
tHTML
HTML’
HTML’’
User input
Server event
User input’
Signals
tHTML
HTML’
HTML’’
User input
Server event
User input’
model
model’
model
model’’
update
Signals
tHTML
HTML’
HTML’’
User input
Server event
User input’
model
model’
model
model’’
update view
Signals
tHTML
HTML’
HTML’’
User input
Server event
User input’
model
model’
model
model’’
update view
Pure functions!
Single data structure holds entire application
state.
Backend programming
Backend programming
Backend programming
Backend programming - netsplit
Actors
msg
actor actor’
(queue msg)
t
Actors
msg
msg’
actor actor’
process msg’
(queue msg)
other msg process other msg
t
Actors
msg
msg’
actor
other msg’
actor’
process msg’
process msg
(queue msg)
other msg process other msg
t
(/dev/null)
Actors
msg
msg’
msg’’
actor
other msg’
actor’
process msg’
process msg
(queue msg)
other msg
(/dev/null)
process other msg
t
(/dev/null)
Actors
msg
msg’
msg’’
actor
other msg’
actor’
process msg’
process msg
(queue msg)
other msg
(/dev/null)
process other msg
t
(/dev/null)
Is actor alive/reachable?
Notify on death
Kill from outside
Kill and restart group of actors
Elixir
def function(arg1, arg2) do
val = receive msg of
{:msg, msg} -> msg
end
val + arg1 + arg2
end
CAP
Conn
Enpoint.call(conn, opts) → conn
Router.call(conn, opts) → conn
Router.browser(conn, opts) → conn
MyController.index(conn, params) → conn
Auth.authenticate(conn, repo) → conn
conn |> endpoint |> router |> pipelines |>
controller
conn |> controller |> common_services |> action
- Single data structure (source of truth)
- flow in one direction
Connecting Phoenix and Elm
● Phoenix Channels
● Phoenix asset pipeline
● Elm ports
● Elm signals
Resources
Elm lang homepage: http://elm-lang.org/
Elm architecture https://github.com/evancz/elm-architecture-tutorial
Different FRP model https://www.youtube.com/watch?v=Agu6jipKfYw
Time traveling debugger http://debug.elm-lang.org/
Elixir lang homepage: http://elixir-lang.org/
Phoenix framework: http://www.phoenixframework.org/
Programming Phoenix:
https://pragprog.com/book/phoenix/programming-phoenix
Elixir + Elm tutorial http://www.cultivatehq.com/posts/phoenix-elm-1/
Elm + Elixir keynote https://www.youtube.com/watch?v=XJ9ckqCMiKk
My blog: http://tkowal.wordpress.com/
Things to remember #1
Different programming languages solve different
problems.
Things to remember #2
For interactive web applications check out both
Elixir and Elm
Things to remember #3
If you like this talk, follow me on Twitter
@snajper47

More Related Content

Viewers also liked

Viewers also liked (12)

Functional web with elixir and elm in phoenix
Functional web with elixir and elm in phoenixFunctional web with elixir and elm in phoenix
Functional web with elixir and elm in phoenix
 
Elm a possible future for web frontend
Elm   a possible future for web frontendElm   a possible future for web frontend
Elm a possible future for web frontend
 
Claudia Doppioslash - Time Travel for game development with Elm
Claudia Doppioslash - Time Travel for game development with ElmClaudia Doppioslash - Time Travel for game development with Elm
Claudia Doppioslash - Time Travel for game development with Elm
 
Elm: frontend code without runtime exceptions
Elm: frontend code without runtime exceptionsElm: frontend code without runtime exceptions
Elm: frontend code without runtime exceptions
 
Very basic functional design patterns
Very basic functional design patternsVery basic functional design patterns
Very basic functional design patterns
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web development
 
Functional Web Development using Elm
Functional Web Development using ElmFunctional Web Development using Elm
Functional Web Development using Elm
 
Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With Elm
 
A recommendation engine for your applications - M.Orselli - Codemotion Rome 17
A recommendation engine for your applications - M.Orselli - Codemotion Rome 17A recommendation engine for your applications - M.Orselli - Codemotion Rome 17
A recommendation engine for your applications - M.Orselli - Codemotion Rome 17
 
Self-testing Code
Self-testing CodeSelf-testing Code
Self-testing Code
 
Introduction to Elm
Introduction to ElmIntroduction to Elm
Introduction to Elm
 
Elm intro
Elm introElm intro
Elm intro
 

Similar to Elixir and elm - the perfect couple

TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
Eelco Visser
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
Dmitry Buzdin
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud apps
David Cunningham
 

Similar to Elixir and elm - the perfect couple (20)

Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programming
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
 
Code Cleanup: A Data Scientist's Guide to Sparkling Code
Code Cleanup: A Data Scientist's Guide to Sparkling CodeCode Cleanup: A Data Scientist's Guide to Sparkling Code
Code Cleanup: A Data Scientist's Guide to Sparkling Code
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
Software Development Automation With Scripting Languages
Software Development Automation With Scripting LanguagesSoftware Development Automation With Scripting Languages
Software Development Automation With Scripting Languages
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and How
 
FastR+Apache Flink
FastR+Apache FlinkFastR+Apache Flink
FastR+Apache Flink
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud apps
 
Golang
GolangGolang
Golang
 
Golang
GolangGolang
Golang
 
Extreme Apache Spark: how in 3 months we created a pipeline that can process ...
Extreme Apache Spark: how in 3 months we created a pipeline that can process ...Extreme Apache Spark: how in 3 months we created a pipeline that can process ...
Extreme Apache Spark: how in 3 months we created a pipeline that can process ...
 
Sharable of qualities of clean code
Sharable of qualities of clean codeSharable of qualities of clean code
Sharable of qualities of clean code
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
Google Cluster Innards
Google Cluster InnardsGoogle Cluster Innards
Google Cluster Innards
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Recently uploaded (20)

WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in Uganda
 

Elixir and elm - the perfect couple