Is C# really better than VB 2005

  • Thread starter Thread starter Newish
  • Start date Start date
N

Newish

Hi

Can someone please enlighten me. I hear different things. Some
suggest that the difference between the languages in terms of
capability and versitility has really narrowed down to a point where it
does not make any difference which language you use. Some suggest that
C# is still far superior language.

Thanks in advance.

Newish
 
Newish said:
Can someone please enlighten me. I hear different things. Some
suggest that the difference between the languages in terms of
capability and versitility has really narrowed down to a point where it
does not make any difference which language you use. Some suggest that
C# is still far superior language.

well, C# is faster than VB.Net at least.
 
well, C# is faster than VB.Net at least.

Is there a new version of C#?

In the VB.language newsgroup there is lately a message given where a product
written with VB.Net outclasses completely an unmanaged written C++ program.

What was written with VB.Net could have done with C# of course as well and
the latter would have given the same performance.

Cor
 
VB said:
well, C# is faster than VB.Net at least.

Do they generate that much different byte code? What kinds of
optimizations can be made by the C# compiler that couldn't be made by
the VB compiler?
 
So Newish, how pragmatic are you? How intelligent? Are you going to be a web
developer? As you may know or will have to learn there are two "platforms"
required for web development: the server and the client.

As it turns out for web development, code that runs in the client requires
code written using JavaScript. The "client" is usually a browser but could
be any application running on the desktop that uses a control to parse and
render webpage content. If you've heard of AJAX yet and how it is changing
webdevelopment? AJAX is A(synchronous) JA(vascript) X(ml). All AJAX code is
written using JavaScript. Arguably, AJAX happens to be the most important
trend in web development at the moment.

Secondly, all of the "Gadgets" and "Widgets" that run on the desktop that
Google, Yahoo and Microsoft are putting out are all built using JavaScript.
Coding with any of the "mashups" requires the use of JavaScript. Its
everywhere.

What's the point you may be wondering? Well JavaScript, C#.NET and Java all
come from C and all have exactly the same syntax. The grammar is nearly
identical too so when you learn one language you actually learn three
(actually more languages in fact because so many languages use the legacy
syntax and grammar of the C language). Coding Flash and applications from
vendors other than Microsoft all require a mastery of the C syntax and
grammar. Flash ActionScript for example is actually a JavaScript clone with
a different name.

Unfortunately, most VB.NET supporters are dishonest and never bother to
explain these facts so you never have a balanced view. I honestly have never
read any comments from any VB.NET developer who replied to any of the
thousands of RFIs asking the "which language" question who has ever had
anything honest to say by providing a balanced view of this topic. Not one.
Ever.

I was a VB script and VB.NET adoptee until I had an epiphany and now use C#
on the server and of course JavaScript on the client. I hope I have helped
you to have an epiphany too. All of the serious development as well as all
of the fun stuff that is happening on the web requires knowing the legacy C
syntax and grammar. So learning C# to use on the server and JavaScript on
the client is the pragmatic and smart way to become a masterful web
developer. Ainna?


<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W
 
Cor Ligthert said:
Is there a new version of C#?

In the VB.language newsgroup there is lately a message given where a
product written with VB.Net outclasses completely an unmanaged written C++
program.

What was written with VB.Net could have done with C# of course as well and
the latter would have given the same performance.

Cor
Please cite the message and any links to test results, etc. it includes.
This, I have to see.
Sorry, but I couldn't find it in the VB group.
 
Peter,

I have sent it to you by email.

Cor

pvdg42 said:
Please cite the message and any links to test results, etc. it includes.
This, I have to see.
Sorry, but I couldn't find it in the VB group.
 
VB said:
well, C# is faster than VB.Net at least.

At doing what? Unless you've got unsafe code involved, I can't think of
many things off-hand that you can't do exactly the same way in VB.NET,
resulting in virtual identical IL.

In a few rare edge cases, the VB.NET compiler creates
methods/properties which aren't inlined whereas the C# equivalent is -
but that would very rarely be significant.
 
For me it comes down to ecomomy of expression.

VB is and has always been more wordy.

c# is terse.
 
Jon Skeet said:
At doing what? Unless you've got unsafe code involved, I can't think of
many things off-hand that you can't do exactly the same way in VB.NET,
resulting in virtual identical IL.

Try following code and Compare the results. Remember compare "remarked"
code also.
I would said C# is not a "superior" but "faster" language.
Sorry for ugly C# code, I'm not skillful in C#. (^^;)

<VB>
Public Class Form1
Dim watch As New System.Diagnostics.Stopwatch

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim val(7) As Long, t As Long
watch.Start()
For i As Long = 1 To 10000
For j As Long = 0 To 255
val(0) = (j And 1) + 48
val(1) = (j And 2) / 2 + 48
val(2) = (j And 4) / 4 + 48
val(3) = (j And 8) / 8 + 48
val(4) = (j And 16) / 16 + 48
val(5) = (j And 32) / 32 + 48
val(6) = (j And 64) / 64 + 48
val(7) = (j And 128) / 128 + 48

'val(0) = (j And 1) + 48
'val(1) = ((j And 2) >> 1) + 48
'val(2) = ((j And 4) >> 2) + 48
'val(3) = ((j And 8) >> 3) + 48
'val(4) = ((j And 16) >> 4) + 48
'val(5) = ((j And 32) >> 5) + 48
'val(6) = ((j And 64) >> 6) + 48
'val(7) = ((j And 128) >> 7) + 48
Next
Next
watch.Stop()
t = watch.ElapsedMilliseconds
Text1.Text = t
watch.Reset()
End Sub
End Class

<C#>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace crt
{
public partial class Form1 : Form
{
private Stopwatch Watch;


public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

long t;
long[] bit = new long[8];

Watch = new Stopwatch();
Watch.Start();
for (long i = 1; i <= 10000; i++)
{
for (long j = 0; j <= 255; j++)
{
bit[0]= (j & 1) + 48;
bit[1] = (j & 2) / 2 + 48;
bit[2] = (j & 4) / 4 + 48;
bit[3] = (j & 8) / 8 + 48;
bit[4] = (j & 16) / 16 + 48;
bit[5] = (j & 32) / 32 + 48;
bit[6] = (j & 64) / 64 + 48;
bit[7] = (j & 128) / 128 + 48;

/*bit[0]= (j & 1) + 48;
bit[1] = ((j & 2) >>1) + 48;
bit[2] = ((j & 4) >>2) + 48;
bit[3] = ((j & 8) >>3) + 48;
bit[4] = ((j & 16) >>4) + 48;
bit[5] = ((j & 32) >>5) + 48;
bit[6] = ((j & 64) >>6) + 48;
bit[7] = ((j & 128) >> 7) + 48;*/

}
}
Watch.Stop();
t = Watch.ElapsedMilliseconds;
text1.Text = t.ToString();
Watch.Reset();
}
}
}
 
VB said:
Jon Skeet said:
At doing what? Unless you've got unsafe code involved, I can't think of
many things off-hand that you can't do exactly the same way in VB.NET,
resulting in virtual identical IL.

Try following code and Compare the results. Remember compare "remarked"
code also.
I would said C# is not a "superior" but "faster" language.
Sorry for ugly C# code, I'm not skillful in C#. (^^;)

[snipped long code snippets]

At first there was a difference, but I made two changes to fix it so
that both snippets ran the same speed:

1) C# by default doesn't check for integer overflows and VB does. I
changed VB to not check and that sped it up.

2) The division you were doing in VB was dividing using a double and
then casting it back to a long. If you turn on Option Strict you'll see
a compiler error. I changed the division operator from / to \ (which is
the integral division operation in VB). IIRC C# uses integral division
when both operations are integral.

After those changes, both versions ran exactly the same speed (averaged
over several runs).


Adam Ruth
 
Adam Ruth said:
1) C# by default doesn't check for integer overflows and VB does. I
changed VB to not check and that sped it up.

Very interestring!
Can you teach me how to turn off this "check" function.
2) The division you were doing in VB was dividing using a double and
then casting it back to a long. If you turn on Option Strict you'll see
a compiler error. I changed the division operator from / to \ (which is
the integral division operation in VB). IIRC C# uses integral division
when both operations are integral.

After those changes, both versions ran exactly the same speed (averaged
over several runs).

Hmmmm, I'm now considering changing VB6 to VB.NET or C#.
To my knowledge, C++ is more efficient than VB6.
However C++ is obscure, VB is more suitable for amateur like me.
I did a little expirement above.
The result really hesitated me in choosing which one.
But now you fix the bug.
Looks like I find the answer. (^^)
 
VB said:
Very interestring!
Can you teach me how to turn off this "check" function.

Sure thing. In the project's properties, go to the compiler tab and
click on the Advanced Options button. There you will see a check box.
It's the same in C#, but the wording is a little different.
Hmmmm, I'm now considering changing VB6 to VB.NET or C#.
To my knowledge, C++ is more efficient than VB6.
However C++ is obscure, VB is more suitable for amateur like me.
I did a little expirement above.
The result really hesitated me in choosing which one.
But now you fix the bug.
Looks like I find the answer. (^^)

Well good luck. I used to do a lot of VB6, then I went to the Unix
world where I did C++ and Perl (yuck) and Python. I came back and found
the VB.Net language to be very different, but very much better. I think
that while the language is more complex, it's also still very easy to
handle.

Have fun whatever language you're using.

Adam Ruth
 
John Bailo said:
For me it comes down to ecomomy of expression.
VB is and has always been more wordy.
c# is terse.

Well it is also true that VB.NET is more descriptive and self documenting.
Not to mention, with Visual Studio's great intellisense support you rarely
have to type an entire keyword anyway. I've used both VB.NET and C#
extensively, and I really don't think C# saves me any sigificant number of
keystrokes.

I love both languages. They both have their pros and cons. When am able to
make the choice though, I usually pick VB.NET over C# because its simply a
friendlier development experience overall.
 
Steve said:
Well it is also true that VB.NET is more descriptive and self documenting.
Not to mention, with Visual Studio's great intellisense support you rarely
have to type an entire keyword anyway. I've used both VB.NET and C#
extensively, and I really don't think C# saves me any sigificant number of
keystrokes.

I love both languages. They both have their pros and cons. When am able to
make the choice though, I usually pick VB.NET over C# because its simply a
friendlier development experience overall.

I tend to agree with that last statement. Visual Studio gives you much
more feedback while coding in VB than C#. I like knowing immediately
all of my compile errors without having to do a build. It seems that VS
2005 is better than VS 2003 in this regard with C#, but it's still not
as nice as with VB.

But the difference between the two is still the difference between 5
pennies and a nickel.

Adam Ruth
 
Thanks everyone for your responses.

Can someone clarify one point for me please.

More than once it was mentioned that C# is faster than VB.Net. Does
this refer to runtime performance or to coding, i.e. interms of
keystrokes.

Newish
 
It doesn't make much difference thought there are minor differences based on
their historical background.
 
Newish said:
Hi

Can someone please enlighten me. I hear different things. Some
suggest that the difference between the languages in terms of
capability and versitility has really narrowed down to a point where it
does not make any difference which language you use. Some suggest that
C# is still far superior language.

Considering they both use the same compiler and framework, that's questionable.

The one fact that can't be dismissed is that only C# is published as an ECMA
standard which is allowing it wider adoption in the non-MS community.
 
IMO, there never was a significant difference between the two -- and this
non-difference still is extant. C# allows you to write unsafe code (not
bad, just unsafe in terminology). VB does not.

As to speed differences, these are trivial, and it is possble to cherry-pick
and find some that performs better than the alternate using either.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Back
Top