|
1 | 1 | # Changelog for Elixir v1.9
|
2 | 2 |
|
| 3 | +## Releases |
| 4 | + |
| 5 | +The main feature in Elixir v1.9 is the addition of releases. A release is a self-contained directory that consists of your application code, all of its dependencies, plus the whole Erlang Virtual Machine (VM) and runtime. Once a release is assembled, it can be packaged and deployed to a target as long as the target runs on the same operating system (OS) distribution and version as the machine running the `mix release` command. |
| 6 | + |
| 7 | +You can start a new project and assemble a release for it in three easy steps: |
| 8 | + |
| 9 | + $ mix new my_app |
| 10 | + $ cd my_app |
| 11 | + $ MIX_ENV=prod mix release |
| 12 | + |
| 13 | +A release will be assembled in `_build/prod/rel/my_app`. Inside the release, there will be a `bin/my_app` file which is the entry point to your system. It supports multiple commands, such as: |
| 14 | + |
| 15 | + * `bin/my_app start`, `bin/my_app start_iex`, `bin/my_app restart`, and `bin/my_app stop` - for general management of the release |
| 16 | + |
| 17 | + * `bin/my_app rpc COMMAND` and `bin/my_app remote` - for running commands on the running system or to connect to the running system |
| 18 | + |
| 19 | + * `bin/my_app eval COMMAND` - to start a fresh system that runs a single command and then shuts down |
| 20 | + |
| 21 | + * `bin/my_app daemon` and `bin/my_app daemon_iex` - to start the system as a daemon on Unix-like systems |
| 22 | + |
| 23 | + * `bin/my_app install` - to install the system as a service on Windows machines |
| 24 | + |
| 25 | +### Why releases? |
| 26 | + |
| 27 | +Releases allow developers to precompile and package all of their code and the runtime into a single unit. The benefits of releases are: |
| 28 | + |
| 29 | + * Code preloading. The VM has two mechanisms for loading code: interactive and embedded. By default, it runs in the interactive mode which dynamically loads modules when they are used for the first time. The first time your application calls `Enum.map/2`, the VM will find the `Enum` module and load it. There’s a downside. When you start a new server in production, it may need to load many other modules, causing the first requests to have an unusual spike in response time. Releases run in embedded mode, which loads all available modules upfront, guaranteeing your system is ready to handle requests after booting. |
| 30 | + |
| 31 | + * Configuration and customization. Releases give developers fine grained control over system configuration and the VM flags used to start the system. |
| 32 | + |
| 33 | + * Self-contained. A release does not require the source code to be included in your production artifacts. All of the code is precompiled and packaged. Releases do not even require Erlang or Elixir in your servers, as they include the Erlang VM and its runtime by default. Furthermore, both Erlang and Elixir standard libraries are stripped to bring only the parts you are actually using. |
| 34 | + |
| 35 | + * Multiple releases. You can assemble different releases with different configuration per application or even with different applications altogether. |
| 36 | + |
| 37 | +### Hooks and Configuration |
| 38 | + |
| 39 | +Releases also provide built-in hooks for configuring almost every need of the production system: |
| 40 | + |
| 41 | + * `config/config.exs` (and `config/prod.exs`) - provides build-time application configuration, which is executed when the release is assembled |
| 42 | + |
| 43 | + * `config/releases.exs` - provides runtime application configuration. It is executed every time the release boots and is further extensible via config providers |
| 44 | + |
| 45 | + * `rel/vm.args.eex` - a template file that is copied into every release and provides static configuration of the Erlang Virtual Machine and other runtime flags |
| 46 | + |
| 47 | + * `rel/env.sh.eex` and `rel/env.bat.eex` - template files that are copied into every release and executed on every command to set up environment variables, including ones specific to the VM, and the general environment |
| 48 | + |
| 49 | +We have written extensive documentation on releases, so we recommend checking it out for more information. |
| 50 | + |
| 51 | +## Configuration overhaul |
| 52 | + |
| 53 | +A new `Config` module has been added to Elixir. The previous configuration API, `Mix.Config`, was part of the Mix build tool. But since releases provide runtime configuration and Mix is not included in releases, we ported the `Mix.Config` API to Elixir. In other words, `use Mix.Config` has been soft-deprecated in favor of `import Config`. |
| 54 | + |
| 55 | +Another important change related to configuration is that `mix new` will no longer generate a `config/config.exs` file. [Relying on configuration is undesired for most libraries](https://hexdocs.pm/elixir/library-guidelines.html#avoid-application-configuration) and the generated config files pushed library authors in the wrong direction. Furthermore, `mix new --umbrella` will no longer generate a configuration for each child app, instead all configuration should be declared in the umbrella root. That's how it has always behaved, we are now making it explicit. |
| 56 | + |
| 57 | +## Other enhancements |
| 58 | + |
| 59 | +There are many other enhancements. The Elixir CLI got a handful of new options in order to best support releases. `Logger` now computes its sync/async/discard thresholds in a decentralized fashion, reducing contention. `EEx` templates support more complex expressions than before. Finally, there is a new `~U` sigil for working with UTC DateTimes as well as new functions in the `File`, `Registry`, and `System` modules. |
| 60 | + |
3 | 61 | ## v1.9.0-dev
|
4 | 62 |
|
5 | 63 | ### 1. Enhancements
|
|
15 | 73 | * [Code] Add `static_atom_encoder` option to `Code.string_to_quoted/2`
|
16 | 74 | * [Code] Support `:force_do_end_blocks` on `Code.format_string!/2` and `Code.format_file!/2`
|
17 | 75 | * [Code] Do not raise on deadlocks on `Code.ensure_compiled/1`
|
18 |
| - * [Config] Add `Config`, `Config.Reader` and `Config.Provider` modules for working with configuration |
| 76 | + * [Config] Add `Config`, `Config.Reader`, and `Config.Provider` modules for working with configuration |
19 | 77 | * [File] Add `File.rename!/2`
|
20 |
| - * [Inspect] Add `:inspect_fun` to `Inspect.Opts` |
| 78 | + * [Inspect] Add `:inspect_fun` and `:custom_options` to `Inspect.Opts` |
21 | 79 | * [Kernel] Add `~U` sigil for UTC date times
|
22 | 80 | * [Kernel] Optimize `&super/arity` and `&super(&1)`
|
23 | 81 | * [Kernel] Optimize generated code for `with` with a catch-all clause
|
|
26 | 84 | * [Protocol] Improve `Protocol.UndefinedError` messages to also include the type that was attempted to dispatch on
|
27 | 85 | * [Protocol] Optimize performance of dynamic dispatching for non-consolidated protocols
|
28 | 86 | * [Record] Include field names in generated type for records
|
| 87 | + * [Regex] Automatically recompile regexes |
29 | 88 | * [Registry] Add `Registry.select/2`
|
30 | 89 | * [System] Add `System.restart/0`, `System.pid/0` and `System.no_halt/1`
|
31 | 90 | * [System] Add `System.get_env/2`, `System.fetch_env/1`, and `System.fetch_env!/1`
|
|
35 | 94 |
|
36 | 95 | * [ExUnit] Allow multiple `:exclude` on configuration/CLI
|
37 | 96 | * [ExUnit.DocTest] No longer wrap doctest errors in custom exceptions. They ended-up hiding more information than showing
|
38 |
| - * [ExUnit.DocTest] Display the actual doctest code when doctset fails |
| 97 | + * [ExUnit.DocTest] Display the actual doctest code when doctest fails |
39 | 98 |
|
40 | 99 | #### IEx
|
41 | 100 |
|
42 |
| - * [IEx.CLI] Copy ticktime from remote node on IEx --remsh |
43 |
| - * [IEx.CLI] Automatically add a host on node given to --remsh |
| 101 | + * [IEx.CLI] Copy ticktime from remote node on IEx `--remsh` |
| 102 | + * [IEx.CLI] Automatically add a host on node given to `--remsh` |
44 | 103 |
|
45 | 104 | #### Logger
|
46 | 105 |
|
|
75 | 134 | * [Kernel] Keep order of elements when macro `in/2` is expanded with a literal list on the right-hand side
|
76 | 135 | * [Kernel] Print proper location on undefined function error from dynamically generated functions
|
77 | 136 | * [System] Make sure `:init.get_status/0` is set to `{:started, :started}` once the system starts
|
| 137 | + * [Path] Do not expand `~` in `Path.expand/2` when not followed by a path separator |
78 | 138 | * [Protocol] Ensure `debug_info` is kept in protocols
|
79 | 139 | * [Regex] Ensure inspect returns valid `~r//` expressions when they are manually compiled with backslashes
|
80 | 140 | * [Registry] Fix ETS leak in `Registry.register/2` for already registered calls in unique registries while the process is still alive
|
81 | 141 |
|
82 | 142 | #### ExUnit
|
83 | 143 |
|
84 | 144 | * [ExUnit] Raise error if attempting to run single line tests on multiple files
|
| 145 | + * [ExUnit] Return proper error on duplicate child IDs on `start_supervised` |
85 | 146 |
|
86 | 147 | #### IEx
|
87 | 148 |
|
88 | 149 | * [IEx] Automatically shut down IEx if we receive EOF
|
89 | 150 |
|
| 151 | +#### Logger |
| 152 | + |
| 153 | + * [Logger] Don't discard Logger messages from other nodes as to leave a trail on both systems |
| 154 | + |
90 | 155 | #### Mix
|
91 | 156 |
|
92 | 157 | * [mix compile] Ensure Erlang-based Mix compilers (erlang, leex, yecc) set valid position on diagnostics
|
93 | 158 | * [mix compile] Ensure compilation halts in an umbrella project if one of the siblings fail to compile
|
| 159 | + * [mix deps] Raise an error if the umbrella app's dir name and `mix.exs` app name don't match |
94 | 160 | * [mix test] Do not consider modules that are no longer cover compiled when computing coverage report, which could lead to flawed reports
|
95 | 161 |
|
96 | 162 | ### 3. Soft-deprecations (no warnings emitted)
|
|
105 | 171 |
|
106 | 172 | * [CLI] Deprecate `--detached` option, use `--erl "-detached"` instead
|
107 | 173 | * [Map] Deprecate Enumerable keys in `Map.drop/2`, `Map.split/2`, and `Map.take/2`
|
| 174 | + * [String] The `:insert_replaced` option in `String.replace/4` has been deprecated. Instead you may pass a function as a replacement or use `:binary.replace/4` if you need to support earlier Elixir versions |
108 | 175 |
|
109 | 176 | #### Mix
|
110 | 177 |
|
|
0 commit comments