SI 413 Fall 2023 / Project


This is the archived website of SI 413 from the Fall 2023 semester. Feel free to browse around; you may also find more recent offerings at my teaching page.

Elixir

Elixir is a functional programming language (like Scheme, Lisp, or Haskell) that is designed for robust, concurrent programming. It is based on an older language called Erlang which was designed by the telecommunications company Ericsson. In fact, Elixir code runs on the Erlang virtual machine. One of the most amazing and unique features of this language is that you can "hot-swap" modules at runtime. That means that, while an application is running, you can change out the way some piece of it works. Sounds useful if you're hosting a website or running a telecom!

Useful Links

  • The Getting Started Guide is a good place to do that.
  • Many more resources are available here, including a book that you should be able to get for free using your usna.edu email address.
  • Wikipedia page
  • Here is a 99 bottles of beer program you can use:
    defmodule Bottles do
      @moduledoc """
      Will print the lyrics for the song 99 bottles of beer on the wall.
      Original source: Martin Gausby, https://gist.github.com/gausby/7b31d00bea9e97cf416e
      """
    
      def create_stream(bottles..stop) do
        Stream.map(bottles..stop, &sing/1)
      end
    
      defp sing(0), do: "No more bottles of beer on the wall, no more bottles of beer.\n#{take_beer(0)}"
      defp sing(1), do: "1 bottle of beer on the wall, 1 bottle of beer.\n#{take_beer(1)}"
      defp sing(n) when is_integer(n) and n > 0 do
        "#{n} bottles of beer on the wall, #{n} bottles of beer.\n#{take_beer(n)}"
      end
    
      defp take_beer(0), do: "Go to the store and buy some more, 99 bottles of beer on the wall.\n"
      defp take_beer(1), do: "Take one down and pass it around, no more bottles of beer on the wall.\n"
      defp take_beer(2), do: "Take one down and pass it around, 1 bottle of beer on the wall.\n"
      defp take_beer(n) when is_integer(n) and n > 0 do
        "Take one down and pass it around, #{n - 1} bottles of beer on the wall.\n"
      end
    
      def main() do
        create_stream(99..0) |> Enum.map(&IO.puts/1)
      end
    end
    
    Bottles.main()

Tools

We will be using Elixir version 1.9.

Everything you need is already installed on CS department lab machines.

To install on your virtual machine, run these commands (copied from the official page here):

wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && sudo dpkg -i erlang-solutions_2.0_all.deb
sudo apt update
sudo apt install esl-erlang
sudo apt install elixir

How I will run your code

The programs you submit should be in a single file called proj.exs, for either part of the project. I will test your code by running the following commands using the software available in the lab environment or using the instructions above:

elixir proj.exs

Note: I strongly recommend you follow the bottles of beer program above and create a module with a main function (and possibly other modules too), and then just have one line outside of the module that calls your main() to run the program.

Phase 1 Requirements

For this language, you need to implement modifications B, C, F, H, and I. 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 Elixir:

  1. Make
  2. TODO list
  3. Game with hidden agenda
  4. Guess the language
  5. Sports Ticker
  6. Rock, Paper, Scissors (would need to make it multi-player)
  7. ??? (you choose!)