Transcript from the November 14, 2006 C# Language Chat

These transcripts are eventually published here, but while we're waiting for that to occur, I'll post a copy here in my blog so that people can view it.


Chat Topic: The C# Language (https://csharp.net, https://blogs.msdn.com/charlie)
Date: Tuesday, November 14, 2006

Forum: https://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=9&SiteID=1

ScottNo [MSFT] (Moderator):
It's about time to start the chat - we have several people from the C# Team to answer your questions about C#. Let's start with some short bios from the team members:
Keith Farmer [MSFT] (Expert):
I'm Keith Farmer, a developer on the DLINQ team. They sometimes let me out for walks.
CyrusN -MS (Expert):
Hi All, I'm Cyrus, a developer on the IDE team. I work primarily with IntelliSense, but I like to dabble in just about everything.
Charlie Calvert (Moderator):
Hi, I'm Charlie Calvert, the Community Program Manager for the C# team.
Ben B [MSFT] (Expert):
A: Hi, I'm Ben and I'm a tester for the C# compiler.
Luke Hoban [MSFT] (Expert):
Hi, my name is Luke, and I'm the Program Manager for the C# Compiler. I'm currently working on bringing C#3.0 and LINQ into the Visual Studio Orcas release, and would love to hear any feedback from you guys.
ScottNo [MSFT] (Moderator):
Alright, let's get started - ask away!
Ben B [MSFT] (Expert):
Q: What’s this chat all about?
A: It's an opportunity for you to ask us any questions you may have about the C# language. For instance, you might have a question about an existing language feature or you might have questions about the changes coming in C# 3.0. Ask away!
Matt Warren [MSFT] (Expert):
Q: My first question is what is the status of LINQ to SQL versus LINQ to Entities?
A: Both projects are being worked on and both teams are aiming to ship with Orcas. We are aware of the overlap. :-)
Ben B [MSFT] (Expert):
Q: Thanks for the answer Ben but when it comes to C I am a noob.
A: If you're interested in learning more about C#, you should check out C# Express. It's our free C# IDE and it contains a lot of starter kits that help you get started learning the language. You can download it at https://msdn.microsoft.com/vstudio/express/visualcsharp/
Matt Warren [MSFT] (Expert):
Q: So both LINQ to SQL and LINQ to Entities will co-exist...at least initially?
A: That's the theory.
Luke Hoban [MSFT] (Expert):
Q: So how about you give us a brief rundown of what LINQ is so we're all on the same page? My understanding is that LINQ will allow me to write queries programmatically.
A: LINQ stands for Language Integrated Query, and as you say, it provides the ability to write queries over all sorts of data using general purpose .NET languages such as C# and VB. You can query over in-memory data, like arrays, or over XML, or over data in a database. In all of these cases, you use the C# language, without writing queries in quoted string literals as you would with many of the current approaches to querying.
CyrusN -MS (Expert):
Q: Currently extension methods must "emulate" non-static methods. Is there a possibility of relaxing this restraint so that for instance operator overloading may be possible via extension methods?
A: Eamon, that's a great question. Right now we're only planning to have extension methods in the 3.0 release. We've been considering in the future allowing far more "Extension Things". i.e. Extension properties/events/operators. We like the power and limited complexity of just methods, and that's why we're only doing that now. However, based on our future feelings and the feelings of the community we could extend things further in the future.
Luke Hoban [MSFT] (Expert):
Q: I have a question related to .Net 3.0, I installed .Net 3.0 on my computer with Visual Studio 2005 with no Orcas and no Windows SDK. I could not figure out how to add event handler to events. In PDC I saw someone just double clicked once and it was done!
A: You'll probably need to install the Visual Studio 2005 CTP extension for .NET 3.0 at https://www.microsoft.com/downloads/details.aspx?FamilyId=F54F5537-CC86-4BF5-AE44-F5A1E805680D\&displaylang=en. This should have some basic Visual Studio support for .NET 3.0.
Ben B [MSFT] (Expert):
Q: In JAVA a method can declare what exceptions it will throw...will we get this in C#?
A: Probably not. There are a few problems (e.g. scalability and versioning) with current implementations of checked exceptions that we'd like to avoid. For a great in-depth discussion of the pros and cons of checked exceptions (and the reasons we did not include them in C#), see https://artima.com/intv/handcuffsP.html
Matt Warren [MSFT] (Expert):
Q: Will they both exist indefinitely, or has the commitment been made to merge the two?
A: I can't really say, because nobody really knows. Both products are similar in most ways, but different in some ways. LINQ to Entities allows many more types of client side mappings. However, many of these mappings are slated for v2 of LINQ to SQL. LINQ to Entities offers a non-object yet mapped layer that is compatible with the current model of queries in strings and results in a DataReader. This is great for a customer who would prioritize mapping features and compatibility with the current ADO model over language integration and type safety.
Matt Warren [MSFT] (Expert):
Q: Will the next CTP/beta include LINQ to Entities?
A: The most recent CTP includes LINQ to Entities. It's in a somewhat prototypish state though. Expect a lot better experience in the CTP that will be named 'Beta1'.
Matt Warren [MSFT] (Expert):
Q: Are any experts here very familiar with LINQ to DataSet?
A: I am familiar with it.
CyrusN -MS (Expert):
Q: So the language features for LINQ as it's in C# 3.0 are finalized (syntax + semantics), but further evolution is possible after C# 3.0?
A: Eamon: The syntax/semantics are not finalized. However, they are certainly in a state where we're not intending to drastically or dramatically change them that much before the final release. Are there things (other than extension methods) that you'd like to see change? Are there areas you'd like to see us working on in the future?
Charlie Calvert (Moderator):
Q: What do you think of the pros and cons of the recent announcement by Sun to open-source Java and could or should such a thing happen with C#?
A: C# and the .NET API's are ECMA standards, and that is probably as far in that direction as we are likely to move. I think it would be great if we could share a bit more of the source to some of the API's, but I'm not holding my breath. For now, I just use Reflector. As far what Sun is doing, I think Sun wants to reach out to their community right now, and so they are finally giving Java developers what they have wanted for a long time. Probably a smart move on their part.
Matt Warren [MSFT] (Expert):
Q: The May 2006 CTP included LINQ to Entities? Or has there been a CTP since then?
A: I was referring to the Visual Studio 'Orcas' CTP's.
Luke Hoban [MSFT] (Expert):
Q: When will the next CTP/beta be available that has enhanced LINQ?
A: The December Orcas CTP will have feature parity with the May prototype CTP for the C# compiler, LINQ to Objects and LINQ to XML, but not yet for the VB compiler, LINQ to SQL or LINQ to Entities. In addition, the C# compiler, LINQ to Objects and LINQ to XML will include a number of design changes and bug fixes. The February CTP and further Orcas CTPs and Betas will see continued feature enhancements in LINQ to SQL and LINQ to Entities. On top of this, you will see improved IDE support for LINQ with each Orcas CTP starting in December.
CyrusN -MS (Expert):
Q: So with LINQ what have been some of the big problems you have encountered implementing it? What haven’t? And what (if any) are its limitations?
A: FallenIdol: I can tell you that getting IntelliSense working has been no small feat. We've had to do some major rearchitecting to get intellisense to work in all the areas that now make heavy use of inferencing. This is so we can provide a great experience within things like queries without you guys ever realizing all the complicated stuff that's going on behind the scenes.
Mads Torgersen[MSFT] (Expert):
Q: Hi, guys! I have a general question about current variable context return operator. Seems as "with" keyword in old VB. It'll be useful in sequential initialization, I think.
A: I am not sure I understand your question - are you asking for something like the "with" operator in VB? No plans for that. Object initializers are a bit like that, though, when you initialize a freshly created object, as in new Point { x = 5, y = 7 }
CyrusN -MS (Expert):
A: Rizwan: Did you try anything like: someButton.Click += new ... ?
Luke Hoban [MSFT] (Expert):
Q: Luke : I installed the Visual Studio Extensions for .Net 3.0 but it did not help me. I could not add event handler to any control, Neither from Designer nor from Code...
A: If the Visual Studio 2005 Extensions for .NET 3.0 did not work for you, then unfortunately I'm not sure whether what you are trying to do is enabled with the basic support that is available right now. If you send me mail directly at lukeh@microsoft.com, I can get you in contact with someone who could provide some more details.
Matt Warren [MSFT] (Expert):
Q: LINQ to DataSet piques my interest, is the team looking at easier ways to manipulate offline datasets? (That's always been a hassle for us, it would be nice to be able to manipulate datasets in a "Query Analyzer" type of way...)
A: With LINQ given us a common query paradigm it would be possible to design a 'Query Analyzer' that could operate over any queryable source.
Mads Torgersen[MSFT] (Expert):
Q: Somebody, I think Charlie Calvert said there wasn't much in the latest Orcas CTP for LINQ. Have I got that wrong?
A: No that's quite right. There will be in the next one, however.
Ben B [MSFT] (Expert):
Q: So with LINQ what have been some of the big problems you have encountered implementing it? Why haven’t we seen it sooner? And what (if any) are its limitations?
A: As with any big release, we've found cases in which our specs don't solve the customer problems as we intended and need to be reworked. We've identified new problems as we're implementing and we've sometimes had to design new language features to solve those problems.
CyrusN -MS (Expert):
Q: Cyrus : yes I did it from code and designer both even I tried to push in XAML but I could not see the events in IntelliSense
A: Rizwan: What do you mean "I could not see the events in IntelliSense"? Could you tell me *exactly* what you're doing, and *exactly* what you'd like to see.
Ben B [MSFT] (Expert):
Q: So with LINQ what have been some of the big problems you have encountered implementing it? Why haven’t we seen it sooner? And what (if any) are its limitations?
A: The reason we haven't released sooner is that we want to get the right set of language and IDE features included - and to make sure they are of the highest quality.
CyrusN -MS (Expert):
Q: what DataSources is LINQ compatible with? Can I write LINQ queries against a CSV file for instance? or ORACLE/MYSQL etc?
A: FallenIdol: If you open up your CSV file in a dataset (or DataReader) then you can write queries against that.
Mads Torgersen[MSFT] (Expert):
Q: Will extension properties be possible? This is useful to allow code to syntactically emulate built-in’s such as Array.Length and thus reuse the same code.
A: No. We're doing only extension methods this time around. We might think about properties for the future, but it is a much more heavy weight change, and extension methods do cover most of the scenarios.
CyrusN -MS (Expert):
Q: Cyrus: I tried to add a handler for Click event, it did not work with double clicking the control, I also tried it from the C# code like button.Click += new.... I did not get button.Click... from the IntelliSense
A: Rizwan: Are you using Avalon?
ScottNo [MSFT] (Moderator):
Hey guys! We're not even halfway through this chat - surely you have more questions for us to answer!
CyrusN -MS (Expert):
Q: Cyrus : No! I'm using Windows XP SP2 (Not Vista)
A: Rizwan: Luke's going to work with you to get you in contact with the Avalon guys so you can send this feedback along.
CyrusN -MS (Expert):
Q: Cyrus : I selected Windows Application (WPF)
A: Yup. Gotcha. Luke's going to help you out with this. We know we need to do more in the tools space here in the future. Right now in the CTPs the experience isn't too hot.
Ben B [MSFT] (Expert):
Q: Is this chat session going to be available online for us to review later?
A: Yes, you can view the transcript of old chats at https://msdn.microsoft.com/chats/transcripts/vstudio/default.aspx. It may take a week or two before this chat shows up, but it will be added.
Luke Hoban [MSFT] (Expert):
Q: Since LINQ introduced lazy evaluation, quite a lot of code can be executed in a normally-written program in a single statement. This makes debugging more complex. Do you have any solutions?
A: We're working on a few. For example, we are going to provide expression-level breakpoints on lambda bodies and query expressions, which will give you finer-grained control over stepping and breaking when working with the larger expressions that are common in LINQ. We're also working on support for a query results view in the debugger watch windows which will let you see the results of your queries while you are debugging, so that the laziness of the evaluation doesn't prevent you from seeing the intermediate results if you need to.
Charlie Calvert (Moderator):
Q: Thank You Mr. Charlie. I'll contact him with a CC to you
A: No problem. I'm interested in this too. We'll figure it out.
Matt Warren [MSFT] (Expert):
Q: Are there any plans to improve dynamic type generation, the way that LCG improved dynamic code generation? I could really use something like "lightweight type generation"
A: Yes. The runtime is investigating adding garbage-collectible types to the runtime. This would allow you to create many dynamic types knowing that the runtime will clean up the declarations & metadata when you stop referring to objects that use them.
Keith Farmer [MSFT] (Expert):
Q: Can I execute LINQ direct to SQL Server...like on a command object or whatever?
A: LINQ consists of the integrated query syntax, plus frameworks for querying data sources. In the case of LINQ to SQL, the compiler translates the query syntax into an expression tree, which LINQ to SQL then translates into SQL and passes that to the server. It'll interpret the results and materialize them into objects and return those back to you.
Matt Warren [MSFT] (Expert):
Q: Will LINQ to SQL always require generating entity classes at compile time?
A: LINQ to SQL does not require you to 'generate' them. You may use simply hand-crafted types of your own. However, it will likely always require you to have pre-defined types else there would be no point to static analysis by the compiler. The area we would like to improve on is the compiler generated anonymous types. We would like the runtime to have built-in anonymous types that would be compatible across assemblies.
Charlie Calvert (Moderator):
Q: Are you aware of any other database vendors working on LINQifying their dbs?
A: Third party's that want to create database access for LINQ need to create Providers. We are working on rolling out some guidelines for that process, but we have nothing to announce at this time.
Mads Torgersen[MSFT] (Expert):
Q: Any effort on being able to return an anonymous type from a function?
A: No. We'll try to make it as easy as possible to build named types when you're out of luck with the anonymous types. This includes auto-implemented properties with generated backing store.
Mads Torgersen[MSFT] (Expert):
Q: What will we be doing with C# 4.0?
A: That remains to be decided. My guess is we'll make it even cooler. :) We'll go public with our plans in due time, but we have to make them first.
Matt Warren [MSFT] (Expert):
Q: A large part of the existing .NET framework, and third party classes throw exceptions. When these occur in a query expression it's frequently useful to deal with them then and there (unexceptional Exceptions...), are you addressing this?
A: API's that throw exceptions will continue to throw exceptions. Doing so will end the iteration as the exception passes out.
CyrusN -MS (Expert):
Q: Sorry, does C#3.0=C#2.0+LINQ?
A: Dr. Wicked: if you look just at the language (and not the surrounding frameworks), then C# 3.0 is: C# 2.0 + Lambdas, Anonymous Types, Extension methods, local variable type inference, query comprehensions, expression trees, auto implemented properties, implicitly typed arrays, collection/object initializers. None of those are "LINQ" per se, but they all come together to provide a great experience around the LINQ APIs.
CyrusN -MS (Expert):
Q: Are LINQ and the other new C# features based on feedback from end developers or ideas from within MS?
A: We actually just pun up the random number generator and picked the set of things that it spit out :) In reality though, LINQ was heavily motivated by end user feedback. For years we've been seeing customers struggling with data manipulation and querying. We were also seeing a ton of duplicated work and wasted efforts across our entire customer base to support these scenarios. So, we decided enough was enough and that we really should do what we could across our entire stack of products (languages, platforms, DBs, etc.) to make this easier and more understandable across the board.
Matt Warren [MSFT] (Expert):
Q: Are other MS products already working on adding support for LINQ? Like AD for example? Any you can tell us about? Is there a list somewhere?
A: The AD team is actively working on a LINQ implementation. We don't have an official list.
CyrusN -MS (Expert):
Q: LINQ sounds kinda similar to the Apache Torque toolkit (https://db.apache.org/torque/) is it?
A: Well, yes. They both have a Q in their names. So they definitely "sound kinda similar"
ScottNo [MSFT] (Moderator):
8 minutes left!!
Charlie Calvert (Moderator):

Q: LINQ sounds kinda similar to the Apache Torque toolkit (https://db.apache.org/torque/) is it?A: There is an Object Relational component in LINQ. In fact that is one of the important parts of the technology. However LINQ brings a lot of other general tools to the language, which when taken together adds functional (declarative) programming to C#. This is a fairly important new approach to development for C# programmers. So yes, it has something in common with Torque, but it has a larger scope that will change not only database programming, but also the way we treat data inside our programs, in XML files, and in many other scenarios.
ScottNo [MSFT] (Moderator):
5 minutes left! Get those last questions in before it's too late!
ScottNo [MSFT] (Moderator):
Alright everyone, we're about done. We'll answer your last few questions and finish it off...
Mads Torgersen[MSFT] (Expert):
Q: Will there be a Tuple<A,B> type in the base framework for the LINQ release?
A: No. We think anonymous types are the way to go for LINQ. Gives you proper names and stronger type checking, plus data binding etc. Tuples are good for many things, though; we may look at them in the future.
ScottNo [MSFT] (Moderator):
Q: I'd like to ask about the WMI code. I have been using ManagementObjectSearcher and QueryObj but it does take a lot of system resources (around 10MB). Is there a better way in C# to gather performance data?
A: Sorry, we're really not experts on this. You can contact us through our blogs (like mine: https://blogs.msdn.com/scottno) and we can track this info down for you...
Ben B [MSFT] (Expert):
Thanks for the great questions! If you have any further questions, you can email me at bebrinck@microsoft.com
Charlie Calvert (Moderator):
A: Good bye. Thanks for dropping in.