Replies: 2 comments 5 replies
-
|
Not completely sure what you're asking here? Are you asking for implementation details? Or general information on immutable data-structures? You mention 'immutable collections', are you talking generally, or about the immutable collections in language-ext, or the Microsoft ImmtuableCollections library? Some general info on the language-ext immutable collection types:
Immutable AVL treesSome of the collection types in language-ext use a self-balancing AVL tree as its backing store. They are:
Immutable AVL trees work by only updating the nodes in the tree that are directly affected by an insertion or deletion. If you have a root This means that the total cost of insertion or removal is Iterating and reading of any of the immutable AVL backed structures will be as fast as doing so with the mutable versions in the BCL ( Note also that that all of these AVL backed types can be initialised with an Compressed Hash Array Map Trie (CHAMP)
The closest type in the BCL is
|
| Type | Add |
Cons | Insert(0,x) |
Enumeration |
|---|---|---|---|
Seq<A> |
29.5 ns / op |
20 ns / op |
10.0 ns / op |
List<T> |
11 ns / op |
10320 ns / op |
16.1 ns / op |
This is pretty amazing for an immutable, thread-safe, lock-free, type that can support appending and prepending with very similar performance benefits to List<T> as well as supports at-most-once lazy streaming. We're still looking at 33-50 million write operations per-second and enumeration that's faster than the mutable counterpart.
One thing to note is that Seq<A> also supports laziness. If you're enumerating a lazy sequence then you're looking at 54 ns / op, or about 18.5 million operations per-second. Once the lazy stream has been enumerated once then it is cached and will have the same performance as the table above.
Beta Was this translation helpful? Give feedback.
-
|
Reading the questions and answers this discussion make me feel again like my first year in the software world but in a very good way. I feel like a child in a big world with rivers and lakes to explore. I mostly have practical experience because I just have the basic formal training from when I was in the equivalent of "high-school" in Chile, around 2014 to 2018. It was a "Telecommunications Medium Technician", but they did touch Programming topics, specificly web and I fell in love with it. After that I started working inmediatly in software development, and learn a lot until 2024, when a was feeling that I get too close to the celling. And maybe I did, but only in Chile. I throught that Vertical Slices Architecture, Domain Driven Design and a very Object Oriented Programming thinking was the answer to the even the most difficult/complex problems or workflows that my clients have send me. I think that I'm good enough in domain modeling, use case understanding, workflow composing, managing technical debt, making code that works, but also reads, feels and seems good. But I was feeling trapped, I was still feeling that the celling was to close to me. Until I get to this repository, and slowly the rules of the game change. Learn about functional programming, and more "formal-concepts" with this library is definitly an experience that I recommend. It may be a little light (it's a big one to me), but this discussion is a very good start-point to do a deep research of more "theorical" concepts (like concurrency, performance) and the ussual problems that programmers have when getting "las manos en la masa" and how more experienced people resolve those problems, for people in a similar context of mine this repository can be even game changing Merry christmas @louthy, you're an inspiration, and currently my inspiration. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
Hi there!
I have been fiddling around with the immutable collections, and one piece of code (that ended up being my fault!) was very slow. That made me go looking for implementation details to get some kind of overview of how the data structures work, just to be certain I didn't do the language-ext version of python-people-making-lisp-code-quadratic.
I couldn't find any except for reading the code. Are there any resources that I missed?
Best regards
Linus
Beta Was this translation helpful? Give feedback.
All reactions