SlideShare a Scribd company logo
1 of 33
 Briefly about Elm
 Jump in and swim
– An app onGitHub pages
Your first Elm program
Per Lundholm 1
Per Lundholm Crisp
 How many consider themselves
– Developers?
– Front end developers?
– Back end developers?
– Full stack developers?
Per Lundholm 2
Survey
 I was happilydoing server side rendered web pages with some Ajax
 Then, one day I was no longer a developer, I was a backend developer
 I decided to learn some JavaScript to get backinto doing the whole
thing
Per Lundholm 3
What happened?
 Meteor
 Angular
 React
 React Native
 NativeScript
Per Lundholm 4
JavaScript –what arethou?
 A pure functional languagefor the web
– Compiles to JavaScript
 On the box it says:
– No runtime errors inpractice. No null. No undefined is not a function.
– Friendly errormessages that helpyou add features more quickly.
– Well-architected codethat stayswell-architected as your app grows.
– Automatically enforced semantic versioning for all Elm packages.
Per Lundholm 5
Elm to the rescue
 Afterhobbyhackingandfulltimefor 5months:
– Type safe to the bone, yet lean
• No null,insteadMaybe andhandle both cases
• No exceptions
• No switchwithouthandlingallcases
– When it compiles, it works – in runtime!
• Refactoringguided bythe compiler
– All state in on place, not scattered about in components
– Nice pattern for model, view and update
– Small footprint
– Fast
Per Lundholm 6
Personally,I like
The nice clean world ofElm
Per Lundholm 7
Json Decode/Encode
Port
Safe
REST
JavaScript
 Like most languageElm has
– Strings
• “Agile means good”
– Numbers
• 2 is anintegerand3.14is afloat
– Lists
• [“all”,“has”“tobe”, “same”,“type”]
– Tuples
• (“left”,godzilla,14)
Per Lundholm 11
Let’s do Elm!
Per Lundholm 12
Elm Records
 Please note the syntax for creating a new record based on the current
 Modules
– A module encapsulates its functions and types unless they are exposed (made
public)
– Access other modules by import.
Per Lundholm 13
Elm modules
 Functions
– A function will always return the same result for a given input.
• Getting thetime ofdayorgenerating arandomnumberarenotfunctions.
Per Lundholm 14
Elm functions
 Model
– Theone and only for the whole app across all your pages.
 View
– Theviewis a function that takes the model and presents it.
– If usercan interact with something, it will result in a Message
 Update
– Takes a Message and the Model.
– Creates the next state of the Model.
Per Lundholm 15
Structure of an Elm app
16Per Lundholm
 One ofmyfirstprograms wasa 3x3Tic-tac-
toe
– It learnt by its mistakes.
– Don’t ask me how the board was presented.
 Now,let’sdo thisfortheweb!
Per Lundholm 18
Project: Tic-tac-toe
An 8-bit processor with
2K RAM and I/O. Display:
6 LED numbers.
Hexadecimal keyboard.
 Who has a laptop?
 Of those, who hasprepared their laptops according to the instructions?
– https://crispab.github.io/elm-workshop/
 Who has published to GitHub pages?
Jimmy Janlén &Per Lundholm 19
Status check
 Clone the workshop source.
– git clone https://github.com/crispab/elm-workshop
 Clone your project repository.
– git clone https://github.com/<username>/<project-repository>
– cd <project-repository>
– elm init
– cp ../elm-workshop/index.html .
– cp ../elm-workshop/src/Main.elm src
– cp ../elm-workshop/*.sh .
Per Lundholm 20
Step 0
 Run the project app and see that it works.
– sh run.sh
 Publish it to GitHub pages.
– git push
Per Lundholm 21
Deploy an Elm app
http://localhost:8000
Per Lundholm 22
Walkthrough of theCounter Example
Per Lundholm 23
Per Lundholm 24
Main.elm
index.html
Per Lundholm 25
elm.json
Per Lundholm 26
Step 1a: A flipping button
Per Lundholm 27
Step 1b: Change the face
Per Lundholm 28
Elm’s time-travelling debugger
Per Lundholm 29
Step 1c:Remove string based logic
Per Lundholm 30
Step 1c:Remove string based logic
Per Lundholm 31
Step 2a: Current player
Per Lundholm 32
Step 2b: Change current player
Per Lundholm 33
Step 3a: A board
Per Lundholm 34
Step 3b: Flip message
Per Lundholm 35
Step 3c: Update the board
Per Lundholm 36
 More on the tic-tac-toe
– Determinewinner, play against computer (AI), graphical styling, sound,
arbitrary large board.
 Official guide: https://guide.elm-lang.org/
 Example projects that requires no backend
– Thedice gameof the book “The Goal” by Goldrath
• Showleadtime andthroughput
– Text based adventure game
• The originalfromthe 70’sis available online(see docs)
– Loan calculator
• How much canyouborrowgiven interestandexpenses?
Per Lundholm 37
Epilogue

More Related Content

What's hot

The Search for the Perfect Program
The Search for the Perfect ProgramThe Search for the Perfect Program
The Search for the Perfect ProgramNatallie Baikevich
 
Leiningen 2 - Humane build management for Clojure
Leiningen 2 - Humane build management for ClojureLeiningen 2 - Humane build management for Clojure
Leiningen 2 - Humane build management for ClojureJohn Stevenson
 
Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017Andrey Devyatkin
 
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)danwrong
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneSylvain Zimmer
 
More Productivitiy with Spring Roo
More Productivitiy with Spring RooMore Productivitiy with Spring Roo
More Productivitiy with Spring RooEberhard Wolff
 
Asynchronous job queues with python-rq
Asynchronous job queues with python-rqAsynchronous job queues with python-rq
Asynchronous job queues with python-rqAshish Acharya
 
Deploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDeploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDigitalOcean
 

What's hot (9)

The Search for the Perfect Program
The Search for the Perfect ProgramThe Search for the Perfect Program
The Search for the Perfect Program
 
Leiningen 2 - Humane build management for Clojure
Leiningen 2 - Humane build management for ClojureLeiningen 2 - Humane build management for Clojure
Leiningen 2 - Humane build management for Clojure
 
Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017
 
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
 
Testing Toolbox
Testing ToolboxTesting Toolbox
Testing Toolbox
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
 
More Productivitiy with Spring Roo
More Productivitiy with Spring RooMore Productivitiy with Spring Roo
More Productivitiy with Spring Roo
 
Asynchronous job queues with python-rq
Asynchronous job queues with python-rqAsynchronous job queues with python-rq
Asynchronous job queues with python-rq
 
Deploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDeploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub Actions
 

Similar to Your first Elm program

Leiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojureLeiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojureJohn Stevenson
 
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработкиJS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработкиJSFestUA
 
Pilot Tech Talk #10 — Practical automation by Kamil Cholewiński
Pilot Tech Talk #10 — Practical automation by Kamil CholewińskiPilot Tech Talk #10 — Practical automation by Kamil Cholewiński
Pilot Tech Talk #10 — Practical automation by Kamil CholewińskiPilot
 
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
 
What is Elm and Why Should I Care?
What is Elm and Why Should I Care?What is Elm and Why Should I Care?
What is Elm and Why Should I Care?Claudio D'Alicandro
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the MetalC4Media
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidStanojko Markovik
 
Elm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and WebElm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and WebPublitory
 
Getting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfGetting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfssuserd254491
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakSigma Software
 
Electron - Build desktop apps using javascript
Electron - Build desktop apps using javascriptElectron - Build desktop apps using javascript
Electron - Build desktop apps using javascriptAustin Ogilvie
 
Concurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple SpacesConcurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple Spacesluccastera
 
PHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpPHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpAhmed Abdou
 
The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)danwrong
 
WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014Minko3D
 
How to start your open source project
How to start your open source projectHow to start your open source project
How to start your open source projectEslam Diaa
 

Similar to Your first Elm program (20)

Leiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojureLeiningen2 - humane build management for clojure
Leiningen2 - humane build management for clojure
 
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработкиJS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
 
Pilot Tech Talk #10 — Practical automation by Kamil Cholewiński
Pilot Tech Talk #10 — Practical automation by Kamil CholewińskiPilot Tech Talk #10 — Practical automation by Kamil Cholewiński
Pilot Tech Talk #10 — Practical automation by Kamil Cholewiński
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
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...
 
What is Elm and Why Should I Care?
What is Elm and Why Should I Care?What is Elm and Why Should I Care?
What is Elm and Why Should I Care?
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the Metal
 
Hack Rio/OS
Hack Rio/OSHack Rio/OS
Hack Rio/OS
 
How to Use OpenMP on Native Activity
How to Use OpenMP on Native ActivityHow to Use OpenMP on Native Activity
How to Use OpenMP on Native Activity
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 
Node.js essentials
 Node.js essentials Node.js essentials
Node.js essentials
 
Elm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and WebElm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and Web
 
Getting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfGetting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdf
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr Sugak
 
Electron - Build desktop apps using javascript
Electron - Build desktop apps using javascriptElectron - Build desktop apps using javascript
Electron - Build desktop apps using javascript
 
Concurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple SpacesConcurrent Programming with Ruby and Tuple Spaces
Concurrent Programming with Ruby and Tuple Spaces
 
PHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in phpPHP Mega Meetup, Sep, 2020, Anti patterns in php
PHP Mega Meetup, Sep, 2020, Anti patterns in php
 
The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)
 
WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014
 
How to start your open source project
How to start your open source projectHow to start your open source project
How to start your open source project
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Your first Elm program

  • 1.  Briefly about Elm  Jump in and swim – An app onGitHub pages Your first Elm program Per Lundholm 1 Per Lundholm Crisp
  • 2.  How many consider themselves – Developers? – Front end developers? – Back end developers? – Full stack developers? Per Lundholm 2 Survey
  • 3.  I was happilydoing server side rendered web pages with some Ajax  Then, one day I was no longer a developer, I was a backend developer  I decided to learn some JavaScript to get backinto doing the whole thing Per Lundholm 3 What happened?
  • 4.  Meteor  Angular  React  React Native  NativeScript Per Lundholm 4 JavaScript –what arethou?
  • 5.  A pure functional languagefor the web – Compiles to JavaScript  On the box it says: – No runtime errors inpractice. No null. No undefined is not a function. – Friendly errormessages that helpyou add features more quickly. – Well-architected codethat stayswell-architected as your app grows. – Automatically enforced semantic versioning for all Elm packages. Per Lundholm 5 Elm to the rescue
  • 6.  Afterhobbyhackingandfulltimefor 5months: – Type safe to the bone, yet lean • No null,insteadMaybe andhandle both cases • No exceptions • No switchwithouthandlingallcases – When it compiles, it works – in runtime! • Refactoringguided bythe compiler – All state in on place, not scattered about in components – Nice pattern for model, view and update – Small footprint – Fast Per Lundholm 6 Personally,I like
  • 7. The nice clean world ofElm Per Lundholm 7 Json Decode/Encode Port Safe REST JavaScript
  • 8.  Like most languageElm has – Strings • “Agile means good” – Numbers • 2 is anintegerand3.14is afloat – Lists • [“all”,“has”“tobe”, “same”,“type”] – Tuples • (“left”,godzilla,14) Per Lundholm 11 Let’s do Elm!
  • 9. Per Lundholm 12 Elm Records  Please note the syntax for creating a new record based on the current
  • 10.  Modules – A module encapsulates its functions and types unless they are exposed (made public) – Access other modules by import. Per Lundholm 13 Elm modules
  • 11.  Functions – A function will always return the same result for a given input. • Getting thetime ofdayorgenerating arandomnumberarenotfunctions. Per Lundholm 14 Elm functions
  • 12.  Model – Theone and only for the whole app across all your pages.  View – Theviewis a function that takes the model and presents it. – If usercan interact with something, it will result in a Message  Update – Takes a Message and the Model. – Creates the next state of the Model. Per Lundholm 15 Structure of an Elm app
  • 14.  One ofmyfirstprograms wasa 3x3Tic-tac- toe – It learnt by its mistakes. – Don’t ask me how the board was presented.  Now,let’sdo thisfortheweb! Per Lundholm 18 Project: Tic-tac-toe An 8-bit processor with 2K RAM and I/O. Display: 6 LED numbers. Hexadecimal keyboard.
  • 15.  Who has a laptop?  Of those, who hasprepared their laptops according to the instructions? – https://crispab.github.io/elm-workshop/  Who has published to GitHub pages? Jimmy Janlén &Per Lundholm 19 Status check
  • 16.  Clone the workshop source. – git clone https://github.com/crispab/elm-workshop  Clone your project repository. – git clone https://github.com/<username>/<project-repository> – cd <project-repository> – elm init – cp ../elm-workshop/index.html . – cp ../elm-workshop/src/Main.elm src – cp ../elm-workshop/*.sh . Per Lundholm 20 Step 0
  • 17.  Run the project app and see that it works. – sh run.sh  Publish it to GitHub pages. – git push Per Lundholm 21 Deploy an Elm app
  • 19. Walkthrough of theCounter Example Per Lundholm 23
  • 23. Step 1a: A flipping button Per Lundholm 27
  • 24. Step 1b: Change the face Per Lundholm 28
  • 26. Step 1c:Remove string based logic Per Lundholm 30
  • 27. Step 1c:Remove string based logic Per Lundholm 31
  • 28. Step 2a: Current player Per Lundholm 32
  • 29. Step 2b: Change current player Per Lundholm 33
  • 30. Step 3a: A board Per Lundholm 34
  • 31. Step 3b: Flip message Per Lundholm 35
  • 32. Step 3c: Update the board Per Lundholm 36
  • 33.  More on the tic-tac-toe – Determinewinner, play against computer (AI), graphical styling, sound, arbitrary large board.  Official guide: https://guide.elm-lang.org/  Example projects that requires no backend – Thedice gameof the book “The Goal” by Goldrath • Showleadtime andthroughput – Text based adventure game • The originalfromthe 70’sis available online(see docs) – Loan calculator • How much canyouborrowgiven interestandexpenses? Per Lundholm 37 Epilogue

Editor's Notes

  1. Run.sh kräver elm-live
  2. Look at the Elm code. Look at the index.html Look at the run.sh
  3. Start off with changing the view. We get a compiler error. Add the Flip message. Now the update function is wrong. Fix the update. Compiles!
  4. Let’s add a buttonValue to our model. Interesting compiler error. Create a Model and let init be a function that returns it. Compiles! type defines and names a new type (which behaves like an enum with data attached), and type alias gives a name to an existing type. type alias isn’t creating a distinct type, it is literally just giving a name to an existing type. A type alias will save you keystrokes, but do nothing more. 
  5. Noticed the little black thing in the lower right corner? Click on it. To the left are messages and to the right is the state of the model that resulted from processing the message. Click on them to see the different states.
  6. Using a string for logic is error prone. Let’s introduce a type!
  7. So to get a grip, let’s introduce type declarations for update and view functions.
  8. We wish to show how is next in turn so we will introduce the current player concept in the model. Let’s also make current player part of the button message.
  9. When a player makes a move, then the next player becomes the current player.
  10. We want a 3x3 board, how shall we represent that? There are options but we select a list of lists. We use List.map to display the board.
  11. The Flip message now needs to tell us which cell it was, as there are now 9 and not one. But how do we get the row and column? We use an indexed map!
  12. We want to update the board when someone clicks. So let’s say we have an updateBoard function. First make a empty function. How do you replace a value in a list? We will show you one way. But to set the value in a list of list, we first need to get the list that is the row. Look how we do pattern matching on lists in the case statement. Now we have both set and get so we can update the board.