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:
- https://www.poeticoding.com/running-elixir-in-docker-containers/
- https://medium.com/@pentacent/getting-started-with-elixir-docker-982e2a16213c
- 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!
The other directory elixir_lang contains simple programming (syntax and the like) examples.
Elixir-specific programming notes are described below:
- Elixir runs on BEAM (akin to Node or JVM).
- To execute compiled Elixir code and copy it into a Docker volume review elixir-docker.
- To quickly execute Elixir use an online IDE like jdoodle or repl.it.
Resources:
- https://elixir-lang.org/
- https://www.tutorialspoint.com/elixir/elixir_loops.htm
- https://elixirschool.com/en/lessons/basics/functions/
Elixir uses a build tool called Mix to compile, package, and manage Elixir programs.
- It's similar to webpack and NPM rolled into one.
- 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: