Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,130 | Comments: 45,558

filter by tags archive

C# vNext

time to read 3 min | 435 words

Jeremy Miller asks what we want in C# vNext. I have only real one request, to have meta programming of sufficent power, after which will be able to add all the required semantics without having the compiler team to argue with.

I am not holding my breath on that one, though. I can just imagine the arguments against it (let us start from the potentail for abuse, move to version and backward compatability hell, and then move forward).

I  want to go over Jeremy's list, and see what I can add there.

  1. Mixin's - Agree 102%. This is something that would so useful, I can't realy understand how it is not already there. Make it a magic attribute, something like [Mixing(typeof(IFoo), typeof(FooImpl))], and you can get away with it with just compiler magic, no changes required to the CLR.
  2. Symbols - I am ambivelent on that one. Syntatic sugar is important, but I have other things that I would value more.
  3. Make hashes a language feature - I think that you can do it right now with this syntax:
  4. var hash = new Hash(
    	Color => "red",
    	Width => 15
  5. Automatic delegation ala Ruby or Objective C - Um, isn't this just mixin?
  6. Metaprogramming! - absolutely. This is something that I have gotten to consider as basic. I am getting tired of having to fight the compiler to get the code that I want to have. The code should express my meaning, I shouldn't have to dance to the compiler's tune.
  7. Everything is virtual by default to make mocking easier - I certainly would like that, but I fear that this is not something that will be changed. AOP as a platorm concept, now that is something that I want to see.

My own request covers:

  1. memberinfo() - the CLR already has this concept, so we just need the syntax for it.
  2. Method Interception - let us start with the easy stuff, I want to be able to intercept methods from any type. I can do it now if I want to mess with the profiler API, but that is not something that I can really make use of for production.
  3. IDynamicObject - I want method missing, damn it! It is just the scratch of meta programming, but this is something that you could probably add to the compiler in a week.
  4. Static interfaces. Since we already has generics to allow us to treat types as interchangable types, I want to extend this concept by just a bit, to get it to work in a more reasonable manner.

I have a few more, but they just called my flight.



Does this resolve mixins ? http://msdn2.microsoft.com/en-us/vcsharp/bb625996.aspx

Andrey Shchekin

Have you read a JavaGI paper (http://homepages.cwi.nl/~ralf/JavaGI/)? I think it gives a sane new approach to static interfaces and mixin-like features, instead of just copying everything form Ruby.

Talkig about hashes, is not it already easy enough:

var hash = new Dictionary<string, string> {

{ "Color", "red" },

{ "Width", 15 }



Or do you really want tuples (guessing from the width value being of different type than color)? Then it would be

var tuple = new {

Color = "red",

Width  15


"Everything is virtual" is a hack, but I would vote for method interception.

Reshef Mann

U forgot to mention dynamic interfaces and a boo lover like u should know... :-)

I understood that MS intended to include it in C# 3.0 but finally postponed it since it wasn't required for linq to work.

I would take dynamic interfaces over the awkward linq...

Ayende Rahien


What do you mean by dynamic interfaces?

Reshef Mann

Say u have:

public class A{

public int Id {get; set;}

// More properties



public class B{

public int Id {get; set;}

//More properties



U can declare something like:

public dynamic interface IIdentifiable{

int Id {get; set;}


and in your code cast both class A and class B as IIdentifiable without having to actually implement IIdentifiable.

Resembles Boo's duck datatype, isn't it?

Frans Bouma

I asked Anders about mixins and AOP at the last summit, and he made it pretty clear that AOP is something he truly dislikes and it's very likely it won't be added to the language.

This is sad, and also looking at what they added to the language, it's pretty funny because if they DID add AOP specific elements, they could have solved things properly instead of flaky as with extension methods (but not properties) etc.


Am I the only one whom AOP reminds of Intercal's "COMEFROM" directive? I know there are certain things like logging or performance profiling that could be done in a very elegant way using AOP. But then I always imagine debugging a program that just jumps somewhere completely different with no apparent reason at the source of the jump. And that's not a weird side effect of AOP, it's the intended effect.

I am a huge fan of metaprogramming though, ever since I began to understand the true power of Lisp, but I doubt it will ever be included in C#. They could probably have implemented Linq with a few generic metaprogramming concepts, but they chose to hard-wire it in the compiler, so I guess the decision has already been made against any serious kind of metaprogramming.

IMO the best we could hope for is that someone comes up with a CLR-friendly (perferably compile-time-static-typed) metaprogramming language that integrates nicely with C# and all the other .NET languages.



Boo is a compile-time-static-typed CLR-friendly metaprogramming langauge and it works fine with C#, VB, etc.




I know Boo. It's a promising language, although metaprogramming in Boo is nowhere nearly as concise as macros in Lisp or Scheme. (But I don't know if that could be done in a language with a rich syntax like Boo.)

My main problem with Boo is that (AFAIK) it still doesn't naturally support .NET generics. Either that, or the documentation on this topic is hopelessly outdated.

Ayende Rahien


Duck typing should cover this. It looks like duck typing with strong typing, which doesn't really mix. I don't really like it, it looks awkward. And there isn't a good way to handle this in the CLR.

Ayende Rahien


Tough for him.

I am with you on that, this is something that can be really helpful on the language level. That he doesn't like it is nice, but it doesn't change the fact that this is a desired featured.

To me, it looks like the need to dance around AOP is causing a lot of warts in the design of C#.

Ayende Rahien


Go check boo, that is exactly what this is.

Ayende Rahien


Check the recent stuff about DSL building, from quasi quotation to meta methods.

Yes, generics is still being added in, but it is possible to both consume and create generic types.

And yes, the docs are out of date.

Reshef Mann

About dynamic interfaces,

I don't think that it is likely to see real duck typing from microsoft ever in C#.

And about handling it in the clr, can't it work like Boo handles duck typing or the way the DLR works?

Ayende Rahien


This is strictly something that the compiler has to do, it is not related to the platform.


Thank you David and Ayande, I've had another look at boo, especially at the newer test cases, and you're right, that's exactly what I meant.

Guess I'll have a boo-power-weekend soon!

Comment preview

Comments have been closed on this topic.


  1. How to waste CPU and kill your disk by scaling 100 million inefficiently - 5 hours from now
  2. RavenDB Conference 2016–Slides - about one day from now

There are posts all the way to Jun 01, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats