Elm 0.19 brings better collections
Robin Heggelund Hansen Aug 21
You're probably aware of this already but Elm 0.19 has just been released. When you read through the release notes and the documentation of the core library, you might to think that nothing has changed with regards to the built-in collection types:
You'd be wrong.
While it is true that the API remains entirely the same, there are huge changes under the covers which results in more performance, and a bug-free
Array implementation. Let's take a closer look.
List is the data structure which have changed the least. In fact, the underlying data structure hasn't changed at all. The only thing which have changed is the implementation of
List.foldr which is now faster by about 30%.
This alone might not seem to be that big of a deal, but considering
append are all implemented on top of
foldr, this means that
List is quite a bit faster across the board.
If you want to know more about the actual implementation, you can take a look at this PR.
Dict and Set
Dict has actually been re-written from scratch while retaining the original API. The benefits of this new implementation is mostly that of performance. We're talking 170% faster inserts and about 30% faster removals.
Set is just a thin wrapper around
Dict, and so
Set benefits from the new implementation as well.
From a performance stand point, the implementation is faster in some cases, while slower in others. More information in this development update.
The API might be the same, however, a huge amount of work has been done to make these data structures better than ever before.
There is a similar story for the
Random module, which has been re-implemented by Max Goldstein to be faster and more, you know, random. You can learn more by checking out this PR.