Tales from the Evil Empire

Bertrand Le Roy's blog

News

Ads Via DevMavens

ASP.NET AJAX UpdatePanel Control: Add Ajax interactivity to your ASP.NET 2.0 web pages


follow bleroy at http://twitter.com

Bertrand Le Roy




Add to Technorati Favorites

Blogs I read

My other stuff

Immutability in C#

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:

  • They simplify multithreaded programming.
  • They can be used as hashtable keys.
  • They simplify state comparison.

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 Transparency
Immutable types can copy the world… safely!

Luca Bolognese on implementing immutable value objects:
Creating an immutable value object in C# - Part I - Using a class
Creating an immutable value object in C# - Part II - Making the class better
Creating an immutable value object in C# - Part III - Using a struct
Creating an immutable value object in C# - Part IV - A class with a special value
Creating 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 Immutability
Immutability in C# Part Two: A Simple Immutable Stack
Immutability in C# Part Three: A Covariant Immutable Stack
Immutability in C# Part Four: An Immutable Queue
Immutability in C# Part Five: LOLZ! <- this is of course the must read of the series ;)
Immutability in C# Part Six: A Simple Binary Tree
Immutability in C# Part Seven: More on Binary Trees
Immutability in C# Part Eight: Even More On Binary Trees
Immutability in C# Part Nine: Academic? Plus my AVL tree implementation
Immutability in C# Part Ten: A double-ended queue
Immutability in C# Part Eleven: A working double-ended queue

Posted: Jan 16 2008, 03:36 PM by Bertrand Le Roy | with 8 comment(s) |
Filed under: ,

Comments

Julien Couvreur said:

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

# January 16, 2008 8:40 PM

Bertrand Le Roy said:

Yes, Julien, you're absolutely right.

# January 16, 2008 8:47 PM

Granville Barnett said:

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.

# January 17, 2008 1:29 PM

rascunho » Blog Archive » links for 2008-01-17 said:

Pingback from  rascunho  &raquo; Blog Archive   &raquo; links for 2008-01-17

# January 17, 2008 3:27 PM

Wöchentliche Rundablage: .NET 3.5, WPF, LINQ, Tests, System.AddIn, SubSonic, Sandcastle | Code-Inside Blog said:

Pingback from  W&ouml;chentliche Rundablage: .NET 3.5, WPF, LINQ, Tests, System.AddIn, SubSonic, Sandcastle | Code-Inside Blog

# January 21, 2008 3:41 PM

Dflying Chen said:

摘要好久没写了,不为自己找借口,不管怎样,还是要继续捡起来。本期共有9篇文章:C#中的不可变类型使用System.Drawing生成缩略图时应采用什么样的InterpolationMode...

# January 27, 2008 4:54 AM

Eric Lippert said:

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.

# February 13, 2008 3:50 PM

brute forced brilliance said:

It's Time for a Change -- We need Immutable Types

# April 3, 2008 1:13 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)