SlideShare a Scribd company logo
 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 Clojure
John Stevenson
 
Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017Stockholm Jenkins Area Meetup, March 2017
Stockholm Jenkins Area Meetup, March 2017
Andrey 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
 
Testing Toolbox
Testing ToolboxTesting Toolbox
Testing Toolbox
Michael Peters
 
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
Sylvain Zimmer
 
More Productivitiy with Spring Roo
More Productivitiy with Spring RooMore Productivitiy with Spring Roo
More Productivitiy with Spring Roo
Eberhard Wolff
 
Asynchronous job queues with python-rq
Asynchronous job queues with python-rqAsynchronous job queues with python-rq
Asynchronous job queues with python-rq
Ashish Acharya
 
Deploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub ActionsDeploying to DigitalOcean With GitHub Actions
Deploying to DigitalOcean With GitHub Actions
DigitalOcean
 

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 clojure
John 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ński
Pilot
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
Aravindharamanan S
 
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 Metal
C4Media
 
Hack Rio/OS
Hack Rio/OSHack Rio/OS
Hack Rio/OS
Kishore Neelamegam
 
How to Use OpenMP on Native Activity
How to Use OpenMP on Native ActivityHow 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
Stanojko Markovik
 
Node.js essentials
 Node.js essentials Node.js essentials
Node.js essentials
Bedis ElAchèche
 
Elm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and WebElm & Elixir: Functional Programming and Web
Elm & Elixir: Functional Programming and Web
Publitory
 
Getting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdfGetting Started with Ansible - Jake.pdf
Getting Started with Ansible - Jake.pdf
ssuserd254491
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr Sugak
Sigma Software
 
Electron - Build desktop apps using javascript
Electron - Build desktop apps using javascriptElectron - Build desktop apps using javascript
Electron - Build desktop apps using javascript
Austin 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 Spaces
luccastera
 
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
Ahmed 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 project
Eslam 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

Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 

Recently uploaded (20)

Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 

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.