Daily Archives: March 11, 2004

Q&A with VJ# and C# Team on Generics

From a conversation with Brian Keller, the PM on the VJ# team and some additional input from C# dudes, Dan Fernandez and Eric Gunnerson .

For further enlightenment, read Jason Clark’s introductory article on “what is generics…“ from Sept 2003 MSDN Magazine.

Q) I know I can’t code VJ# for beans, but why can’t I create generic classes in VJ# like I can in C# and VB.NET?

A) VJ# can consume generics but cannot create generics.

Q) But Generics is part of the CLR. Why is it acting like it is only a language enhancement for C#, VB.NET and C++.NET?

A) Generics is baked into the CLR as much as other data types are built into the CLR and IL. The way generics are implemented is that when you use a generic type, a “placeholder” is added where the generic value will be used in the resulting IL.  Only on first execution is a specific version of the specialized class created.  Once you get to the IL level, there is nothing language specific going on, it’s all the CLR.  The BCL has several examples of generics including collection classes available in the System.Collections.Generic namespace and ObjectSpaces, an object-relational mapping tool is using generics for their underlying data structures. Generics are present at the IL level – that is, if you declare a parameter as a List<int>, you will get that type if you use reflection on the parameter.

Q) So if it is in the CLR and I can’t fully use it in VJ#, does that mean it is up to the language developers to leverage it (or not)

A) Correct, generics were not added to the Common Language Specification because it puts a large onus on language developers that would then need to implement generic data types in their compilers. It will likely be added to the CLS in the Orcas timeframe (following Whidbey).

Q) Aha! This is definitely a point of confusion/contention because at first many people kept saying that generics is a C# language enhancement and suggesting that it did not exist in VB.NET, which pissed off a lot of VB people. Even Elden Nelson wrote something that was interpreted that way in an editorial for ASPNetPro. Then the word was “no no no – generics is part of the framework and therefore available everywhere…” But that statement doesn’t quite work as we see with the lack of the implementation in VJ#. So what we are really seeing is variations on implementation: C# does it one way, VB.NET does it another and VJ# does it another. The lack of the “consuming“ implementation in VJ# is not really any different than the language difference, for example, between how we declare a variable in VB.NET and how we do that declaration in C#.

A) You are correct, C#, Visual Basic, and C++ will support creating and consuming generics.  J# will only support consuming generics at this time, largely because the Java community has yet to start using generics.

Q) Let’s qualify “Consume generics” for our audience: does that mean if I have an assembly that I wrote in VB or C# and it contains some generic custom classes, then I can use those from a VJ# assembly just as I would access the system.collections.generic classes?

A) Correct, you can use these classes, you simply cannot create your own.

TechEd 2004 BOF – another Women Who Code BOF

Here’s the description:

This will be an opportunity to continue conversations begun at PDC as well as the TechEd 2004 Women in I.T. Luncheon. Meet other women who are programmers and discover that you are not, in fact, an alien! Chat about our visibility in the industry and other related issues that sometimes make us scratch our heads and wonder.

I tried to word this carefully so that nobody would start in on me. If you have any questions in that vein, just read this. The session is not intended to be some political bra-burning event. Do you know how expensive bras are, anyway? At PDC we had a cool discussion that involved also a lot of men who were curious about their daughter’s future in tech or trends they have noticed in university etc.

Personally I just love meeting other women at conferences who are programmers. I don’t feel quite so out of place. We have an abnormally high percentage of women in my user group, too.

There is also going to be a Women in Tech luncheon with a panel, similar to last TechEd. So I will pull some strings to ensure that this BOF is AFTER that luncheon.

Oh and go vote! It’s www.ineta.org/bof  then “proposed sessions”.

There are a bunch of other great sessions up there already, too.

code generation starting to show up on my own radar

For some reason, I have not been that interested in code generation up until recently. I have looked only briefly at some of the tools out htere and not at all at others. I guess I saw them as an all or nothing situation – rather than leveraging code generation for bits and pieces of my development and then going back to my old control freak usual self for the rest. However, recently two things have been turning my head. One is constant exposure to it through Kathleen Dollard and the other was seeing an example of code generation that Jason Beres showed in our user group meeting on Monday. I watched him, with a button, create pieces of code that I am writing by hand – the way I would write them. It was a “v-8” moment. Can’t drop everything and play with it at the moment, but it will happen – hopefully before the next time I start coding up a class full of properties that are more than 50% matching the structure of a table in my database.