Solved

VB.NET Vs C#

Posted on 2004-04-29
30
1,868 Views
Last Modified: 2012-08-13

THe question is simple:

Does  C# has any superiority to VB.NET?

I knowthat  they both compile to same code. And they run at same speed.

So any reason for using C# expect that C# name looks more dandy?
0
Comment
Question by:unknown_routine
  • 6
  • 4
  • 4
  • +9
30 Comments
 
LVL 3

Assisted Solution

by:jayrod
jayrod earned 60 total points
ID: 10950167
From what I know all of the syntax you can do in one language you can do in another. They do run in the same intermediatte language (MSIL) You'll find more C# stuff out there as C is more of a popular syntax.

Other than that It shouldn't really matter.

You may run into a few problems if you want to work with other .Net webDevelopers who mainly use C# while you use VB.  Just cause the codebehind pages and web pages have to be in the same language. You can however write the aspx and and codebehind pages in vb and then use dlls coded in C#.

It's all preference I believe
0
 
LVL 15

Author Comment

by:unknown_routine
ID: 10950253

I diagree with this part: webDevelopers who mainly use C#

Nealry all webDevelopers who I know are using VB.NET.


Thanks for the comment


( I increased the points and waiting for more comments)

I will split the points between all useful comments.


0
 
LVL 3

Assisted Solution

by:jayrod
jayrod earned 60 total points
ID: 10950295
<<.Net webDevelopers who mainly use C#

sorry mis spoke.. You're right .NET webdevelopers coming from ASP tend to jump right into VB.NET. However the windows APP programmers I believe tend to come from java and C backgrounds.. and they jump into C#.

I'm currently in this situation now. I work on a website and the Web Developer/ Graphic Artist uses VB while I program all of the middle tier objects in C#.

It works rather well and we haven't had any problems. The only problems may come when I may try to do more web development, as I can't code snippets of pages in one language while he uses another

That's what I meant
0
 
LVL 7

Assisted Solution

by:NipNFriar_Tuck
NipNFriar_Tuck earned 70 total points
ID: 10950546
From my experience you can inherit from VB.Net to C# and back as desired... so you can have a inheritance tree that looks like

Class in VB.Net
   Class in C#
      Class in VB.Net
          Class in C#

The main advantage of C# over the VB.Net is the XML Documentation.  This allows the code to be internally documented and that documentation to be then xtracted and turned into a developers document.  It is on the lines of the JavaDoc functionality.

I also agree with jayrod in his assesment of why developers use the language they use as what he has said is my experience also.

Regards
nipnfriar_tuck
0
 
LVL 3

Assisted Solution

by:jayrod
jayrod earned 60 total points
ID: 10950582
cool nip.. I didn't  know you could inherit like that...

One other gotcha that I ran into was while debugging I forgot to install the VB stuff and I wasn't able to step through VB code from the page to my dll.

I use NDOC as a documentation tool from my DLL's and it is funkin awesome.
0
 
LVL 20

Assisted Solution

by:ihenry
ihenry earned 90 total points
ID: 10950660
>> Does  C# has any superiority to VB.NET?

These I get from internet easily since it has been covered out there so many times
1. Operator overloading.
2. The using statement.
3. Unsafe code, allows playing around with pointer while you can't in VB.NET
4. Supports for unsigned types.
5. Explicit interface implementation, where an interface which is already implemented in a base class can be reimplemented separately in a derived class.
6. Xml documentation generation from source code comment.
7. bla..bla..bla and many more..


My personal preference,
1. Less typing code
2. Can learn Ximian's Mono project: .NET for monkeys, penguins, and gnomes easily.

My personal opinion, it's better to learn both that makes easier to switch project or job. And I see many programmers are actually bi or even multi-bilingual.
0
 
LVL 9

Assisted Solution

by:msdixon
msdixon earned 80 total points
ID: 10950723
i came from a web development background and hate the very sight of any sort of vb. in my opinion, c# is a much "cleaner" language, and doesn't have all the verbosity vb does (although the ide for vb is better for lazy developers like myself).

c# developers command a higher salary (visual studio magazine had the article a while back). it was a substantial difference. and here's why.

typically (i'm generalizing here, so don't get your panties in a bunch if this doesn't apply to you), c# developers have a more in-depth knowledge of oo. there's no such thing as true oo in vb, and especially not vbscript (which is where most MS web developers have used in the past). this is true because the comment above states:
"You're right .NET webdevelopers coming from ASP tend to jump right into VB.NET. However the windows APP programmers I believe tend to come from java and C backgrounds.. and they jump into C#."

from an employers perspective; when you're hiring a c# developer, you're really hiring a java, c, c++, etc. guy who's staying current with the technology. don't get me wrong, this is not a true statement. but that's the PERCEPTION. and let's face it salary is all about perception.

also, the IL is not identical, hence, performance can be a little different. having said that, i don't think that one language is more optimized for performance than the other. it's too close to use that as a determining factor.

another reason for c#... i find that a lot of the more advanced code samples (take remoting for example... the samples in "Advanced .Net Remoting" by Ingo Rammer, are all in c# -- good book, by the way. a great little twist at the end -- the butler didn't do it) are in c#. i find very few of them in vb.

summary:
i started with vb.net in beta 2 of vs.net. about 3 months after that (when i had a handle on the .net framework), i switched to c#. i'll never write another line of vb code if i can help it. i think a lot of it comes down to perception. vb developers are looked down upon in the non-vb arena. that's a fact.

do yourself a favor, learn c#. but more importantly, learn oo, windows services, web services, gdi+, custom painting, threading, remoting, xml, xslt, web development, windows development, smart device development, write a custom control or two for both web and windows development, exend a class, learn about polymorphism, and avoid crystal reports like the plague. become more of an asset.

we are paid for our knowledge... so, acquire mor of it than the guy next to you and you'll be set.
0
 
LVL 9

Assisted Solution

by:msdixon
msdixon earned 80 total points
ID: 10950772
ihenry,

comments on your comments:
operator overloading is available in vb.net, although it's much more verbose... you have to declare the method as overloaded (i don't remember the syntax)
i've never had the need to write unsafe code, how about you?
there are add-ins for xml documentation in vb.net, and the next version of visual studio supports it
0
 
LVL 9

Assisted Solution

by:msdixon
msdixon earned 80 total points
ID: 10950861
0
 
LVL 20

Assisted Solution

by:ihenry
ihenry earned 90 total points
ID: 10950903
Hi msdixon,

Method or function overloading is not the same with operator overloading, and vb.net doesn't support truly operator overloading because it uses method call instead of the real operator.

>> i've never had the need to write unsafe code, how about you?
same here, i'd rather use vc++.net with more flexibilities.

>> there are add-ins for xml documentation in vb.net
it's a 3rd party component. I might be wrong, but let me know if you don't think so.

>> and the next version of visual studio supports it
There many, please read this article.

New Features in VB.NET Whidbey
http://www.ondotnet.com/pub/a/dotnet/2004/04/26/vbnet20_pt1.html
0
 
LVL 9

Assisted Solution

by:msdixon
msdixon earned 80 total points
ID: 10951032
misread... yes, operator overloading is not available in vb.net.

i didn't say the add-in was from microsoft, just that it's available.
0
 
LVL 22

Assisted Solution

by:_TAD_
_TAD_ earned 20 total points
ID: 10951115


In the next release of .Net (due Jan of 2005), all languages will be on even keel.  VB gets operator overloading as well as XML documentation.

The only advantage C# will have of VB is that C# will still be able to use "unsafe" code.  This looks doubtful for VB.




At anyrate, what does it matter?  VB.Net was produced to appeal to VB-ers and C# was built to appeal to Java programmers.  Not to mention C++.NET, J#.Net, C.Net and COBOL.Net.

In a nutshell, learn good OO design and programming skills and pick a language that you already know something about.  Any decent programmer out there can learn the syntax of a lanugage in just a day or two, the rest of the knowledge needed comes from a platforms libraries.  Since .Net uses the same libraries across its platform, syntax is really about semantics and that's just trivial.
0
 
LVL 20

Assisted Solution

by:ihenry
ihenry earned 90 total points
ID: 10951139
VB.NET is still left  behind for whidbey version. Take a look to the new cool features in C# 2.0

http://download.microsoft.com/download/8/1/6/81682478-4018-48fe-9e5e-f87a44af3db9/SpecificationVer2.doc
0
 
LVL 15

Author Comment

by:unknown_routine
ID: 10951267
Very good so Far :))

I really enjoyed all the comments and  waiting for more.

To have more options to split the points I raise the points to 500.

 jayrod:

I have been in a multi language environment where every tier was a different lanugage. I belive its a mess
and any good manager should avoid it.
---------------------------------------------------------

 NipNFriar_Tuck:
<<The main advantage of C# over the VB.Net is the XML Documentation.  This allows the code to be internally documented and that documentation to be then xtracted and turned into a developers document.>>

I don't understand this. code to be internally documented . do you mean you can directly write xml inside C# and then
turn it to outside doc l for example a word.doc  . explain more....
-----------------------------------------------------
 ihenry:

1. Operator overloading . What is this? explain briefly
2. The using statement. What is this? explain briefly
4. Supports for unsigned types. What is this? explain briefly

6. Xml documentation generation from source code comment. Whats good about this? how the document should be created.
I mean who can create it?

1. Less typing code,    <<I realy doubt this.

 it's better to learn both that makes easier to switch project or job. And I see many programmers are actually bi or even multi-bilingual.  
I disagree , in my opinion It is better to be a Guru in one language than to learn 2 or more languahes loosely.

-----------------------------------------------------------

 msdixon:

 came from a web development background and hate the very sight of any sort of vb

simliar to you I came from a web development background but I hate the very sight of any sort of  C++. lol

c# developers command a higher salary
This can be true, only because some dummy bosses and knoledgeless managers still in the false belief C# is faster.
But this mentalitiy won't live  more  than a year or two.

 c# developers have a more in-depth knowledge of oo. there's no such thing as true oo in vb, and especially not vbscript

I agree c++ developers might have more knowldge of OO comparing to vb6 developers but here We are comparing C# and VB.NET
And as far as I know VB.NET is as much OO as C#

<<do yourself a favor, learn c#. but more importantly, learn oo, windows services, web services, gdi+, custom painting, threading, remoting, xml, xslt, web development, windows development, smart device development, write a custom control or two for both web and windows development, exend a class, learn about polymorphism>>

do yourself a favor, learn c#. : if definitely like to do this

learn oo: belive it or not but VB6 can be %95 OO and .NET is 100%

 Windows services, web services,threading, exend a class, learn about polymorphism
Again all of this can be done even in VB6. and I have practical experience in this regard.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=


Further comments are welcome.

Thanks.












0
 
LVL 7

Assisted Solution

by:NipNFriar_Tuck
NipNFriar_Tuck earned 70 total points
ID: 10951373
The XML documentation is documentation in an XML format that you can put above namespaces, classes, fields, properties and methods documenting what the block does, give example how to use etc...  Then you can turn on a feature in the IDE to output this documentation into an XML File.  Then with a tool like NDoc (free tool) you can transform this XML file into a very nice website and the documentation looks very much like the documentation you see on MSDN.  The best part is that after you define a function, you type the /// above that function and the IDE puts in the XML outline for that function!

Here is an example of the XML Documentation for a class:
    /// <summary>
    /// Encapsulates all functionality to report errors and messages to
    /// the database and event logs.
    /// </summary>
    /// <remarks>
    /// <P>Every system component should report status to a commonly monitored area.  By
    /// using this class's reporting features, a single format and repository is built
    /// for all component messages.  These messages have a complex nature and can provide
    /// detailed information to the source of a bug or the state of a component.</P>
    /// <P>The contents of the output are somewhat determined by usage.  When instantiating
    /// this object, an overall "source" variable can be set.  This is designed to mark the
    /// broader application or system component which may include many smaller objects.  For
    /// example, in the PSAST client applications, this is set to "Acct Maint", "RTS" or another
    /// application name</P>
    /// <P>This object also supports the use of Auditing messages.  Auditing is controlled
    /// through an enumerated set in the SysInfo class object, and audit messages are sent
    /// from any location to this object with an appropriate audit code.  For example,
    /// the DataAccess object gives various audit messages
    /// to the AlertReporting object.  AlertReporting then examines the current log settings
    /// for active audits and log settings (ON/OFF, active output channels) and react accodingly.</P>
    /// </remarks>
    /// <seealso CREF="DataAccess">DataAccess</seealso>
    /// <seealso CREF="SysInfo">SysInfo</seealso>
    public class AlertReporting : IDisposable { //Do a bunch of stuff }

Hope this helps...

Regards
nipnfriar_tuck
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 20 total points
ID: 10951425
you can see more reviews regarding C# abd VB.NET..
http://www.dotnet247.com/247reference/msgs/39/195720.aspx

R.K
0
 
LVL 7

Assisted Solution

by:NipNFriar_Tuck
NipNFriar_Tuck earned 70 total points
ID: 10951632
unknown_routine,

After reading the rest of your last comment I have to disagree on VB6 being 95% OO.

I worked in VB6 exclusively for a year and did some cool stuff with VB6 and got familliar
with the winapi to do the really complicated stuff.  But VB6 is not OO, and can be barely
defined as OO Like.  Depending on who you read there are 4 or more basics of OO and
VB6 did not implement the basics... For instance you can not create a class in VB6, inherit
that class in another class and use a method in the inherited class as if it was part of the
second class created.  What you had to do is instead of using an "Is A" relation you had to
us an "Has A" or "Uses" relation.  At best I was able to use maybe 40% of the OO concepts
in VB6 and that is being optimistic!

Don't get me wrong, I am not saying that VB6 is a good or bad language...  As I said I have
done some cool stuff in VB6, but it is definatly not OO!

Regards
nipnfriar_tuck
0
 
LVL 15

Author Comment

by:unknown_routine
ID: 10951859
NipNFriar_Tuck: I have been working more than 10 years on VB.

Again thank for the comment:


<< For instance you can not create a class in VB6 :>>
 Not True, you can create a class in VB using a class module


 <<inherit that class in another class  and use a method in the inherited class as if it was part of the
second class created.>>
  Not true , you can use implements keyword to do the task.


<< At best I was able to use maybe 40% of the OO concepts>>
 I disagree I guess you have not had enough Exp with VB.


<<Don't get me wrong, I am not saying that VB6 is a good or bad language...  As I said I have
done some cool stuff in VB6, but it is definatly not OO!>>

I want to hear all suggestions, and very comment is welcome. But lets forget about VB6 and concentrate
on the question which is C# agains VB.NET






0
 
LVL 20

Assisted Solution

by:ihenry
ihenry earned 90 total points
ID: 10952156
>> Operator overloading . What is this? explain briefly
If you have heard operator overloading in c++, the goal is pretty much the same. When you compare between two integer variables whether they're equal you use the equal operator ==. But when you have a definition that two instances from Employee class are equal when they both have the same EmployeeID, can you do the same? yes after you overload the == operator.

>> The using statement. What is this? explain briefly
You know when in VB6 to destroy an object from memory you use,
     Set myObject = Nothing
In .NET you don't really have to destroy an object explicitly because the garbage collection system will do for you. But when your object is holding scarce or critical resources which need to be freed as soon as possible you can't rely on garbage collection ( this is another quite a big topic ). Using the using block will help you by automatically dispose the object when it goes out of scope.

>> Supports for unsigned types
In CTS types there's a type named int ( Integer in VB.NET ) or System.Int32 which range from -2^31 to 2^31 -1, but there's also another type named uint or System.UInt32 or unsign integer ranges from 0 to 2^32 -1.

>> Xml documentation generation from source code comment. Whats good about this? how the document should be created
Read nipnfriar_tuck comment

>> Less typing code
Some people believe curly braces are more beatiful than human language like statements :)

>> I disagree , in my opinion It is better to be a Guru in one language than to learn 2 or more languahes loosely.
To be a guru in web development you need to know more than a C# or VB.NET, you need HTML, javascript, XML, VBScript and many more.
0
 
LVL 3

Assisted Solution

by:gillit
gillit earned 50 total points
ID: 10953263
The main goal of .NET is to make all languages equivalent so that (like TAD says) you choose whichever appeals to you more. This may be impossible, but that is the aim. Think of it as verbal language, you choose what is most compatible with your environment.

So then a question arises... what language do you use if you are by yourself?

From my experience, I have chosen C#. The following are purely opinions:
1) The reason being that it is less verbose than VB, so that I can minimize what I read (less screen space --> less scrolling) but still maximize what I can understand from it. I argue with myself a lot about whether I prefer the brace blocks or VB's "if" and "end if".
2) I don't like VB in that you do not have to declare variables. It is bothersome when there is someone in the group who just cannot seem to spell very well. But this feature can be turned off.
3) I also do not like VB's case insensitivity. (IMO) If a programmer cannot pay enough attention to something as simple as that, I cannot bring myself to feel that they can program correctly.

But then there are people who like VB just for the same reasons I don't.

>>So any reason for using C# expect that C# name looks more dandy?
AND you get to look smart when correcting someone who pronounces it as "see pound" or "see number"
0
 
LVL 15

Author Comment

by:unknown_routine
ID: 10954022
1) The reason being that it is less verbose than VB, so that I can minimize what I read (less screen space --> less scrolling) but still maximize what I can understand from it. I argue with myself a lot about whether I prefer the brace blocks or VB's "if" and "end if".

Not true:
I guess c++ is a lot more verbose , I can give you many examples that 2 lines of VB code is 10 or more C++.


2) I don't like VB in that you do not have to declare variables. It is bothersome when there is someone in the group who just cannot seem to spell very well. But this feature can be turned off

Again Not True:
In VB You have to delcare variable unless you set
option explisit off
0
 
LVL 37

Assisted Solution

by:gregoryyoung
gregoryyoung earned 50 total points
ID: 10955209
<NOT CLR COMPLIANT> 1. Operator overloading.
<USEFULL BUT NOT FOR MOST BUSINESS PROGRAMMING>3. Unsafe code, allows playing around with pointer while you can't in VB.NET
<NOT CLR COMPLIANT>4. Supports for unsigned types.

> 2) I don't like VB in that you do not have to declare variables. It is bothersome when there is someone in the group who just cannot seem to spell very well. But this feature can be turned off

with option strict on the rules are the same in VB.NET vs c# for variable declarations and type casts

my big problem was with vb implicit conversions / late binding behaviors ... option strict gets rid of that ....
my other big problem is the non-case sensitivity in VB. This can cause some problems at runtime due to case differences.

Now something in VBs favor ... Event declarations are much simpler !
withevents is kinda nice :)
Actually VB.NET has outperformed C# in some jagged and multidimensional array tests ...
VB.Net is bit quicker and dirtier if RAD is important to you

I have found as a general statement that C# developers understand OO better than VB.NET developers but I believe this is due to many VB programmers moving to VB.NET without taking the time to learn true OO whereas many of the C# people are coming from Java/C++ backgrounds.

0
 
LVL 15

Author Comment

by:unknown_routine
ID: 10955324

my other big problem is the non-case sensitivity in VB. This can cause some problems at runtime due to case differences.
==============

Explain this.examle?
0
 
LVL 37

Assisted Solution

by:gregoryyoung
gregoryyoung earned 50 total points
ID: 10955346
ive run into cases where doing things (such as overriding) where a case difference gets introduced and the runtime throws an exception. This is because the runtime is case sensitive and the environment / compiler are merely trying to emulate non-case sensitiviy
0
 
LVL 21

Accepted Solution

by:
tovvenki earned 60 total points
ID: 10956319
Hi,
Have look at this comments by experts from Microsoft
http://msdn.microsoft.com/asp.net/community/inbox/vbcs/default.aspx

venki
0
 
LVL 3

Assisted Solution

by:gillit
gillit earned 50 total points
ID: 10959273
>>I guess c++ is a lot more verbose , I can give you many examples that 2 lines of VB code is 10 or more C++.
>>In VB You have to delcare variable unless you set
>>option explisit off

I'm sorry, I meant VB.NET when I was referring to VB. I was comparing with C#, not C++. I agree C++ can be be longer, but then C++ is still much more powerful/dangerous than .NET.
0
 
LVL 15

Author Comment

by:unknown_routine
ID: 10959527
tovvenki:
Very good Article!

For the future reader:

Both languages have same  99.9%  same functionality.

C# has “using” and operator overloading,
VB.NET has optional arguments, late binding, and an easier syntax for wiring up events

I will continute with VB.NET and then Start C#.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10959909
I feel it is important to note that MS has taken a very open ended route.

For anyone getting into .net, using the best tool for the job is whats really important be it VB.NET, C#, MSIL, or even thilibant.net (an object oriented lisp compiler I wrote).

Greg
*its all binary underneath*
0
 

Expert Comment

by:gtzpower
ID: 10992811
We actually did some tests using borland c# builder, and VB.net, and using the EXACT same code (a loop performing calculations) vb would be faster for smaller loops, but C# was faster in larger loops.  Not sure why, but after a certain point, C# was growing to be faster and faster than VB the larger the loop got..  We used the gettickcount API for accuracy, ran the test on multiple pc's and did it many times.  We even changed the code in both programs, and the results were always the same.
0
 
LVL 2

Expert Comment

by:rogaut1
ID: 10997668
Hi,

Here is what I have documented so far, if you have comments or questions please send them to me.

http://www.robertstation.com/csharp/csharpVSvb.xls
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now