Microsoft.FSharp.Collections vs System.Collections.Immutable

I recently found out that in .Net

There are tons of immutable collections .

F # is a language with an emphasis on immutability, and it has its own immutable data types . Interestingly, I did not see references to the above immutable collections in any reading on F #.

I am wondering if there is any connection between these immutable collections and F # collections? Are there any recommendations for use? Which is better, F # Map<_,_> or ImmutableDictionary(TKey, TValue) , etc.?

UPDATE Perhaps I could ask it this way: does anyone have experience using both of these libraries in the same project or comparing their performance? Or is it just like this: first for C #, and the last for F # and what is it?

+6
source share
2 answers

The reason for this duplication is that System.Collections.Immutable is a recent addition and intended for use in C #, so its developers clearly did not want people to refer to FSharp.Core.dll .

Regarding the choice between the two, I would use System.Collections.Immutable in C # code and in F # code, which is intended to be used with C # and Microsoft.FSharp.Collections in all other F # code. AFAIK there is no significant difference in performance. Typical code will look like a chain of method calls with SCI and a series of calls |> with MFC, but this is just the syntactical difference in fact - conceptually it is one and the same.

+4
source

Just to add my 2 cents: in my current study it seems that System.Collections.Immutable is what should help the F # program when programming C #))

Here's the MSDN blog post on them. It refers to another message (MSDN too). And in this article there is an incorrect reference to the T4 template, which can be easily created to create immutable objects in C #: here is a TT file and here is a terrible conversion result .

This is certainly great work, but it seems to reproduce (using System.Collections.Immutable ) functions that already naturally exist in F #.

Therefore, the answer currently looks like System.Collections.Immutable for C # and Microsoft.FSharp.Collections for F # and what is it.

+2
source

All Articles