50

Elm 0.19 brings better collections

 5 years ago
source link: https://www.tuicool.com/articles/hit/EfUfueZ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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: List , Array , Dict and Set .

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

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 map , filter and 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.

More info in the PR and these development updates: #1 , #2 .

Array

Like Dict , Array has been totally re-written. The original code was in Javascript, and suffered from grave bugs that could cause runtime crashes and mutations. The new implementation is in mostly Elm, and all known bugs are fixed.

From a performance stand point, the implementation is faster in some cases, while slower in others. More information in this development update .

Summary

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 .


Recommend

  • 29
    • www.tuicool.com 5 years ago
    • Cache

    Elm on fire! Shaders in elm

    Shaders have long been on the list of possible subject to study for Jappie. The potential of both creating

  • 28
    • www.tuicool.com 5 years ago
    • Cache

    Elm 0.19 Broke Us

    Elm 0.19 was released yesterday. There were a significant number of breaking changes at every level: configuration, tooling, library, language. But those are not what this post is primarily about. For my team, this releas...

  • 107
    • www.tuicool.com 5 years ago
    • Cache

    The Elm Architecture

    The Elm Architecture The Elm Architecture is a simple pattern for architecting webapps. It is great for modularity, code reuse, and testing. Ultimately, it makes it easy to create complex web apps that stay hea...

  • 37

    New Beginnings Since I originally learned about and tried Elm in 2013, a lot about the language has changed. Elm and I have grown distant and close several times over the years, each encounter being more pleasa...

  • 40
    • www.tuicool.com 5 years ago
    • Cache

    Upgrading Elm from 0.18 to 0.19

    Published on Friday, March 1, 2019. by The Engineering Team Elm is a front-end, functional language that compiles to JavaScript for seamless web development, and...

  • 32
    • www.tuicool.com 4 years ago
    • Cache

    The Elm Architecture (TEA) animation

    The “game loop” of Elm This is the backbone of a web application written in the Elm language ( https...

  • 18
    • Github github.com 4 years ago
    • Cache

    Elm Regression Testing

    :recycle: Elm Regression Testing :recycle: Refactor that obscure piece of code that nobody can understand anymore! What is it? Imagine you start a new job on an alr...

  • 2
    • www.derrickreimer.com 3 years ago
    • Cache

    Elixir, Elm, GraphQL, Oh My!

    Elixir, Elm, GraphQL, Oh My! How I went about choosing the technology for Level.For the last nine months, I’ve been building a prototype of Level. The reason is two-fold: I needed an environment in which t...

  • 8
    • marcosh.github.io 3 years ago
    • Cache

    Elm and Event Sourcing

    Elm and Event Sourcing Jul 9, 2016 • Marco Perone In the last time I’ve been attracted to study mainly two things, Elm and Domain Driven Design. They are not necessarily two strictly related subjects, but, in my own opin...

  • 6
    • marcosh.github.io 3 years ago
    • Cache

    ELM

    or how I learned to front-end development ...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK