Elm
Elm is a purely functional language that is designed exclusively for making JavaScript-based web apps.
Due to the strong typing and purely functional paradigm, Elm claims to have zero run-time errors. That is, if your Elm code compiles, then the resulting JavaScript should never have a problem.
This is a pretty bold claim, but it seems to work out! The downside is that Elm programming looks very different from JavaScript or C. The upside is that the documentation and learning guides are truly excellent, and your familiarity with Scheme will get you most of the way there.
Useful Links
- Elm homepage
- The Elm introductory guide is impressively well-written. You can tell that the original creator of Elm now works for an online educational resources company.
- Wikipedia page
- I couldn't find any 99 bottles of beer program with the fully-correct
lyrics, so I modified one and here it is:
-- Original source: https://rosettacode.org/wiki/99_bottles_of_beer#Elm -- Modified to match the "correct" lyrics and formatting by Dan Roche, 2021 module Proj exposing (main) import Html main = List.range 0 99 |> List.reverse |> List.map (\n -> let bottles beers cap = if beers == 0 then (if cap then "N" else "n") ++ "o more bottles" else String.fromInt beers ++ " bottle" ++ (if beers > 1 then "s" else "") nString = bottles n n1String = bottles (if n > 0 then n - 1 else 99) action = if n > 0 then "Take one down and pass it around" else "Go to the store and buy some more" in [ nString True ++ " of beer on the wall, " ++ nString False ++ " of beer." , action ++ ", " ++ n1String False ++ " of beer on the wall." ] |> List.map Html.text |> List.intersperse (Html.br [] []) |> Html.p [] ) |> Html.div []
Tools
We will use the Elm reference compiler, version available on github, version 0.19.1.
Everything you need is already installed on CS department lab machines
in the /courses/roche/413/bin
folder, which should be in your
PATH.
To install on your virtual machine, follow the steps
in this install guide.
(Aside: like the Elm language guide itself, these installer instructions are incredibly
beginner-friendly and clear. Reading the Elm documentation makes me (Dr. Roche) think harder about
how to make educational guides for my classes.)
How I will run your code
Elm is a bit unusual since your code will not run directly or compile to machine code, but instead your Elm program compiles to HTML and JavaScript, which is then run in a web browser.
To use the elm
compiler you need to have an entire folder, but I want you to
keep all of your code in one file called Proj.elm and submit that
Here is how I will compile your Proj.elm
program into a web page:
mkdir -p proj/src
cp Proj.elm proj/src/
cd proj
elm make src/Proj.elm
Running these commands should create an index.html
file, which I will
then open in a Chrome web browser to test your code.
Phase 1 Requirements
For this language, you need to implement modifications B,C,G, and J. See the Phase 1 page for details on what this means.
Phase 2
See the Phase 2 Page for the list of suggested
problems. Of the ones listed, I recommend the following as being most
well-suited for LANGUAGE:
- Image Creator
- Hangman
- TODO list
- Game with hidden agenda
- Sports Ticker
- Music Maker
- ??? (you choose!)