

Elm 0.12.1: Fast immutable arrays - yiransheng
http://elm-lang.org/blog/announce/0.12.1.elm

======
millstone
I think this means to say fast persistent arrays. A fast immutable array is
trivial - just use an array!

~~~
anorwell
I'm not sure what persistent means in this context, but what is meant by
"fast" immutable array here is that the immutable array supports operations
like insert and delete (returning new immutable objects) in near-constant
time.

~~~
tree_of_item
Rich Hickey (re)popularized the usage of "persistent" to mean what you just
described immutable as. That is, the previous version of the data structure
"persists" after you add an element, and now you have two values.

To the people using that definition of persistent, "immutable" just means
constant, i.e. no insertion or deletion at all.

~~~
sgk284
That's not quite right. All immutable data structures are persistent, but not
all persistent data structures strictly use immutability.

Immutability is a common way of achieving persistence, but fundamentally a
persistent data structure simply preserves previous versions. This can be
achieved through some mutability via things like fat nodes[1].

It turns out that when you use immutability, many other nice properties often
fall out from that decision. You can absolutely insert and delete into an
immutable data structure though. You'll simply get back a new structure.

[1]
[http://en.wikipedia.org/wiki/Persistent_data_structure#Fat_N...](http://en.wikipedia.org/wiki/Persistent_data_structure#Fat_Node)

------
tehabe
When I read elm I thought it was about an email client. I think that makes me
officially very old.

I miss those email clients. They were much nicer than most of the email
software which is considered modern today.

------
moomin
Couldn't they just use Mori?

~~~
JeanPierre
Mori doesn't implement RRB-trees, thus doesn't support logarithmic
concatenation.

~~~
jonase
Maybe mori could include core.rrb-vector[1]. Other interesting persistent data
structures (by the same author) are persistent sorted maps and sets[2].

[1] [https://github.com/clojure/core.rrb-
vector](https://github.com/clojure/core.rrb-vector) [2]
[https://github.com/clojure/data.avl](https://github.com/clojure/data.avl)

------
rurban
Logarithmic is not constant.

The fact that elm announces constant array access will not surprise anybody,
as this is an inherent property of arrays. But then seeing that they have to
use radix-trees for arrays and announcing it as constant is highly misleading.
These guys should switch over to politics.

And this only holds for immutable arrays! So even without
push,pop,shift,unshift they have to use trees for arrays.

~~~
tiles
Why are Elm's arrays so much more complex than JavaScript's O(n) arrays?

~~~
wheatBread
It's about mutability vs immutability. I think Zach explains the whole idea of
immutable arrays really well: [http://www.infoq.com/presentations/julia-
vectors-maps-sets](http://www.infoq.com/presentations/julia-vectors-maps-sets)

