Going Deep

Expert to Expert: Erik Meijer and Anders Hejlsberg - The Future of C#

Download this episode

Download Video


It's always a pleasure to get a chance to sit down and geek out with Anders Hejlsberg. Anders is a Microsoft Technical Fellow (a Technical Fellow is the highest ranking technical position at Microsoft) and programming language design master. He's the creator of C# and one of the founders of .NET. Anders is an expert language design craftsman. C# is one of the most popular languages Microsoft has created and certainly the most widely used language by developers who target the .NET platform.

Erik Meijer, Expert to Expert host, programming language designer and occasionally-radical category theoritician, has spent many years working with Anders and the C# team. As you may know, Erik has been a key contributor to the addition of functional constructs to C#. 

Here, Erik and Anders wax on topics ranging from the design of C# 4.0's dynamic keyword (what's the thinking behind the thinking) to the potential near and far future of the C# language (and general purpose imperative programming, generally). Anders also spends some time at the whiteboard explaining C# 4.0's support for covariance and contravariance. Of course, we can't forget about concurrency and parallelism, so we don't.

As you might expect, the conversation takes some interesting jaunts into various programming language design rabbit holes. For example, Anders discusses the notion of creating a new language to support new problem domains versus extending current languages to meet the needs of developers who need to express solutions to complex problems (so, how do you make a language like C# more dynamic in the sense that it can readily help developers solve problems that the language was not initially designed to solve?). We talk about the work being done on a service-oriented C# compiler (compiler as a service), C# as an ESDL container (or as an EDSL itself to be hosted in other environments...) and much more. This is a fantastic conversation with some of Microsoft's true visionaries. Enjoy.



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • tomkirbygre​en
      Hot damn. An E2E video with Anders and Erik, that's my evening viewing sorted. Thanks Charles!
    • littleguru

      Awesome! Thanks guys. Great, great stuff... please more!

    • aL_
      as .tom said, expert to expert with anders and eric :O talking about crossing the beams (of awsomeness that is) cant wait to watch it Smiley

      what where you talking about there in the beginning btw? Smiley

      hah first i was like, "wow.. i thoguht anders had more cubes that that" but then i saw that the row of cubes goes around the whole window Tongue Out (i still think he has a garage full of em at home though Wink )
    • Charles
      We were talking about Erik's evil plot to turn C# into a Haskell variant. Smiley (just kidding). The conversation started abrubtly (I turned the camera on when I felt the game was on)

    • aL_
      hehe i knew it Wink
      its kind of interesting though, because eric is a static typing guy (that the impression i have anyway) but there are a lot of "dynamic" concepts in 4.0, most notably the dynamic keywork of course Smiley how does eric feel about that? is c# becoming "dirtier", less pretty? my personal awnser is "no, its awsome" but i wonder what erics awnser would be Smiley maybe its coming though, im only at 26:21 right now..
      perhaps you could have an E2E with just eric (eric talking to eric) and talk about stuff like that Big Smile

      what i really wanted to comment on was extension methods (talked about at ~25:00), what i really really like about them is that you can call methods on objects that are null and also you can add methods to enums.. small things yes, but darn useful Smiley

      --edit @01:00:00--
      what i meant when i said "just use haskell" was really, "just use haskell where its really convenient to do so and use c# when thats more convenient" Smiley that perhaps more interop is the key Smiley i do agree with eric though, maybe the divide between imperative and functional isnt that huge.. or maybe it doesnt have to be atleast Smiley thank you charels for bringing this topic into this conversation

      --edit post watch--
      wow man.. this i gotta say takes the channel9 crown from the discussion about c# (3.0 at the time) as the best c9 interview ever. i am slightly biased though because i kind of, sort of contributed indirectly but still Smiley
      The discussion about functional vs imperative was really great though i dont think that battle will end anytime soon Tongue Out

      the single greatest thing though is the complete lack of religion in this discussion, just pragamatism and pros and cons of diffrent concepts.. just that single aspect is something we can all learn from i think Smiley

      again, great stuff Smiley
    • Charles
      Glad you liked it! Smiley

      Channel 9 is not, nor has it ever been, simply us talking to you (or at you). Niners are always in the room for our conversational pieces (whether it's obvious or not). Many times, Niner posts are sent directly to those who have answers (assuming the context includes questions) or simply need to know. One of the things I'd love to enable is real time Q&A with a virtual audience. This is not a pipe dream.

      Keep on posting,
    • joechung

      A few things I would like to see in C#:

      • With regards to immutability, how about a freeze method, like in Ruby and implemented perhaps as an extension method of System.Object, that would allow you to make an existing instance of an object immutable? (Also a IsFrozen() method to determine if an object has been frozen) It already exists in a limited form with readonly, and it might be doable moreso now thanks to code contracts that could be used to enforce immutability at compile-time and run-time.
      • Better literals for arrays, hash tables, and objects. Object and collection initializers are nice but not as succinct as in, say, Ruby or JavaScript.
      • (Really a wish for LINQ) Enumerable.Empty, i.e., return an empty sequence. Silly to ask for something so trivial but it's missing! And of course it needs a nice literal...

      Long term for .NET:

      • SIMD instructions to support data parallelism in xPU computation where perhaps PLINQ code gets farmed out to the many processing units in your GPGPU (Cell, Larrabee) instead of the handful of processors in your CPU. This is something the Mono guys are already working on, if I understand correctly.
      • More lazily evaluated library methods (where possible and enabled by the underlying Win32 API), e.g., DirectoryInfo.GetFiles() takes a awfully long time to load when you have 500,000 files in a folder -- where's the wrapper for FindNextFile?  Or how about lazily evaluated networking functions where implementing a TCP server is as simple as implementing an iterator?
    • Maddus Mattus
      Nice shirt Erik!
    • rciq
      Static extension methods please, please, please... Wink
    • littleguru
      Charles, could you post the link to the video with Jim Gray that you mentioned in the interview? Thank you Smiley
    • littleguru
      OMG is his syntax for static extension methods ugly... why using the generic syntax for it? It's very confusing.
    • tivadj
      If I have
      interface ISet<T> : IEnumerable<T>
      bool Contains(T item);

      then it can't be covariant (because Contains takes T as an argument) according to Anders explanation...

      Guys who have touched 4.0, is it true?
    • rciq
      I agree on that, but I never insisted on his syntaxt. There are some nice ideas down there in the comments; and anyway I'm sure the C# team would find their own best syntaxt. I just want the feature;)
    • SteveRichter
      I would like to be able to create a new language based on C#.  Where the new language is actually a pre compiler, which translates any non c# statement in the code to actual C#. One example being a language which allowed VB code to be mixed in with C# code. The pre compiler would translate the VB code to C#, then call the C# compiler to compile the result.  A better example is the embedding of a DSL that targets spreadsheet or document automation.  You dont need enhancements to C# to make such a precompiler doable. What is needed ( I think ) is the Visual Studio debugger and editor being able to switch between the views of the source code of the program. One view contains the source code that was input to the pre compiler. The 2nd view contains the code that was output from the pre compiler and input to the C# compiler. These views needed to be interleaveable so that statements in one view line up with statements in another view. Also, program variables have to be mapped from one view to the other. 

      The IBM AS400 uses this facility very well to embed SQL within COBOL, RPG and C code:

      Can Visual Studio do this now?  I asked a few years ago and was told no.

    • Charles
      I believe it's this one: http://channel9.msdn.com/posts/TheChannel9Team/Jim-Gray-Part-II-of-talking-about-Database-Design/ 
      About half-way through Jim talks abot his perspective on the Concurrency problem.
    • CbrAInK
      concerning the extension properties:

      why concentrate on the syntax of the properties?

      Why don't you change the class?
      So just add a new decorator like inherit- let's call it extents - so now you have something like
      static class Extender extents int
          bool IsPrime { get { .... } }
          void DoSomething() { ... }

      Isn't this simple enough?
    • CbrAInK

      some questions:

      - what about static methods for interfaces or static abstract / virtual methods in classes?
      - what about readonly/const local variables / parameters

      this might concern the CLR but anyway:
      - what about a IArithmetic interface
      or even
      - what about type classes (for F# Wink )
      - what about new <- declarations in interfaces WITH parameters

      All these are lacking and all these hurts noadays where you try to decouple as far as possible

    • aL_
      i might be totaly missing what you mean but there is a Enumerable.empty Smiley (Enumareable is also in the System.Linq namespace)
      Enumerable.Empty<String>( );
      returns an empty ienumerable of string.. or du you mean a non generic version or something? (if so, you could simply cast to IEnumerable and you're golden)

      also, while there isnt a super neat way to declare a hash/dictionary, you can initialize a an array without explicitly typing out the type on the array:

      var stringArray = new[ ] { "hello", "world" };
      var myIntArray = new[ ] { 2, 3 };
      var InvalidArray = new[ ] { "hello", 3 };  //wont compile

      personally i think object initializers are pretty on par with object initializers in ruby..
      i agree that hash inits a'la ruby would be nice though Smiley
    • littleguru
      Nice ideas Smiley Very nice!
    • littleguru
      It's doable... but it's a pain, a real pain. You could write your own editor and your own tools that then translate and probably use the classes in the Microsoft.CSharp namespace to then compile your generated code... it's not very nice to do this right now.
    • metaThought
      great stuff; thx.
      Anders is always a pleasure to see/listen to
    • stevo_
      This is the best video ever..
    • sokhaty
      Immutability should be a VM-level feature.

      Regarding lazy evaluated methods,  I guess what you are really asking for is an object pipeline at VM or even OS level that would be thread safe and allowed multiple contributors and consumers to plug into it. It would presumably address quite a few scenarios of massive and/or parallel data processing. And yes, it would be nice if all the interfaces that can potentially return lots and lots of data were "pipeline"-aware.
    • Moemeka
      call me crazy but doesnt the inclusion of dynamic (more importantly the ability to intercept calls to 'phantom' methods) implicitly provide the extension property/static extension method issue?  Why add more language features?  As I see it all we'd have to do is create a class that inherits from IDynamic and provide an implicit cast to it from the type we want to extend.  Then you can go crazy adding members that dont really exist.  Sure you dont get IDE support but it works perfectly fine.
    • cycnus
      Awesome interview!.
      Anything with Erik Meijer is worth watching -if only to find out which colourful shirt he's going to wear Smiley -, but when both Erik and Anders Hejlsberg are together, oh my!

      Thanks a lot Charles for this video!
    • aL_

      i've got a question,
      if IEnumerable<T> is changed to IEnumberable<out T>, how can things like List<T> implement it?
      List<T> does add Ts and doesnt that break the co-variance? can the interface be co-variant and the implementing class not be?
      (class List<T> : IEnumerable<out T>)

      im sure anders thought of this ages ago but still, it'd be interesting to hear how that fits together Smiley

      btw where can we get those cup<T> (cup of T for any non geeks out there) cups Big Smile

    • rciq
      Definitely doable, but due to a few obvious reasons (intellisense, performance, overall complicity) I think nobody would go that far;) However, if you don't care, you can go all out. Turn all your code dynamic and make it do really mad stuff. Imagine some crazy levensthein-distance-powered resolver which corrects your spelling (like "ToStrign" -> "ToString") on the fly, omg;)
    • Jeff Klawiter
      SIMD (Single Input Multiple Data) is a CPU term of instruction set extensions. MMX was the first widespread extension followed by SSE, SSE2, 3DNOW and so on. What they have been working on at the Mono project is taking advantage of these instructions where appropriate and exposing an API to call them specifically. It's a logical step since the JIT has knowledge of what hardware it's running on, why not actually optomize for that hardware as much as possible. The performance gains in the situations where it makes sense is quite enormous and this is one of the places where XNA games could see the largest vindication.

      As for GPU offloading, I'm unaware of managed work to do it. I'm sure using unsafe bindings hitting up CUDA or GPGPU (Ati needs a better name) could be used.
    • Art Scott
      Thanks. It's all good.
      If you don't have 70 minutes, some good bits, at approx. times:
      - "continous design", 29:04
      - "C 6.0 ...37 years..." , 38:--
      - "OO v Fun ..." , 60:--
      - For sure  "... look at that shirt ..." , 64:--
      - "... create new language ..." , 65:--
      - "... the grass has to be an aweful lot greener over there and there has to be one heck of a giant carrot ...", 67:30
      -- How green is the F# garden? And how BIG is the F# carrot? Compared to what ... GM SUV or Toyota Hybrid?
      -- Sometimes change is not evolutionary, but revolutionary. See single xPU's in museums, today!
      -- Note to self: check out Lynn Hill's group.
      - There should be some richness at 42:-- too
      - Yes, I have way too much time.
      - Let's have some more fun.
    • Daniel Smith
      Here's an example of how I'd implement extensions:

      public extends DateTime
          // Extension property
          public DateTime Tomorrow
              get { return this.AddDays(1); }

          // Extension method
          public DateTime SetTime(int hour, int min, int sec)
              return new DateTime(this.Year, this.Month, this.Day, hour, min, sec);

          // Static extension method
          public static int DaysBetween(DateTime startDate, DateTime endDate)
              return endDate.Subtract(startDate).Days;


      • The "this" keyword represents the instance of the object the extension method/property is attached to.


      • There is no need for a dummy "this" parameter on the extension methods as with the old syntax.
      • Extensibility - it would be easy to see how other extensions could be added e.g. indexers, etc.
      • Keeps all your extensions for a class together.
      • Clean, concise, familiar syntax without any freaky context keyword tricks.
      • Other than the enclosing "extends X" everything inside the braces is normal code.
      • The same rules that classes use for the "this" keyword apply to the new "extends X" construct i.e. the "this" keyword can only be used in the non-static extension methods.


      • Would make the original extension method syntax redundant Smiley
    • Ralph Trickey

      I'm going to be a heretic and flatly state that Anders is wrong about one thing, and I drank the kool-aid starting back with Turbo Pascal.

      We're going to see a /parallelize switch on the compiler. It may be C# 7+, but we're going to see it. I remember the arguments against garbage collection, against dynamic typing, etc.

      We will probably see 8+ cores on the user's desktop and 16+ cores on the developer's machine, and probably 16Gig, and that's enough to crunch one heck of a lot of graphs for a compiler. Most programs aren't the worst-case type of scenarios that people talk about, people still think linearly, so while I wouldn't expect the parallelize switch to work on Word or Excel, or any paint programs, I would expect it to be able to make enough use of parrallelism to make it twice as fast on a standard application as a single threaded program, even if it uses all 8+ cores to become twice as fast. It's going to be innefficient as anything, but it's still a 'free' 2x improvement in speed.

      Will the /parallelize switch become anything more that a gimmic to make old programs and casual games run faster? That I don't know. That's where my crystal ball fails me. Seeing what they're doing with the task parallel library, I wouldn't be too surprised if between that and the software transactional memory that doing something like running multiple copies in parrallel and simply throwing away the unused portions (somthing like what the CPU does) may not make it possible to do a lot more with the compiler and library to parrallelize than Anders thinks is possible. We also may see more fine-grained parallelism and SIMD type stuff built into the VMs/CPUs. On the other hand, I've got a classical CS background, understand compiler design, and remember the 1K machines, not those behemoth 64K machines that Anders was talking about. I know how difficult the problem is, but it only has to be solved once.

      My random 2c,

    • aL_
      this is total conjecture and rumor mongering but i firmly belive that GPGPU processing are in the works for .net Tongue Out
      long time ago (2006) there was something called the accelerator project, there was even a channel9 video about it:

      in another video chalres did with joe duffy and his team there is mention that joes team is talking to "all those teams" when charels asks about a few msr projects including accelerator

      at the pdc one of the speakers mentions that "those guys [refering to another .net team] are translating linq queries into shaders" this only mentioned in this one sentence and is never talked about again in the sessions, i thinks its still a secret and the speaker slipped a little

      also, brian beckman, who has worked on gaming related stuff is working on something secret that seems to be related to .net. this is mentioned in this video

      again, this is just me extrapolating from a bunch of out of context statements and my own wish for something like that Smiley (.net would pwn with linq-to-gpu) and ive got aboslutily no response from anyone at microsoft when i've asked about this stuff (thought that to me adds to the likelyhood of something beeing in the works Tongue Out)


      the accelerator project is still around it seems, but it hasnt been updated for a while :
      there are bits you can download though Smiley

      charles i know ive nagged about an update on accelerator but pleeeeese try and get something from them or duffy or whoever Smiley i really like to know if im on to something or if i should just fashion a tinfoil hat right now Big Smile
    • AdityaG
      I think my favorite feature in C# will be the stuff they are doing with parameters (named parameters, hallelujah!).

      P.S. Is it just me or is this like nerd gold. Seeing Erik go into his self-thinking/trying to ask a question while getting lost in the expanse that must be his brain is awesome. Please do more videos like these Charles! Big Smile
    • Charles
      Many more E2Es with Erik on the horizon.
    • Charles
      Re: targeting GPU, yes, of course; there are both research projects and incubation in this area inside MS. Nothing is ready for public disclosure, however and therefore I can't/won't comment on the specifics. As for Accelerator, it's most likely not dead....

      Remove the tin foil hat,
    • aL_
      thats all i needed to hear man (although i wouldnt protest if i was told more Wink )
      i certainly dont want you, channel9 or the interviewés to get in trouble from the bosses because you said too much Smiley

      i went back and rewatched that accerator video and it really does sound like linq, with the expression trees and lazy eval..
      the bits are really cool and also made me realize just how much i love generics and lambdas Big Smile

      atleast it seems gpgpu things are not not beeing worked on Wink
      cant wait to hear more (here's hoping for announcement @ mix Big Smile )
    • sylvan
      So I was going to play with the .Net 4.0 CTP and went through the huge hassle of downloading 14 separate files etc. etc., but when I actually load it up in Virtual PC the windows server installation on it asks me to activate! Is there some time restriction on the CTP or something or do I need to manually type in some key (I've looked, couldn't find one)?

    • androidi

      Before letting it load the OS for first time, set the clock to 2008 november (maybe october will work too not sure).

      Also use http://blogs.msdn.com/virtual_pc_guy/archive/2007/11/28/disabling-time-synchronization-under-virtual-pc-2007.aspx
      to prevent sync with host clock.

    • JasonOlson
      Yes, androidi beat me to it. My teammate Brian Keller has an excellent post about getting around several of the activation messages you might run into: http://blogs.msdn.com/briankel/archive/2008/10/27/visual-studio-2010-ctp-vpc-dealing-with-activation-messages.aspx.
    • JustinVP

      .NET 4 will have new APIs for lazily and efficiently enumerate files/directories.  The new APIs return IEnumerable<T> and are meant to replace the existing APIs that return arrays.  Some more info is available in the following blog post: http://blogs.msdn.com/bclteam/archive/2008/11/04/what-s-new-in-the-bcl-in-net-4-0-justin-van-patten.aspx
      I'll be blogging more about these APIs in the next couple of months, so stay tuned to the BCL team blog if you're interested in learning more.


      Justin Van Patten
      Program Manager
      Microsoft, CLR

    • Clinton Lee
      When they were speaking about using 'macros' for common tasks in c# for repeditive tasks (like property persistence, events on changes, etc), would a solution to this to be to introduce Aspects or AOP into the language? Have they ever thought about it? Or is it still too 'immature'? Just curious.
    • danielearwi​cker
      Enumerable.Empty is already there.
    • danielearwi​cker
      Steve, I want the same thing, an extensible language. It's a real shame that the "syntactic sugar" (anything that can be specified in terms of other language features: the using statement, the Linq queries) was not built using a macro-like system that user could also take advantage of.

      You may be interested in the answer I got to this question.

    • Charles
      What did you think?
    • trickyt
      (Really a wish for LINQ) Enumerable.Empty, i.e., return an empty sequence. Silly to ask for something so trivial but it's missing! And of course it needs a nice literal...

      Enumerable.Empty<T>() is of course the current way this is implemented, but what would a literal look like?  There's lots of literals used for it in other languages, but I mean in C# style.
    • FFE

      Very nice. Thank you.

    • exoteric

      Static extension methods: A non-feature.


      public enum Date { Yesterday, ... } public static DateTime Yesterday(this Date date) { var t = DateTime.Today; if (date == Date.Yesterday) t = t.AddDays(-1); ... return t; }


      Besides, having yesterday be relative to a given date is more generic.

    • Kareem

      In position 02:07 in the WMV File Version you can hear how he got a new email,...ROFL

    • Mohamoud

      Anders and Erik for the Nobel Peace Prize Angel

    • Santa's Envoy

      How about a post-release review for .NET 4.0? A lot of stuff has gone on through the year (notably Rx) which are terrific topics for future discussion. I think we're all interested on where C# , the BCL and .NET Framework as a whole are heading.


      It's a pleasure to see the rockstars of .NET on this masterful concert. Thanks guys.

    • Santa's Envoy

      Also, in reply to Anders, I have a suggestion for the extension property notation:


      public static class ExtensionProperties


          // The extended type appears after the colon, following the property declaration.

          // The "this" keyword refers to the extended (/indexed) object. 


          // Property.

          public static string Password : ICredential


              get { return this.Password; }

              set { /*Business logic*/  this.Password = value; }



          // Indexer.

          public static T this[int index] : IList<T>


               get { return this.ElementAt(index);  } 




      As for extension fields (which is what'd make extension properties something of its own), some engineering on the compiler would be necessary. Simply put: we'll need to have fields on the extension class, which will be static. By natural means, said field would be shared by all objects calling the extension property. Thus, some mechanism would be required to "bind" extension fields to the instances being extended.


      NOTE: The "property-hiding" scenario described was intentional. This should either hide the member or raise a compile-time error.

    • koistya

      New property system and property extensions in C# 5.0


      // A product type in this sample has a property Name of type String var product = new Product();
      // This will print "Product.Name.IsDirty: False" Console.WriteLine("Product.Name.IsDirty: {0}", product.Name.IsDirty);
      // Now let's try to update product's Name property product.Name = "T-Short";
      // And now this will print "Product.Name.IsDirty: True" Console.WriteLine("Product.Name.IsDirty: {0}", product.Name.IsDirty);
      // Then when you try to save this product in database, your Store Repository // will know for sure which fields must be saved and which can be skipped storeRepository.Add(product); storeRepository.SubmitChanges();

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.