What are the main differences between VB.NET and C#?

Asked

Viewed 7,424 times

16

In addition to syntax, what are the main differences between these two languages?

Is there any difference in performance between them?

Or is there any case where it is extremely advisable to use one language and not the other, or VB.NET exists only to keep VB programmers familiar with the new language?

3 answers

18


Its final conclusion is the best explanation for VB.NET to exist. I’m not gonna find anything easy, but there’s some information spread around that says this is it. Unlike some languages that are better at some kind of problem, when comparing these two it is difficult to point out clearly because one is better than the other if you don’t have one background previous.

In the current versions there are fewer differences yet and are almost entirely interchangeable.

Performance

In terms of performance there is nothing in the languages that profoundly change the obtained result, mainly because most of the time will be spent in the execution of functions that are the same in both (almost always written in C# and transformed into CIL code). It makes more difference the platform where it runs than the language itself. I’m not even going to talk about the question of which algorithms usually make more difference.

Of course some features of the language can eventually make a small difference, but you’re probably comparing different things. So the comparison turns out to be unfair. To get equal results you need to write different codes. But note that the difference will be very small and it is not clear which is more advantageous.

In some cases the same code can produce better results in one than the other, but with little modification can match both or even reverse the result. Comparing language performance is very complicated, in practice it is not possible. There is no language faster than the other in general terms, especially when they have such similar basic philosophies.

Styles

I don’t think a list of minor differences would help define anything relevant to choosing one or the other. What is certain is that VB.NET has a little less ceremony than C#, but very little. There is more convenience in either depending on how you look at the problem.

Generally speaking, the types, memory management, almost all basic constructs of algorithms and data structure work the same, the difference is essentially syntactic.

Legacy of VB

VB.NET may use a style a little closer to the original VB but it is not recommended to use it in new code. It may seem a little easier to use this style but in the background it brings more problems in the long run. As there is this recommendation, in practice the advantage of familiarity is not relevant.

It is an illusion to think that you will make an easier transition from VB to VB.NET. Legacy code does not convert so simply and the differences from VB to VB.NET are so great that the work of learning VB.NET can very well be leveraged to learn C#. The different syntax between languages is the easy part of what you have to learn.

Difference in language support

There are a little more examples and material available for C# than VB.NET, but nothing significant that makes much difference (this has changed gradually and more has strength in C# and not in VB.NET.

C# has a feeling of being the official language and VB.NET is there because of the legacy. But this is not proven if the analysis is very objective.

Completion

Any criterion that can be observed seems to be too subjective. I doubt anyone can give another reason to choose one or the other.

And recently Microsoft gave demonstrations that it will no longer work on VB.NET. It will continue to be supported, but will not have evolution. This is important.

  • Even though C# having this feeling of being the official and VB.Net the badly loved son, LINQ’s Query Syntax in VB.Net is much richer.

  • @Tobymosque You could quote a reference that shows this?

  • This information is in the Training Kit for the 70-516, if I think and is allowed, I can take a picture of the page in question.

  • @Tobymosque I think quoting the source and is just a stretch of the work falls on fair use

  • 2

    http://www.imgur.com/a/v1SfG I invested the image order, but you can see that in VB.Net it is possible to use take, Skip, sum, max, etc with query syntax

  • I just saw, returning to the subject, also read in these training books that the methods in C# and Vb.Net have different implementations within the Framework, so there may be performance differences between running the same code in C# or VB.Net

  • Same code is relative. It’s very complicated to compare different languages but this subject is too long to discuss here. Often the wrong thing is just to compare the same code. Different languages ask for different codes.

  • I was programming in VB since VB 4, when I learned to program. And I had never used another language, except a time I played with Delphi. But I changed to C# because it irritated me some examples that I could not find in VB and could not carry. @bigown said "a little more example in C#"... I think (and made the transition for that), which is more than a little difference. It is very rare to find an example in VB.NET that does not appear in C#, and it is common to find one in C# that does not bring the VB.

Show 3 more comments

6

In addition to syntax, what are the main differences between these two languages?

There is an article in Codeproject that illustrates the differences extensively. It is not worth commenting on all in this reply.

I mean, is there any difference in performance between them?

No. The two are first compiled in CIL, so the performance is identical.

Or is there any case where it is extremely advisable to use one language and not the other, or VB.net exists only to keep VB programmers familiar with the new language?

I think @Maniero’s response fully responds to this part, with a few addendums: adapting older programmers is quite costly and many prefer not to learn a new language.

There is, still, another aggravating: The conversion from VB6 to VB.NET is not trivial, which does not bring any benefit in keeping in VB.NET. Usually applications need to be rewritten and previous versions of systems are abandoned.

2

Or is there any case where it is extremely advisable to use a language and not the other?

It is not exactly a case that I will mention, it is more a advice: courses, tutorials, examples, libraries, work, etc., in its great majority (almost all) are/require C#.

Now a piece of advice that came from VB6 and now began to learn VB.net and C#, for those who have doubt, focus on C# and will not regret.

For anyone who wants to start: Beginner course in C# - English (with caption) Microsoft Virtual Academy

Microsoft Virtual Academy (if you are thinking of searching for VB.NET or Visual Basic do not click here) ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.