inertial-frame / elixir_experiments

Elixir experiments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

elixir_experiments

Setup and Installation

Erlang is a required dependency for Elixir. Unfortunately, it can't be installed easily on MacOS.

Therefore, the recommended way is to spin up a Docker instance (with Docker Desktop installed):

$ docker pull elixir
$ docker run elixir

Specifically, grab the Elixir Docker Image from Docker Hub.

The directory elixir-docker contains a variety of examples demonstrating how to work with Elixir programs with a Docker container.

Furthermore, the best approach to editing is probably Visual Studio Code. Make sure to grab the vscode-elixir plugin.

Resources:

  1. https://www.poeticoding.com/running-elixir-in-docker-containers/
  2. https://medium.com/@pentacent/getting-started-with-elixir-docker-982e2a16213c
  3. https://pspdfkit.com/blog/2018/how-to-run-your-phoenix-application-with-docker/

Note: the supplied bash scripts are not intended to be "simply executed" - they are to be walked through line by line. Some, for instance, contain Bash to start a Docker container and Bash to execute within it!

Programming Notes

The other directory elixir_lang contains simple programming (syntax and the like) examples.

Elixir-specific programming notes are described below:

  1. Elixir runs on BEAM (akin to Node or JVM).
  2. To execute compiled Elixir code and copy it into a Docker volume review elixir-docker.
  3. To quickly execute Elixir use an online IDE like jdoodle or repl.it.

Resources:

  1. https://elixir-lang.org/
  2. https://www.tutorialspoint.com/elixir/elixir_loops.htm
  3. https://elixirschool.com/en/lessons/basics/functions/

Mix

Elixir uses a build tool called Mix to compile, package, and manage Elixir programs.

  1. It's similar to webpack and NPM rolled into one.
  2. Or, Gradle and Maven.

An example Mix layout created via:

$ mix new mix_example_1 --module MixExample1
$ docker container run --rm -v $PWD:/data -w /data elixir mix new mix_example_1

is available in elixir-mix.

Resources:

  1. https://hex.pm
  2. https://hexdocs.pm/mix/Mix.html

About

Elixir experiments


Languages

Language:Elixir 56.1%Language:Shell 43.9%