SlideShare uma empresa Scribd logo
1 de 20
Make Yourself a Happy Front-end
Web Developer with Elm
ASEP BAGJA PRIANDANA | FROYO FRAMEWORK
What do Programmers Want?
Usable
(time to novice to product)
Maintainable
(ease of adding new feature)
ML Family
(SML, OCaml, Haskell)
JavaScript
JavaX
X
Gradual type?
Why Elm?
A functional programming language that compiles to JavaScript
Front-end web development without runtime error exception
Friendly error messages
Every function is curried function by default
Why Functional Programming Matter?
Immutability
Pure function or stateless function
Safe code means reliable code
It's easy to refactor
The Tooling
elm-repl, for playing with simple expression
elm-reactor, for building an elm project without cli
elm-make, compiler for the elm code
elm-package, for handling the dependencies
The Elm Architecture
View View View
Update Update UpdateModel Model Model
functions
functions
types
Actions types
The Syntax: Elm vs
JavaScript
COMPARING BETWEEN TWO LANGUAGES
Comments
ELM
-- single comment
{- multiline comment
{- can be nested -}
-}
JAVASCRIPT
// single comment
/* multiline comment
line 2
*/
Literals
ELM
True : Bool
False : Bool
21 : number -- Can be Int or Float
3.14 : Float
‘a’ : Char
“abc” : String
“””
This is multiline string
Oh yeah multiline
“””
JAVASCRIPT
true // bool
false // bool
21 // number
3.14 // number
‘a’ // string
“abc” // string
`This is multiline string
By using ES6 template string`
Variables
ELM
let
length = 12
wide = 5
in
length * wide
JAVASCRIPT
let length = 12, // ES6
wide = 5;
length * wide;
Conditional
ELM
if age > 42 then
“You are considered old”
else
“You are still young”
JAVASCRIPT
age > 42 ?
“You are considered old”
:
“You are still young”;
// the closest form of condition
// in JS with the same behaviour as
// Elm is using ternary operator
List in Elm and Array in JS
ELM
[1..4]
[1,2,3,4]
1 :: [2,3,4]
1 :: 2 :: 3 :: 4 :: []
JAVASCRIPT
[1,2,3,4]
Records in Elm and Object in JS
ELM
-- create
user = { name = “Tom”, age = 23 }
-- access field
user.name
-- update fields
{ user |
name = “Jerry”,
age = 26
}
JAVASCRIPT
-- create
const User = { name: “Tom”, age: 23};
-- access field
User.name
-- update fields
User.name = “Jerry”;
User.age = 26;
Function and Anonymous Function
ELM
-- define function
totalPrice discount price =
price – (discount * price)
-- invoke function
totalPrice 0.5 15000
-- anonymous function
n -> String.toUpper n
JAVASCRIPT
-- define function
function totalPrice(discount, price) {
return price – (discount * price);
}
-- invoke function
totalPrice(0.5, 15000);
-- anonymous function
(n) => n.toUpperCase(); // ES6
function(n) { return n.toUpperCase(); }; // ES5
Type Signature
ELM
calculate : Int -> Int -> Int
calculate x y =
let squareX = x ^ 2
squareY = y ^ 2
in squareX + squareY
JAVASCRIPT
// There’s no such thing like this in
// JS
Function Composition
ELM
formatting : String -> List String
formatting yourname =
yourname
|> String.toLower
|> String.trim
|> String.split “ “
JAVASCRIPT
// by default it does not exist in JS
// unless we use functional programming
// library such as Ramda
Elm and JavaScript
Interop
WHAT HAPPENS IN JAVASCRIPT STAY IN JAVASCRIPT.
Two Ways to Interop
PORTS
We can consider it as a hole inside the Elm
program for sending the value ins and outs
Sending values out to JS is a command
Listening values coming in from JS is a
subscription.
FLAGS
It’s more like a static configuration for the Elm
program
How to Use Elm in Production?
Have an advocate in your team
Start small
Fix a problem
Write Elm code
Contact Me
Email: asep@froyo.co.id
Framework’s web: http://www.framework.id
Personal’s web: http://www.asep.co
You can find the source code on this presentation at:
https://github.com/froyoframework/basic-elm-sample
https://github.com/froyoframework/elm-shopping-cart-sample

Mais conteúdo relacionado

Mais procurados

Anatomy of a Reactive Application
Anatomy of a Reactive ApplicationAnatomy of a Reactive Application
Anatomy of a Reactive ApplicationMark Wilson
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
 
Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in javaJason O'Regan
 
Asynchronous development in JavaScript
Asynchronous development  in JavaScriptAsynchronous development  in JavaScript
Asynchronous development in JavaScriptAmitai Barnea
 
Workshop JavaScript ES6+
Workshop JavaScript ES6+Workshop JavaScript ES6+
Workshop JavaScript ES6+Roy Derks
 
Generating ephermal values in ansible
Generating ephermal values in ansibleGenerating ephermal values in ansible
Generating ephermal values in ansibleDavid Karban
 
Asynchronous Programming in .NET
Asynchronous Programming in .NETAsynchronous Programming in .NET
Asynchronous Programming in .NETPierre-Luc Maheu
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? reactima
 
Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.Anton Mishchuk
 
Declarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetationDeclarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetationOm Shankar
 
How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...Codemotion
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++Jenish Patel
 
Inline and lambda function
Inline and lambda functionInline and lambda function
Inline and lambda functionJawad Khan
 

Mais procurados (20)

Anatomy of a Reactive Application
Anatomy of a Reactive ApplicationAnatomy of a Reactive Application
Anatomy of a Reactive Application
 
Callback Function
Callback FunctionCallback Function
Callback Function
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in java
 
Asynchronous development in JavaScript
Asynchronous development  in JavaScriptAsynchronous development  in JavaScript
Asynchronous development in JavaScript
 
Workshop JavaScript ES6+
Workshop JavaScript ES6+Workshop JavaScript ES6+
Workshop JavaScript ES6+
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
Ruby Blocks
Ruby BlocksRuby Blocks
Ruby Blocks
 
Generating ephermal values in ansible
Generating ephermal values in ansibleGenerating ephermal values in ansible
Generating ephermal values in ansible
 
Asynchronous Programming in .NET
Asynchronous Programming in .NETAsynchronous Programming in .NET
Asynchronous Programming in .NET
 
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
 
Let's migrate to Swift 3.0
Let's migrate to Swift 3.0Let's migrate to Swift 3.0
Let's migrate to Swift 3.0
 
Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.
 
Declarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetationDeclarative JavaScript concepts and implemetation
Declarative JavaScript concepts and implemetation
 
C++basics
C++basicsC++basics
C++basics
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
 
How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Coffee script
Coffee scriptCoffee script
Coffee script
 
Inline and lambda function
Inline and lambda functionInline and lambda function
Inline and lambda function
 

Destaque

track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...
track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...
track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...양 한빛
 
Flask! - python web framework flask 튜토리얼
Flask! - python web framework flask 튜토리얼Flask! - python web framework flask 튜토리얼
Flask! - python web framework flask 튜토리얼mangonamu
 
Emotional manifestation in children 2
Emotional manifestation in children 2Emotional manifestation in children 2
Emotional manifestation in children 2sri yunie
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web developmentAmir Barylko
 
E言語スタック
E言語スタックE言語スタック
E言語スタックhayabusa333
 
파이썬 플라스크 이해하기
파이썬 플라스크 이해하기 파이썬 플라스크 이해하기
파이썬 플라스크 이해하기 Yong Joon Moon
 

Destaque (13)

track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...
track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...
track1 05. 스타트업 1인 개발 극복기’와 ‘javascript vs Scala, (함수형 언어 관점으로)방황기/ I/O Inc, ...
 
Flask! - python web framework flask 튜토리얼
Flask! - python web framework flask 튜토리얼Flask! - python web framework flask 튜토리얼
Flask! - python web framework flask 튜토리얼
 
Emotional manifestation in children 2
Emotional manifestation in children 2Emotional manifestation in children 2
Emotional manifestation in children 2
 
Elm: give it a try
Elm: give it a tryElm: give it a try
Elm: give it a try
 
Play with Elm!
Play with Elm!Play with Elm!
Play with Elm!
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web development
 
Elm 101
Elm 101Elm 101
Elm 101
 
Functional Web Development using Elm
Functional Web Development using ElmFunctional Web Development using Elm
Functional Web Development using Elm
 
E言語スタック
E言語スタックE言語スタック
E言語スタック
 
Elm
ElmElm
Elm
 
플라스크 템플릿
플라스크 템플릿플라스크 템플릿
플라스크 템플릿
 
파이썬 플라스크 이해하기
파이썬 플라스크 이해하기 파이썬 플라스크 이해하기
파이썬 플라스크 이해하기
 
Elm intro
Elm introElm intro
Elm intro
 

Semelhante a Elm: Make Yourself A Happy Front-end Web Developer

Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocamlpramode_ce
 
The... Wonderful? World of Lambdas
The... Wonderful? World of LambdasThe... Wonderful? World of Lambdas
The... Wonderful? World of LambdasEsther Lozano
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascriptguest4d57e6
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)Piyush Katariya
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express jsAhmed Assaf
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to JavascriptAnjan Banda
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScriptMark Shelton
 
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...Akaks
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
Elm, the runtime error killer
Elm, the runtime error killerElm, the runtime error killer
Elm, the runtime error killerJordy Moos
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Hermann Hueck
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programsKranthi Kumar
 

Semelhante a Elm: Make Yourself A Happy Front-end Web Developer (20)

Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
 
Elm @ DublinJS
Elm @ DublinJSElm @ DublinJS
Elm @ DublinJS
 
The... Wonderful? World of Lambdas
The... Wonderful? World of LambdasThe... Wonderful? World of Lambdas
The... Wonderful? World of Lambdas
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascript
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
 
[2015/2016] JavaScript
[2015/2016] JavaScript[2015/2016] JavaScript
[2015/2016] JavaScript
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Ocl 09
Ocl 09Ocl 09
Ocl 09
 
Modern frontend in react.js
Modern frontend in react.jsModern frontend in react.js
Modern frontend in react.js
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
Wien15 java8
Wien15 java8Wien15 java8
Wien15 java8
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
 
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Elm, the runtime error killer
Elm, the runtime error killerElm, the runtime error killer
Elm, the runtime error killer
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
 

Último

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Elm: Make Yourself A Happy Front-end Web Developer

  • 1. Make Yourself a Happy Front-end Web Developer with Elm ASEP BAGJA PRIANDANA | FROYO FRAMEWORK
  • 2. What do Programmers Want? Usable (time to novice to product) Maintainable (ease of adding new feature) ML Family (SML, OCaml, Haskell) JavaScript JavaX X Gradual type?
  • 3. Why Elm? A functional programming language that compiles to JavaScript Front-end web development without runtime error exception Friendly error messages Every function is curried function by default
  • 4. Why Functional Programming Matter? Immutability Pure function or stateless function Safe code means reliable code It's easy to refactor
  • 5. The Tooling elm-repl, for playing with simple expression elm-reactor, for building an elm project without cli elm-make, compiler for the elm code elm-package, for handling the dependencies
  • 6. The Elm Architecture View View View Update Update UpdateModel Model Model functions functions types Actions types
  • 7. The Syntax: Elm vs JavaScript COMPARING BETWEEN TWO LANGUAGES
  • 8. Comments ELM -- single comment {- multiline comment {- can be nested -} -} JAVASCRIPT // single comment /* multiline comment line 2 */
  • 9. Literals ELM True : Bool False : Bool 21 : number -- Can be Int or Float 3.14 : Float ‘a’ : Char “abc” : String “”” This is multiline string Oh yeah multiline “”” JAVASCRIPT true // bool false // bool 21 // number 3.14 // number ‘a’ // string “abc” // string `This is multiline string By using ES6 template string`
  • 10. Variables ELM let length = 12 wide = 5 in length * wide JAVASCRIPT let length = 12, // ES6 wide = 5; length * wide;
  • 11. Conditional ELM if age > 42 then “You are considered old” else “You are still young” JAVASCRIPT age > 42 ? “You are considered old” : “You are still young”; // the closest form of condition // in JS with the same behaviour as // Elm is using ternary operator
  • 12. List in Elm and Array in JS ELM [1..4] [1,2,3,4] 1 :: [2,3,4] 1 :: 2 :: 3 :: 4 :: [] JAVASCRIPT [1,2,3,4]
  • 13. Records in Elm and Object in JS ELM -- create user = { name = “Tom”, age = 23 } -- access field user.name -- update fields { user | name = “Jerry”, age = 26 } JAVASCRIPT -- create const User = { name: “Tom”, age: 23}; -- access field User.name -- update fields User.name = “Jerry”; User.age = 26;
  • 14. Function and Anonymous Function ELM -- define function totalPrice discount price = price – (discount * price) -- invoke function totalPrice 0.5 15000 -- anonymous function n -> String.toUpper n JAVASCRIPT -- define function function totalPrice(discount, price) { return price – (discount * price); } -- invoke function totalPrice(0.5, 15000); -- anonymous function (n) => n.toUpperCase(); // ES6 function(n) { return n.toUpperCase(); }; // ES5
  • 15. Type Signature ELM calculate : Int -> Int -> Int calculate x y = let squareX = x ^ 2 squareY = y ^ 2 in squareX + squareY JAVASCRIPT // There’s no such thing like this in // JS
  • 16. Function Composition ELM formatting : String -> List String formatting yourname = yourname |> String.toLower |> String.trim |> String.split “ “ JAVASCRIPT // by default it does not exist in JS // unless we use functional programming // library such as Ramda
  • 17. Elm and JavaScript Interop WHAT HAPPENS IN JAVASCRIPT STAY IN JAVASCRIPT.
  • 18. Two Ways to Interop PORTS We can consider it as a hole inside the Elm program for sending the value ins and outs Sending values out to JS is a command Listening values coming in from JS is a subscription. FLAGS It’s more like a static configuration for the Elm program
  • 19. How to Use Elm in Production? Have an advocate in your team Start small Fix a problem Write Elm code
  • 20. Contact Me Email: asep@froyo.co.id Framework’s web: http://www.framework.id Personal’s web: http://www.asep.co You can find the source code on this presentation at: https://github.com/froyoframework/basic-elm-sample https://github.com/froyoframework/elm-shopping-cart-sample