While covering TechEd 2003 for us last week, Chad Myers managed to sit down and interview Eric Gunnerson, a Program Manager in the Visual C# .NET group at Microsoft. In the interview, Eric discusses the future of C#, other languages, and more.
While covering TechEd 2003 for us last week, Chad Myers managed to sit down and interview Eric Gunnerson, a Program Manager in the Visual C# .NET group at Microsoft. In the interview, Eric discusses the future of C#, other languages, and more.
From the article:
I’m also a big fan of foreach. If I only had a small percentage of the money wasted worldwide writing:
for (int i = 0; i < arr.size; i++)
{
Employee e = arr[i];
}
I’d be set for life.
‘Money wasted’ … haha – how about all those CPU cycles you wasted on computing the size N times instead of computing it once and storing it in a variable.
DOH!
You could inline the container size method so that it is inline expanded at compile time. Therefore it would only be computed once.
i think gcc does this automatically
If you inline a method like a object.size() method for example:
class Example {
int _size;
…
public:
int size() const { return _size; }
};
Than at a loop such as:
for ( int i = 0; i < Example.size(); ++i ) {
…
}
The inline function expands to this at compile time:
for ( int i = 0; i < Example._size; ++i) {
…
}
And not have to put up with C ‘hash’ complications and compromises. Although almost anything is better than C++ or Java. I do, however, like C.
C is a vendor implementation language used for building systems with centralized control data structures. I’d rather use an organic and flexible language like Standard C++. It’s not too difficult to learn Standard C++ as long as you don’t have to learn one hundred other languages such as C#, Java, VB, etc.
If this is a propery, then the properties get() method will need to be evaluated at each iteration. If it is not a property (just a member value) it can be fetched into some temporary storage (register, etc), however this is not called ‘inlining’.
Anonymous’s example code with Example.size() expanding to Example._size is false in the general case. Maybe some compiler(s) support this optimisation when the function immediately returns a member value, but for no other circumstance could it do this, since the size() function maybe side-effecting.
My apologies, Anonymous’s example is correct in this circumstance. I was attempting to correct the idea that ‘inlining’ means the results of the function would be stored after only an initial call. _All_ of the function is written inline and computed for each iteration.
The inline function is expanded in place at its point of call and is a suggestion to the compiler. This behavior is supported in most compilers, such as g++. It would be expanded like in the above example.
Side effects with inlining are managed by placing all inline functions into header files. Than make sure to include headers only once through preprocessor directives such as #ifndef.
It is possible that some compilers would not support inlining, but than that wouldn’t be a good compiler IMO.
umm….it depends on how the arr class is implimented.
if it is implimented with a flat array (such as a buffer) arr.size is constant.
if it is implimented as a linked list, calculating the new arr.size is not that difficult and would not waste that much.
‘Money wasted’ … haha – how about all those CPU cycles you wasted on computing the size N times instead of computing it once and storing it in a variable.
You’ll notice there aren’t any parentheses after arr.size. This means that size is a member variable of arr, not a member function. The array’s size isn’t being calculated each time it is requested. And besides, it’s just a stupid example, stop being such a prick.
The only problem with ar.size is that it means that size is public, but with the inlined size() method, _size is a private member.
I think that application server frameworks and their development solution languages like C# are well suited for most programmers and businesses, however I wouldn’t use them because I know that the libraries are controlled by the vendor and that the vendor will ultimately discontinue support because they need to keep making money. Since the libraries are not open source, than they are dead in the water if the vendor decides to move on.
Side effects with inlining are managed by placing all inline functions into header files. Than make sure to include headers only once through preprocessor directives such as #ifndef.
I don’t really have time to explain, sorry, but no. Google yourself some info on side effects.
Another Anonymous –
You’ll notice there aren’t any parentheses after arr.size. This means that size is a member variable of arr, not a member function.
Except that it is c#, which can have underlying get()/set()methods for properties. I don’t know if this particular example is just a normal member value or a property, someone with the reference can speak up.
You’ll get more speed advantage by avoiding/reducing the loop, than avoiding a method call.. I’ll just bet that some people will use an O(n2) search algorithm, but will avoid a method call for speed 🙂
I know people have favourite languages but I’d rather pursue and get good at languages that would make me some money.
Is there really much money wasted on things like this?
I’m not a professional programmer, but I tend to find that most of my time is spent on figuring out actual logic problems, rather than trying to work out how to make a simple loop.
I can’t really see how this is going to save any noticeable amount of money.
While this kind of addition doesn’t pollute the syntax too much on its own, applying simple things like this all over the place can lead to a bloated syntax making it harder to keep track of, without really adding any value.
… I’ve just always used this syntax for those types of loops:
for(int i = 0, n = arr.Length; i < n; i++) {
// blah
}
That’s the shell program in Windows 3.1! 🙂
ActiveWin.com: One of the largest criticisms (at least that I’ve heard) of C# today is that it copies from, or is a cheap knock-off of, Java. What do you say to these critics?
Eric Gunnerson: When we started with C#, we wanted a language that was comfortable for C and C++ programmers. Because of that, much of the C# syntax comes from C and C++. Java took a similar approach, and since both languages run in managed environments, it’s not surprising that there are more than a few similarities.
I’m so tired of hearing this same line from everyone at Microsoft. Can’t you just be honest? A blind baboon could tell that you borrowed a lot more from Java than some C syntax. If you don’t tell me the truth about your programming languages, I am certainly never going to believe you when you talk about things less easy to prove (like whether you are an illegal monopolist). Act adult, please. Great thinkers acknowledge their teachers, even as they point out their flaws.
“A blind baboon could tell that you borrowed a lot more from Java than some C syntax”.
Like what dude ? Please tell me EVERYTHING that C# took from Java (to make your point valid you must write only things that exists ONLY in Java and C#). Please, don’t run into Smalltalk….
ActiveWin.com: What is your vision for C# on platforms other than MS Windows in the future? (Submitted by mOOzilla)
Eric Gunnerson: I’m afraid I can’t give a very definitive answer on this one.
Translation: “Fuggedh about it!”
Actually, it is quite possible that not statically calculating the list size causes the alogorithm to become O(n-squared). If the size() operation is O(n) is it usually is for lists, then a dumb search algorithm would be O(n-squared).
the size() operation is O(1), not O(n).
I find it interesting how some people nit-pick an interview. Eric presented a simple loop to illustrate a point and 75% of the posts rip that code sample apart… so be it. 🙂 I think his point was more about maintainability as opposed to performance.
Also, I agree with Peter0 on the fact that C# borrows alot from Java. And maybe not just C# but also the .NET base class library. If you look through the .NET base class library you’ll notice MANY similarities and direct correlations. I can’t believe that a similar design goal would yield such direct similarities without the .NET team borrowing from Java.
I’ve been working with C# and .NET now for about 6 months and I really enjoy it (although I come from a mainly VB 6 background with some C++, Java, and Perl in there too). I like Visual Studio and it’s built-in debugger.
My $0.02
>I’m so tired of hearing this same line from everyone at Microsoft. Can’t you just be honest? A blind baboon could tell that you borrowed a lot more from Java than some C syntax.
Well, what exactly DO you want to hear? Firstly, AFAIK Dennis Ritchie, Brian Kernighan, et al. designed C, and Bjarne Stroustrup designed C++, both groups did not, in fact, create them for Microsoft, nor while working at Microsoft. While Microsoft has adopted the two languages to a large degree, but your original question was “Why can’t Microsoft ever give credit to someone else?”. Well, they are. Just not to Gosling and friends as you would have them do. But I’ll get to that.
Java and Objective-C draw heavily upon design principles set forth by Smalltalk. C drew upon Algol-60 (among others). Here, the fact of the matter is that while C# did take a good amount of semantic (hey, and syntactic too while we’re at it) material from Java, most of it was just improving upon language design principles being preached before either Java or C++ were around. As most good OO evangelists would tell you, single inheritance should be enforced, and a decent way of managing this is to have a root class, from which all objects are derived. Ok sure, C# takes this queue from Java, and it’s completely different in C++. However, open up your programming languages book, and you’ll find that Smalltalk had single inheritance and a magical ‘Object’ root class long before Java devised the same.
Ok sure, there may be a few things which C# took directly from Java (or more likely, a few things with new names which C# took directly from Java), but that’s to be expected in this business. Further, there are a whole bunch of things which Java completely borked, doesn’t have, or C# simply blows out of the water. Assembly scope comes to mind.
marcthepirate: Ok sure, there may be a few things which C# took directly from Java (or more likely, a few things with new names which C# took directly from Java), but that’s to be expected in this business.
Expected, yes. Good, yes. I like .NET. I just wonder why everyone at Microsoft is so shy about admitting that they looked at Java when they were designing C#. Like we would think less of Microsoft because they borrowed someone else’s ideas.
Let me assure you, Microsoft, I couldn’t ever think less of you than I do already!
In a sue-happy corporate culture, everyone knows the ramifications of admitting publically that some ‘ideas’ came from a competitor’s product.
In a sue-happy corporate culture, everyone knows the ramifications of admitting publically that some ‘ideas’ came from a competitor’s product.
Especially when Microsoft’s already been sued twice by that specific competitor in regards to that specific product (or set of products I guess, the JVM and the Java language).
I thought that was a good read. From what I’ve seen, C# looks okay. I like the .NET idea, and am a fan of the Mono project too. C# would be my language of choice for writing a .NET application. I only wish that implementing SOAP enabled software was as simple in C# as it is in Perl with SOAP::Lite. I think that the C# way of dealing with SOAP is cumbersome and ugly after reading about in the O’Reilly SOAP book, and trying it out myself.
Microsoft stole Suns solution architecture, the idea of a framework and virtual machine.
If you created an application server than it would look similar to .Net and Java. What Microsoft stole is the idea, they didn’t necessarily copy Java source code.
The vendor can offer more reuse of vendor research and development through framework inheritance, and yet they don’t have to give away the implementation, so it can remain 100% in their control.
Microsofts old model was based on a less rich architecture, that didn’t offer as high a quality of reuse.
The over all fact though is that both of these architectures are not owned by the users, so you are renting them. If the vendor decides not to support them in the future, than your applications will become invalid. Just like a renter that gets evicted because the owner raised the rent too high.