For some reason, there's been a lot of buzz lately around immutability in C#. If you're interested in algorithms and data structures, it's a fascinating subject. Immutable objects, according to Patrick Smacchia, have the following advantages:
A good introduction to immutable types by Patrick Smacchia:Immutable types: understand their benefits and use them
More on immutability usefulness:Immutability, Purity, and Referential TransparencyImmutable types can copy the world… safely!
Luca Bolognese on implementing immutable value objects:Creating an immutable value object in C# - Part I - Using a classCreating an immutable value object in C# - Part II - Making the class betterCreating an immutable value object in C# - Part III - Using a structCreating an immutable value object in C# - Part IV - A class with a special valueCreating an immutable value object in C# - Part V - Using a library
Finally, Eric Lippert shows how to implement a few common data structures as immutable types:Immutability in C# Part One: Kinds of ImmutabilityImmutability in C# Part Two: A Simple Immutable StackImmutability in C# Part Three: A Covariant Immutable StackImmutability in C# Part Four: An Immutable QueueImmutability in C# Part Five: LOLZ! <- this is of course the must read of the series ;)Immutability in C# Part Six: A Simple Binary TreeImmutability in C# Part Seven: More on Binary TreesImmutability in C# Part Eight: Even More On Binary TreesImmutability in C# Part Nine: Academic? Plus my AVL tree implementationImmutability in C# Part Ten: A double-ended queueImmutability in C# Part Eleven: A working double-ended queue
Probably because there's been a lot of buzz around functional languages ;-)
Here's another pointer which you may find interesting: blogs.msdn.com/.../132646.aspx
Yes, Julien, you're absolutely right.
I have used F# for a while having used Haskell prior to that and the simplicity of concurrent programming is a joy and one that imperative languages like C# etc will want to emulate in the future given the fact that processors are scaling out in terms of cores.
I guess we will have to wait and see but I would bet that the next version of C# will introduce more abstract language constructs - LINQ was the tip of the iceberg.
Pingback from rascunho » Blog Archive » links for 2008-01-17
Pingback from Wöchentliche Rundablage: .NET 3.5, WPF, LINQ, Tests, System.AddIn, SubSonic, Sandcastle | Code-Inside Blog
摘要好久没写了,不为自己找借口,不管怎样,还是要继续捡起来。本期共有9篇文章:C#中的不可变类型使用System.Drawing生成缩略图时应采用什么样的InterpolationMode...
Granville: though we are not of course discussing specifics at this time, you should expect that whatever we do next in the C# space will be less heavy on paradigm-shifting features for a while.
After introducing anonymous methods, generics, iterators and nullable value types in C# 2, and then query comprehensions, etc, in C# 3, we want to slow down on the massive influx of complex new language features and concentrate on more targetted improvements to the language and infrastructure.
That said, the future is big and there is a lot more we can do with this language, and yes, multi-core is going to be important.
It's Time for a Change -- We need Immutable Types