After releasing Elixir 1.8 in January, the team behind Elixir announced the release of Elixir 1.9 yesterday. This comes with a new ‘releases’ feature, the Config API for streamlined configuration, plus many other enhancements and bug fixes. Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang VM.
Releases, a single unit for code and the runtime
Releases are the most important feature that has landed in this version. A release is a “self-contained directory” that encapsulates not only your application code and its dependencies but also the whole Erlang VM and runtime.
So, basically, it allows you to precompile and package your code and runtime in a single unit. You can then deploy this single unit to a target that is running on the same OS distribution and version as the machine running the ‘mix release’ command.
Following are some of the benefits ‘releases’ provide:
- Code preloading: As releases run in embedded mode for loading code it loads all the modules beforehand. This makes your system ready for handling requests right after booting.
- Configuration and customization: It gives you “fine-grained control” over system configuration and the VM flags for starting the system.
- Multiple releases: It allows you to assemble different releases of the same application with different configurations.
- Management scripts: It provides management scripts to start, restart, connect to the running system remotely, execute RPC calls, run in daemon mode, run in Windows service mode, and more.
Releases are also the last planned feature for Elixir and the team is not planning to add any other user-facing feature in the near future. The Elixir team shared in the announcement, “Of course, it does not mean that v1.9 is the last Elixir version. We will continue shipping new releases every 6 months with enhancements, bug fixes, and improvements.”
A streamlined configuration API
This version comes with a more streamlined Elixir’s configuration API in the form of a new ‘Config’ module. Previously, the ‘Mix.Config’ configuration API was part of the Mix build tool. Beginning Elixir 1.9, the runtime configuration is now taken care of by ‘releases’ and Mix is no longer included in ‘releases’, this API is now ported to Elixir. “In other words, ‘use Mix.Config’ has been soft-deprecated in favor of import Config,” the announcement reads.
Another crucial change in configuration is that starting from this release the ‘mix new’ command will not generate a ‘config/config.exs’ file. The ‘mix new –umbrella’ will also not generate a configuration for each child app as the configuration is now moved from individual umbrella application to the root of the umbrella.
Many developers are excited about the ‘releases’ support. One user praised the feature saying, “Even without the compilation and configuration stuff, it’s easier to put the release bundle in something basic like an alpine image, rather than keep docker image versions and app in sync.”
However, as many of them currently rely on the Distillery tool for deployment they have some reservations about using releases as it lacks some of the features Distillery provides. “Elixir’s `mix release` is intended to replace (or remove the need for) third-party packages like Distillery. However, it’s not there yet, and Distillery is strictly more powerful at the moment. Notably, Elixir’s release implementation does not support hot code upgrades. I use upgrades all the time, and won’t be trying out Elixir’s releases until this shortcoming is addressed,” a Hacker News user commented.
Public opinion on Twitter was also positive:
Spent the afternoon learning releases introduced in Elixir 1.9
Finally have working solution for two different Phoenix instances (environments) utilizing GitLabCI 🎉😍
Using simple shell commands & ssh 😅 Ecto migrations included 😀https://t.co/mOvubOpSo8#myelixirstatus pic.twitter.com/FskSv4zTuO
— Jaromír Červenka (@C3rvajz) June 16, 2019
With the release of Elixir 1.9, there has never been a better time to get started with the language!
If you are an experienced programmer who likes a just-give-to-me/no-frills-introduction, I recommend https://t.co/tuGczdC8OB which I used to learn Elixir back in the day.
— René Föhring (@rrrene) June 25, 2019