I heard F# has native support for immutability but what about it that can not be replicated in C#? What do you get by an F# immutable data that you don't get from a C# immutable data?
Also in F#, is there no way to create mutable data? Is everything immutable?
If you use both C# and F# in an application, can you change the immutable F# data in C#? Or do you just have to create new C# types that uses the immutable F# data and replaces the references that points to those data?
The way F# works makes it easier to work with immutable data but there's nothing special that can't be done in C# in that regard. It may not provide neat syntax though.
F# supports mutable data with the mutable
keyword. F# is not a pure functional language. It supports imperative constructs like loops as well as functional constructs.
No. Immutable types are really immutable. The .NET type system is shared across both languages. You can't change the immutable data from C# either (short of reflection and memory hacks, of course).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With