In one of my C# books, this is written:

"if you write this application in VB.NET or any other language compliant with the .NET CLS, you will have compiled it into more or less the same MSIL. By design, IL code created from different languages is virtually indistinguishable"

I was then asked this question: Why is there a difference between C# and VB in speed? I don't understand the above statement very well, but it seems to be saying that we end up with almost the same executable code.

I couldn't answer the question, so I thought I would ask you guys. Thanks!

more or less the same MSIL perhaps just means C# and VB can be processed by the same JIT-compiler, but because of differences in the MSIL code there may be differences in executing time.

In pre .net Id have agreed, in .net itself its not something Id given much thought.

All .NET code compiles identically. It is first compiled to CIL (formerley MSIL) which is then interpreted by the .NET CLR and is compiled to machine code.

http://en.wikipedia.org/wiki/Common_Language_Runtime

http://en.wikipedia.org/wiki/Image:Overview_of_the_Common_Language_Infrastructure.png

There should be NO difference between the .NEt languages in speed (possibly with the exception of Managed C++ as MS seem to have far more compiler optimisation options for that - but i think thats mainly due to ms being wierd as opposed to a technological limitation)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.