Month: September 2005

This was a comment that came up several times at the PDC from various sources: “What’s so revolutionary about this stuff? We’ve been doing this kind of thing for years!” On the one hand, what’s unique about LINQ is how it’s built, it’s openness and flexibility, and it’s unification of data querying across domains. But on the other hand, yeah, let’s be honest: as Newton would say, if we’re seeing further, it’s only because we’re standing on the shoulders of giants. My standard response to this line of thought is: there are really only 15 good ideas in computer science and all of them were discovered thirty years ago or more. What happens is that the programming world just rediscovers them over and over and over again, each time prentending like the ideas are brand new.

Erik Meijer had a good comment in the languages panel that if you want to know what the next big thing in programming is going to be, all you have to do is look at what was hot twenty years ago. Because that tends to be the length of time it takes for the wheel to turn a full crank…

Looks like Carl and Co. have put up a .NET Rocks show that Amanda, Erik and I recorded at the PDC. We had a very interesting discussion, ranging from LINQ to what it was like for Erik to be a “Head in a Box,” definitely something for everyone! Check it out!

I’ve been thinking about something Wes said last week about C# 3.0 and VB 9.0. After viewing my PDC presentation slides, he noted:

The difference in focus between the C# and VB team is becoming much more evident: The VB team is opting for greater relevance and convenience in the short term, while the C# team is trying to avoid creating long-term baggage.

I think this succinctly describes what’s going on in regards to VB’s embrace of XML integration into the language and C#’s cautiousness around it. If you talk to the C# team about this, you get some very explicit concerns about the long-term impact that integrating XML into the language might have. I would characterize these concerns in my own words as:

It is extremely risky to put some portion of your language design in the hands of another language design team. In other words, if VB integrates XML as it stands today into our language, what happens in the future as the XML standard continues to evolve? What we do today may be sufficient and there may not be any demand for adding any further features the XML standard may add. But maybe not. And those features will not necessarily have been designed with an eye towards whether they’ll work well in VB. Heaven knows we’re going to have enough issues shoehorning XML into the language, what happens if we hit some really sticky issue in the future? What if XML heads in a direction we’re not willing or able to go in?

It is extremely risky to tie yourself explicitly to a technology that may or may not be here 15 years from now. Right now, XML is king. But what happens if some other technology comes along and knocks it off its perch? What if things radically shift in some other direction and XML suddenly becomes a side track instead of the main line?

In truth, both of these concerns are valid. In fact, VB’s own history has borne them out — all one has to do is replace “XML” with “COM” and you have the whole VB6 to VB.NET question in a nutshell. I mean, it doesn’t seem likely today that XML will ever lose its primacy, but if you could take a time machine and go back to the pre-.NET days and ask Don Box if COM was going to be supplanted in a few years time, what do you think he would have said?

So, if integrating XML is so gosh-darn risky, then why are we doing it? Are we nuts? My answer is: not exactly.

Like so many things in life, it’s all about tradeoffs. The C# team looks at the problem and says, “It’s more important to us that we design a language that is as minimal as possible and whose pieces are guaranteed (as much as anything ever is) to retain relevance for the forseeable future. Therefore, we’re willing to sacrifice some usability and some programmer speed to ensure this goal is reached.” Perfectly valid. The VB team, on the other hand, looks at the problem and says, “It’s more important to use that we design a language that allows people to solve the problems that are confronting them today in as simple and straightforward manner as possible. Therefore, we’re willing to take the chance that some feature that is fantastically useful right now may lose relevance in the future and perhaps even become almost entirely useless (c.f. Gosub, On … Goto, Open/Close, etc.).” Also perfectly valid.

What it boils down to is that we’re willing to make the bet that the overall benefit of integrating XML now is going to, in the long run, outweigh any possible downside. Are there people who are going to say we’re crazy? Of course. How can we tell who’s right? Check back in 15 years. In the meantime, I leave you with the conclusion to Wes’s quote above:

The end result is that Visual Basic is definitely going to be much more fun to program.

Over in the LINQ MSDN forums, the question came up: which is better, Select/From (as VB does it) or From/Select (as C# does it)? To quote from the thread, here’s the C# side of it, straight from Anders:

There are a multitude of reasons why select comes at the end and not the beginning of a query in C# 3.0. The more important ones are:

(1) Statement completion (Cyrus’ blog has a good explanation).

(2) Order of execution. The C# query syntax lists operations in the order they are executed.

(3) Scope of “from” variables. SQL is strange in that scope flows both upward and downward. In C#, scope extends from the point of introduction to the end of the query, which seems much more intuitive.

(4) Large select expressions. In SQL, because results are rectangular rowsets, select clauses tend to be fairly simple. However, when querying objects and XML it is quite common to have large select expressions that construct entire object graphs, possibly with multiple nested queries. Trying to understand a large select expression written in terms of variables that haven’t been introduced yet (and may not even be visible on the screen) is quite confusing.

(5) Even if we picked SQL’s ordering, the similarity would be skin deep. There are lots of other differences. For example, C#’s built-in operators and quite different from those of SQL. I actually think the different ordering is a benefit because it makes it quite clear that this is not SQL.

Note that XQuery’s FLWR (“flower”) expressions have the same ordering as C#’s query expressions–I suspect for some of the same reasons.

Anders

and here’s the VB side of it, straight from me:

Speaking from the VB team perspective…

As is already obvious from this thread, Select/From ordering is going to be another one of those religious issues like case insensitivity that people are going to be arguing about for the next twenty years and beyond. As with case sensitivity, both sides can marshal perfectly reasonable arguments as to why their choice is the One True Way(tm) and why the other side is Consorting With the Devil(tm). I say this knowing that nothing I say now can influence that outcome and that this discussion (in the larger sense) must always end in tears, recriminations and Godwin’s law. But it’s worth saying nonetheless.

With that out of the way, I think this thread has already covered many of the relevant points relating to why VB chose to say Select/From instead of From/Select:

* For many, many programmers and for many, many VB programmers, specifically, SQL is a very familiar language. Leveraging a huge existing base of knowledge (and programmed muscle memory) makes the LINQ support more understandable and usable straight out of the gate.

* The SQL ordering of clauses is a time-tested convention that has been in continuous use for decades.

* VB emphasizes English readability. As noted in the beginning of the thread, the SQL ordering is more English readable than the obverse.

Anders raises some objections to the SQL ordering, but on the balance, we believe that the benefits outweigh the limitations. Specifically, I’d say:

* Statement completion is a significant question. We have a bunch of ideas as to how we could finesse this in the IDE, but we haven’t reached a point of being really able to try them out. This may be a real sticking point, time is just going to tell.

* I don’t agree with Anders’s points about the difficulty of understanding SQL’s clause ordering. Although some variants of SQL have invented phenomenally complex and bizarre sets of rules about how binding works, the basic rules about binding seem to have been graspable by millions of SQL programmers over the years without too much pain and suffering. As long as the rules remain relatively simple and straightforward, there don’t appear (to me, at least) to be major hurdles in implementing a very understandable Select statement where From is in the middle of the statement. Reasonable people can disagree on this point, however.

* Ultimately, we don’t believe that people will be confused as to whether this syntax is SQL because it will become almost immediately obvious that it isn’t once a programmer works with it for more than a few minutes. It’s a problem that will sort itself out on its own relatively quickly.

I would close by saying that the VB team, overall, values practicality over dogmatism. From a pure syntatic perspective, clause ordering is not fixed in stone – one could support both a Select/From order and a From/Select order without much difficulty. Indeed, we’d like to look at how clauses such as Where and Order By can be used on their own without requiring a Select or, perhaps, even a From. So while we will continue to support Select/From, other possibilities may be investigated if it becomes obvious that they make the language more usable in some strong way.

That’s about it. We now return you to your regularly scheduled religious debate…

PaulVB Team

And that’s where it stands at the moment… I’m sure I’ll get a few comments on that, though.

Paul Vick and Erik Meijer – Dynamic Programming in Visual Basic – This is me and Erik talking about dynamic stuff in VB. We were planning on talking about some of the new XML stuff as well, but didn’t even get to it! Another video, I’m sure…

Hopefully more to come. If you have specific topics you’d like to see, let us know! Based on some of the comments, we may still have some kinks to iron out in the presentation department, but videos are easy enough to do and we’d love to talk about what you’re interested in hearing about!