Changelog for Elixir v1.2
v1.2 brings enhancements, bug fixes, performance improvements and more into Elixir. Elixir v1.2 relies on many features in Erlang 18, requiring at least Erlang 18+. Upgrading to Erlang 18 is therefore necessary before upgrading Elixir.
Erlang 18 support
We have brought many features specific to Erlang 18:
- Maps can now scale from dozens to millions of keys. Therefore, usage of
the modules
DictandHashDictis now discouraged and will be deprecated in future releases, instead useMap. Similarly,SetandHashSetwill be deprecated in favor ofMapSet - Compilation times are faster due to improvements on both Elixir and Erlang compilers
- Dialyzer now emits less false negative warnings thanks to new annotations available in the Erlang compiler
- And many more
Language improvements
This release includes four notable language improvements:
-
The addition of multi aliases/imports/require:
alias MyApp.{Foo, Bar, Baz} -
Support for variables in map keys:
%{key => value} -
Support for pin operator in map keys and function clauses:
%{^key => value} = %{key => value} fn ^key -> :ok end -
Addition of the
withspecial form to match on multiple expressions:with {:ok, contents} <- File.read("my_file.ex"), {res, binding} <- Code.eval_string(contents), do: {:ok, res}
Those improvements aim to make the language more consistent and expressive.
Getting started experience
At the same time we improved the language, we have improved both parser and compiler to be even more aware of language constructs, emitting warnings on common pitfalls like when piping to expressions without parenthesis or when defining unsafe variables.
We have also introduced the i/1 helper in IEx, which allows developers
to retrieve information about any data type. This will help newcomers
explore the language values while providing experienced developers with
crucial information about the value they are introspecting.
Workflow improvements
Umbrella applications are now able to share both build and configuration files.
This aims to drastically reduce compilation times in umbrella projects by
adding the following configuration to each umbrella app's mix.exs file:
build_path: "../../_build",
config_path: "../../config/config.exs",
Finally, Mix will now always consolidated protocols as we are now able to consolidate in parallel and cache the consolidation results, providing the best performance across all environments without affecting compilation times.
Those are great additions on top of the faster compilation times we have achieved when migrating to Erlang 18.
v1.2.0-dev
1. Enhancements
Elixir
- [Application] Add
spec/1andspec/2to retrieve application specification - [Application] Add
get_application/1to retrieve the application a given module belongs to - [Base] Optimize encode and decode operations about 10 times
- [Enum] Use the faster and auto-seeding
:randinstead of:randominEnum.shuffle/1andEnum.random/1andEnum.take_random/2 - [GenServer] Add
GenServer.stop/1for reliably shutting servers down - [Kernel] Support multiple aliases in
alias,import,requireanduse. For example,alias MyApp.{Foo, Bar, Baz} - [Kernel] Add
struct!/2. Similar tostruct/2but raises on invalid keys - [Kernel] Warn if
@doc/@typedoc/@moduledocattributes are redefined - [Kernel] Warn if non-variables are used in
defdelegate/2(as they have no effect) - [Kernel] Mark quoted expressions as generated avoiding false positives on dialyzer
- [Kernel] Allow variables as map keys on creation
%{key => value}and on matches%{^key => value} - [Kernel] Allow the pin operator
^infnclauses and on the left side of<-inforcomprehensions - [Kernel] Introduce
withas a special form that allows matching on right side parameters - [Kernel] Raise when right hand side of
->does not provide any expression - [Kernel] Warn if the Elixir was compiled with a different endianness than the one currently available at runtime
- [Kernel] Warn if a variable is used after being defined exclusively in a nested context
- [Kernel] Warn if piping into an expression without parenthesis
- [Macro] Add
Macro.traverse/4that performs pre and post-walk at once - [Macro] Add
Macro.camelize/1andMacro.underscore/1 - [Process] Add
Process.get_keys/0 - [String] Introduce
String.replace_{prefix,suffix,leading,trailing}/2. The first two will replace only the first occurrence of the given match in string. The last two will replace all occurrences of the given match - [String] Support
String.normalize/2andString.equivalent?/2that perform NFD and NFC normalization - [Task] Add
Task.Supervisor.async_nolink/1/3that spawns a supervised task without linking to the caller process - [Task] Introduce
Task.yield_many/2 - [Task] Raise an error when a task is queried from a non-owning process (instead of waiting forever)
ExUnit
- [ExUnit] Allow one test to raise multiple errors. The goal is to enable tools in the ecosystem to emit multiple failure reports from the same test
- [ExUnit] Support
@tag report: [:foo, :bar]which will include the values for tags:fooand:barwhenever a test fails
IEx
- [IEx] Display type docs for
t(Module.type)andt(Module.type/arity) - [IEx] Add
i/1helper that prints information about any data type - [IEx] Show source code snippet whenever there is a request to pry a given process
Logger
- [Logger] Add file to logger metadata
Mix
- [Mix] Cache and always consolidate protocols
- [Mix] Add
warn_test_patterntomix testthat will warn on potentially misconfigured test files - [Mix] Introduce
MIX_QUIETenvironment variable that configures the underlying Mix task to output only error messages - [Mix] Validate git options and warn on conflicting ref, branch or tags
- [Mix] New umbrella applications will now share configuration and build files
2. Bug fixes
Kernel
- [Kernel] Change
__ENV__.fileif@fileis set for the given function - [Kernel] Make
Kernel.ParallelRequireaware of:warning_as_errors - [Kernel] Improve error message for invalid
do/do:
IEx
- [IEx] Do not start apps on
recompilehelper if--no-startwas given - [IEx] Avoid copying of data when evaluating every expression in IEx
Mix
- [Mix] Always run non-recursive tasks at the umbrella root
- [Mix] Ensure rebar projects work on directory names that contain non-latin characters
- [Mix] Ignore directories inside
appsin umbrellas that do not have amix.exsfile - [Mix] Ensure Mix can be used with path dependencies where the app name is different than the path basename
ExUnit
- [ExUnit] Include file and line in all compilation errors for doctests
3. Soft deprecations (no warnings emitted)
Kernel
- [Dict]
DictandHashDictare soft deprecated in favor ofMap - [Keyword]
Keyword.size/1is deprecated in favor oflength/1 - [Map]
Map.size/1is deprecated in favor ofmap_size/1 - [Set]
SetandHashSetare soft deprecated in favor ofMapSet
Mix
- [Mix]
Mix.Utils.camelize/1andMix.Utils.underscore/1are soft deprecated in favor ofMacro.camelize/1andMacro.underscore/1