this repo has no description
1+++ 2title = "Erlang in Mix" 3date = 2019-07-24T12:32:07+02:00 4draft = true 5+++ 6 7Currently there are 3 main build tools in BEAM world: 8 9- Rebar3 - de facto standard in Erlang and other languages (with exception to 10 Elixir). Uses declarative `rebar.config` file (which is in `file:consult/1` 11 format) that can be then formatted via `rebar.config.script` Erlang script. 12- Mix - standard build tool in Elixir world. Uses imperative `mix.exs` file. 13- erlang.mk - GNU Make based tool. Uses it's own registry and is mostly known as 14 tool used by Cowboy. 15 16In this article I will cover only first two and their comparison when it comes 17to support building mostly Erlang projects (AFAIK `rebar3` do not have yet 18support for building Elixir projects, mostly because Elixir cannot be used as 19Erlang library). 20 21## Declarative vs imperative 22 23Accordingly to [Wikipedia][declarative programming]: 24 25> In computer science, declarative programming is a programming paradigm—a style 26> of building the structure and elements of computer programs—that expresses the 27> logic of a computation without describing its control flow. 28 29In other words, we only describe **what** without focusing on **how**. This mean 30that we have less direct control over our configuration while requiring less 31knowledge to configure properly. 32 33At the same time it is (in theory) more secure, as imagine that you would have 34dependency with such `mix.exs`: 35 36```elixir 37defmodule TotallySafeLibrary.Mixfile do 38 use Mix.Project 39 40 # HAHAHA I lied!!! Pwnd MF 41 File.rm_rf!(System.user_home()) 42 43 # … 44end 45``` 46 47I mean, this is still possible in Rebar via `rebar.config.script`, but it is 48much harder due to 2 reasons: 49 50- There is no such function like `File.rm_rf!/1` in Erlang, so the end user 51 would need to write their own. 52- It is much easier to spot additional file in the repo than review whole one 53 file. 54 55The same goes for `.app.src` file, which while having more "abstract" format 56than Mix's `application/0` function ends much simpler without all imperativeness 57brought by making configuration file executable script. 58 59## Tasks