Anders Hejlsberg - What influenced the development of C#?
- Posted: Jun 18, 2004 at 1:05 PM
- 37,754 Views
- 9 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- Mid Quality WMV (Lo-band, Mobile)
- WMV (WMV Video)
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.
Follow the Discussion
For example, the using construct "knows about" the IDisposable interface, foreach knows about IEnumerable (well, GetEnumerator at least), lock knows about Monitor, and the list goes on.
This is a clear departure from C++, where the language is well isolated from whatever code the user writes.
I suppose that with support for reflection and boxing, it may have been unavoidable. Am I the only one who felt a little uncomfortable with that?
Don Syme and Andrew Kennedy from MSR Cambridge came up with the implementation techniques used for .NET generics - and they beat pretty much everything else out there in terms of expressibility, speed, and performance. Note that the original paper is from 2001: it can take a LONG time to take a good idea from research and get it into the hands of customers!
- Sparky
I agree that C# and the framework were closely tied together during their development and various features of one influenced the other. However, I don’t believe those features of C# as a language are as tightly coupled with the framework features as you mentioned. Those are just the implementation details of C# on the .NET platform. The ‘using’ construct means “free up this resource after this block exits”. From the language perspective it doesn’t matter how it goes about freeing the resource, just that it frees it. Similarly, the ‘lock’ keyword is a generic (relatively) thread synchronization feature. It just so happens that the C# .NET compiler uses a Monitor to achieve that. Same goes for the foreach statement. It’s to iterate over a collection. The fact that the compiler translates that into the whole IEnumerable deal is a platform implementation detail.
In other words, C# using, lock, and foreach know nothing about IDisposable, Monitor, and IEnumerator any more than the C++ operators new and delete know about the CRT malloc and free functions that will likely get called as a result of those operators.
In the CLR, I think they have also carefully side-stepped the dependencies. The 'box' instruction, for example, has to specify a type handle to the boxed type you want returned. So, you could (in theory at least) write your own Int32 struct and use it instead of the framework's.
However, C# doesn't seem to side-step the dependency. In the docs for 'using', it states: "The object you instantiate must implement the System.IDisposable interface." This is in contrast to the docs for 'foreach', where it seems that the issue was side-stepped: "Evaluates to a type that implements IEnumerable or a type that declares a GetEnumerator method."
I haven't tested the statements in MSDN's 'using' page against the actual implementation, so it may be that the docs are just wrong.
I'll test it and write again here with the results.
Nice catch sparky ;o))
But this program will answer you that.
using in C# Rocks !
foreach in C# Rocks !
using System;
using System.Collections;
namespace Test
{
class MyGetEnumerator
{
public IEnumerator GetEnumerator()
{
yield return "foreach in C# Rocks !";
}
}
class MyDispose
{
public void Dispose()
{
Console.WriteLine("using in C# Rocks !");
}
}
class EntryPoint
{
static void Main(string[] args)
{
MyDispose myDispose = new MyDispose();
using (myDispose)
{
// Cast white magic spell
}
MyGetEnumerator myGetEnumerator = new MyGetEnumerator();
foreach (string message in myGetEnumerator)
{
Console.WriteLine(message);
}
}
}
}
error CS0029: Cannot implicitly convert type 'Test.MyDispose' to 'System.IDisposable'
namespace Test
{
class MyDispose
{
public void Dispose()
{
Console.WriteLine("! using in C# Rocks");
}
}
class EntryPoint
{
static void Main(string[] args)
{
using (MyDispose myDispose = new MyDispose())
{
// Cast white magic spell
}
}
}
}
Remove this comment
Remove this thread
close