Sharp Code

Code has never been this sharp!

  Home  |   Contact  |   Syndication    |   Login
  22 Posts | 0 Stories | 49 Comments | 0 Trackbacks

News

Paul Montagna is a hobbyist software developer who aspires to become a professional in the future. Currently studying Software Development at University he is familiar with .NET, C++, PHP, Perl, Python, VB5/6 and Java. Preferred language is .NET but i am competent enough to code in any of the mentioned languages to an extent :)

Archives

Post Categories

Blogs!

As a VB.NET programmer i only really use C# for XNA and other projects when i don't have a say on the matter. Recently i have begun to think about making a full blooded transition to C# after having some great success with it (specifically in XNA) and its not because VB.NET doesn't cut it. It is great but C# is also fantastic in my opinion, as it took features from some of the more distinguished languages avaliable, C++, Java and Object Pascal to name a few. Feature wise they are perfect for me no issues at all so before making any sort of decision i thought i would do a bit of research. So i decided to take a look at the MSIL of two simple applications in C# and VB.NET.

After comparing the MSIL of both this is what i realised:
  • VB.NET contained 4 extra opcodes which were NOP (No Operation)
  • VB.NET generated two extra variables (types Int32[] and Bool)
  • VB.NET certainly used more OpCodes
The code was a simple for each loop like so:

        Dim intArr() As Integer = {1, 2, 3, 4}
        For Each i As Integer In intArr
            Console.WriteLine(i.ToString())
        Next

       and..

        int[] intArr = {1,2,3,4};
        foreach (int i in intArr)
        {
            Console.WriteLine(i.ToString());
        }


I am yet to test the execution speed of either application which will be one of my next tasks after a little more research. On a side note the C# code compiled was of size 5.0 kb and the VB.NET code compiled to 11.0 kb. I'll be sure to post more after i conduct some more research. Also note i am in no way trying to change peoples mind on what language to use, i don't believe the execution difference would be that noticeable anyway.

And here is another article which sort of explains the same thing as me but in a little more detail: VB.NET vs C#: Performance
posted on Wednesday, April 23, 2008 9:40 PM

Feedback

# re: C# vs VB.NET: Performance, Part 1 4/24/2008 12:40 AM Blogus Maximus
Perhaps you should post the IL code too. Anecdotal evidence is fine, but seeing the actual code that's generated is even better, IMO.

# re: C# vs VB.NET: Performance, Part 1 4/24/2008 12:41 AM Blogus Maximus
FYI... that article you link to is 6 1/2 years old and 3 compiler versions ago... not sure how relevant it is today.

# re: C# vs VB.NET: Performance, Part 1 4/24/2008 12:49 AM paul
Yea my next article i plan on being a lot more detailed even finding out more about some of the stranger opcodes.

Oh and Chris yea i know :) well i guess it still is though as all my testing was done with VS 2008 and the 3.5 framework.

# re: C# vs VB.NET: Performance, Part 1 4/24/2008 12:51 AM paul
And if you want to see the IL code for the moment to just be sure you can just chuck the code in ;)

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: