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.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
Awesome! Thanks guys. Great, great stuff... please more!
--edit--
what where you talking about there in the beginning btw?
--edit2--
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
C
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
perhaps you could have an E2E with just eric (eric talking to eric) and talk about stuff like that
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
--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"
--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
The discussion about functional vs imperative was really great though i dont think that battle will end anytime soon
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
again, great stuff
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,
C
A few things I would like to see in C#:
Long term for .NET:
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?
The IBM AS400 uses this facility very well to embed SQL within COBOL, RPG and C code:
http://publib.boulder.ibm.com/infocenter/systems/scope/i5os/topic/apis/debug1.htm
Can Visual Studio do this now? I asked a few years ago and was told no.
About half-way through Jim talks abot his perspective on the Concurrency problem.
C
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?
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#
- 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
ex:
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
Anders is always a pleasure to see/listen to
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.
Anything with Erik Meijer is worth watching -if only to find out which colourful shirt he's going to wear
Thanks a lot Charles for this video!
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
-edit-
btw where can we get those cup<T> (cup of T for any non geeks out there) cups
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.
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.
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;
}
}
Notes
Benefits
Downsides
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,
Ralph
long time ago (2006) there was something called the accelerator project, there was even a channel9 video about it:
http://channel9.msdn.com/shows/Going+Deep/Programming-in-the-Age-of-Concurrency-The-Accelerator-Project/
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
http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-The-Zen-of-Expressing-State-The-State-Monad/
again, this is just me extrapolating from a bunch of out of context statements and my own wish for something like that
--edit--
the accelerator project is still around it seems, but it hasnt been updated for a while :
http://research.microsoft.com/en-us/projects/Accelerator/
there are bits you can download though
charles i know ive nagged about an update on accelerator but pleeeeese try and get something from them or duffy or whoever
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!
C
Remove the tin foil hat,
C
i certainly dont want you, channel9 or the interviewés to get in trouble from the bosses because you said too much
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
atleast it seems gpgpu things are not not beeing worked on
cant wait to hear more (here's hoping for announcement @ mix
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.
.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.
Cheers,
Justin Van Patten
Program Manager
Microsoft, CLR
You may be interested in the answer I got to this question.
C
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.
Very nice. Thank you.
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.
In position 02:07 in the WMV File Version you can hear how he got a new email,...ROFL
Anders and Erik for the Nobel Peace Prize
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.
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.
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();Remove this comment
Remove this thread
close