Compile vs Runtime Evaluation in Elixir

less than 1 minute read

Elixir despite being a compiled language, it somehow behaves like an interpreted language. For instance Usually you would not put an Application.get_env or System.get_env call as a module attribute since it is evaluated at compile time and usually you are looking to have these things configured at run-time.

Compile vs Runtime evaluation can results in issues in different production environments, at times what you really want is for example an environment variable to be evaluated at runtime, instead of at compile-time or the other way around.

For more information on this topic you can checkout the following amazing posts:

  1. Configuring your Elixir Application at Runtime with Vapor
  2. Elixir: Runtime vs. compile time configuration
  3. Understanding Compile Time Dependencies in Elixir - A Bug Hunt
  4. Speeding up re-compilation of Elixir projects