Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic
photo of Dan Mabbutt

Dan's Visual Basic Blog

By Dan Mabbutt, About.com Guide to Visual Basic since 2002

VB.NET versus Java versus C#

Tuesday October 7, 2008

"Adrian" wrote in to ask:

"Some people tell me VB.NET is bound to disappear, and that C# or Java are better. What do you recommend?"

I haven't answered this question in a while, so here's my point of view.

Back in the days of VB6, there was much more of a case to be made about "VB" versus "C" but today, everything is different. Back then, a lot of what the computer could do was 'hidden' from the VB programmer to reduce the complexity of programming Windows enough to make it a practical reality. It's doubtful that Windows itself would have been successful without VB to reduce the cost of developing an application enough for business to afford it. But some programmers insisted that they needed to get 'next to the hardware' anyway for speed or the implementation of low level functions (like communications ports or individual monitor pixels). It's questionable how often this was REALLY a requirement but since managers tended to simply not understand the issue, programmers often got their way in spite of business realities.

But that was then and this is now.

Today, the issue of Java versus VB and C# versus VB are two different questions. They have seperate pro's and con's. Let's look at them individually.

Java versus VB

This is actually more a question of Java versus .NET, not VB. Java is a complex, but very powerful, programming environment controlled by Sun. In my opinion, Java has both less functionality and more complex requirements than .NET. Some of the reason is due to the fact that .NET is simply a more recent development and Microsoft took advantage of more advanced understanding of what worked and what didn't. (Much of it learned because Java pioneered the way, but that's life in the big city.)

At the same time, Microsoft has recently pushed out the frontiers of programming with initiatives like WPF (Windows Presentation Foundation - the basis of Vista Aero graphics which gives you vector based and hardware accelerated graphics), WCF (Windows Communication Foundation - again, used in Vista, but destined for much greater things because it was designed with the Web at the core) and WF (Workflow Foundation - if this takes off, it will be incredible, but it's actually advanced beyond the needs of today's business).

Sun simply doesn't have the infrastructure to match this kind of "Apollo Project" scale of development. Some pretty amazing things are being done in Java, but they're being done by the customers, not by Sun. If you plan on inventing your own wheel, go with Java. If you want the resources of a mega-corporation behind you, go with .NET. There are pro's and con's of living inside the garden walls rather than being free and on your own. Choose wisely.

C# versus VB

This is a much more difficult choice. Today, VB.NET and C#.NET both compile to exactly the same intermediate language and use exactly the same Framework libraries. In most important respects, they are identical. As you note, the main difference is in syntax. C# syntax looks like this:

for (int i = 1; (i <= 10); 
i = (i + 2)) 
{
    // Do this
}

VB syntax looks like this:

For i As Integer = 1 To 10 Step 2
   'Do this
Next

Pick the one that seems easiest to code and understand.

There are a few language differences today (more than there were when .NET was introduced, actually). But most of them favor VB. For example, the C# development team has chosen not to implement the "My" namespace in C#. (But you can use it anyway by simply importing the Microsoft.VisualBasic library into your C# project.) And there are features in the VB.NET implementation of Microsoft's new LINQ, such as XML literals, that aren't in C#. ("Nullable Types" - a feature in C# that isn't in the current version of VB - will be in VB.NET 9.0.) So they aren't identical in functionality, but they're very close.

The one clear advantage that C# has is that there are more books and articles written using C# as a basis. I simply don't understand this and it seems illogical to me. But since I review a lot of books, I can't deny it. What I can say is that there are plenty of books and articles for both. I doubt that you will ever run out of reading material with either one.

The bottom line is that both VB.NET and C#.NET are great development environments. Given a free choice, I would (and have) picked VB. But the decision factor in the 'real world' is likely to be the language that your employer chooses.

Comments

October 7, 2008 at 8:46 pm
(1) finalizer says:

Why did you write the C# version of the loop by so unpractical and unusual way? In Java and in C# I would write it so:

for (int i = 1; i <= 10; i += 2) {
// Do this
}

Then why you think it’s more complicated then your VB version?

October 8, 2008 at 2:08 am
(2) Nix says:

Java has both less functionality and more complex requirements than .NET.???

What is the alternative for Enterprise development in .Net??? (say EJB, Connectors and Authentication and Authorization).

I’ll say you want total control of your application go with Java. How easy it is to create custom grids, custom components in .Net?? It is as complex as in Java. And very few people knows it, but still they will claim that they are “.NET Developers”

October 8, 2008 at 8:17 am
(3) gsrk says:

By saying “There are pro’s and con’s of living inside the garden walls rather than being free and on your own. Choose wisely.”
I dont understand if the supports VB or Java! Well, if I hear to Dan’s words, I would choose to be free and on my own, and I will choose Java.

October 8, 2008 at 10:12 am
(4) visualbasic says:

First, let me say, “Welcome to About Visual Basic” to my new friends here. I’m glad to see that my blog attracted a few comments.

Second, having seen flame wars before, I know enough not to get involved in one. So I’m not going to respond to things that are clearly value judgements. The goal of the blog was simply to outline some of the choices, not to dictate a conclusion. My bottom line was, “choose wisely”. I have no problem with someone who does not make the same choices that I do.

But I will reply to questions that are not value loaded arguments.

finalizer asked, “Why did you write the C# version of the loop by so unpractical and unusual way?”

I didn’t. I simply ran it through a translation web page and copied the result. But, apart from saving a few keystrokes, I don’t see much difference. (And I’ll freely admit, VB normally requires more keystrokes.)

But I also didn’t say it was “more complicated”. I said, “Pick the one that seems easiest to code and understand.” If that’s C# for you, then great. I have no problem with that.

October 9, 2008 at 5:47 am
(5) Lennie says:

Hi! Normally I don’t agree or join language wars but: I programmed for 4 years in Java, VB (VB.net and VB 6), C++ and C#, PHP etc. The fact is that each language have advantages and disavandages, yes the .Net framework is more solid than the Java lib but Java is cross-platform to portable devices etc… VB is easy to code since it hide you from the details of the framework where with C# its more “C++ system style” of coding where its not so abstract like VB…. the point that i’m making is that you all even the guide can go on how bad one language is over another etc but hey, b glad that we don’t live in the days of Assembler since that was bad! A language is a tool, use the tool that you prefer (its your own personal opnion) and have knowledge in, for example: I will not go write a complete website in a week using Ruby on Rails since I don’t know it but it doesn’t mean its a good tool. Use the tool that suite the task and hand and what you prefer… damm if you want to use Lisp then go for it!

October 9, 2008 at 1:04 pm
(6) Bob says:

Nice article – spoken like a genuine moron.

And what’s up with the convoluted code? Have you ever compiled a non VB program in your life? Another clueless moron blogging away.

October 12, 2008 at 11:15 am
(7) programmer says:

You don’t understand why there are so many C# books. You think the employer will choose the language.

Managers tended to simply not understand the issue, programmers (Bob) get their way in spite of business realities.

C# is after all the new language.

October 13, 2008 at 10:09 am
(8) jazzydonald says:

Whateverer the language someone choose to me doesnt matter, but what matters the most is that one(programmer) should choose a language that will enable him/her to be able to accomplish his task at hand. If can use cobol today and accomplish my tasks the way i wanted it whats the problem with that???

Also for a certain languge (Like c#) to have so many articles, books,sample code on the entire internet, books library etc, doesnt mean it is the best language. problaby its beacuse its a new language and people wanted us all to get an idea of it, compared to vb which was there since 90’s.

But the bottom line is, just like leenie and bob mabbut said, the choice is yours and choose wisely depending on your prefarences but they are all good languages that we can use to accomplish our task.

If you feel your are not very comfortable with the symbols,curly brackets etc then go with vb if you are go with c# or java.

October 13, 2008 at 10:33 am
(9) visualbasic says:

“If I can use Cobol today and accomplish my tasks the way I wanted it whats the problem with that???”

No problem. I used Cobol for twenty years and there were a lot of great systems built using it.

However …

For whatever reason, virtually no structured, object oriented code was written using Cobol. It’s not impossible to do. It’s just that nobody did it. The language itself must have something to do with that.

October 14, 2008 at 10:53 pm
(10) Velu says:

I had used all these languages for real projects. My ranking:
1) Java
2) C#
3) VB6
4) VB.NET

October 24, 2008 at 1:45 pm
(11) Fabiano says:

I agree with you, nice article.

November 4, 2008 at 8:49 am
(12) TheMan says:

The c# code you posted as a comparison to VB code showed that you don’t have a clue what you’re talking about Dan. My best advice to you is to stick to what you know (which is nothing probably) rather than exposing yourself as a know-nothing pillock like you have here.

November 4, 2008 at 10:56 am
(13) visualbasic says:

Thanks for your comment; and thanks for adding to the hitcount total at About Visual Basic. All contributions are appreciated.

I’ve left your message on the site as the best representation of this point of view.

December 9, 2008 at 10:04 pm
(14) TongGA says:

Just an article bias to vb.net. Apparently the author never use java for enterprise application development.

December 10, 2008 at 10:45 am
(15) visualbasic says:

The author has never been part of the Java development team, but the author has certainly been a part of projects where both languages were in use.

Java is a great development environment just as .NET is. The factors that should go into a choice transcend personal preference and include past investment (does the company have the skills to enjoy a competitive advantage in one technology or the other); specific business requirements (both languages have technology advantages in particular areas); and possibly extra support that might be available from vendors. These days, Sun just isn’t able to offer much since their own business isn’t experiencing much joy.

December 13, 2008 at 9:42 pm
(16) Nonono says:

Hi everyone!

December 28, 2008 at 3:11 pm
(17) Random says:

What about c++? C++ should be the best (as long as you really know how to code in c++)

December 29, 2008 at 12:56 pm
(18) visualbasic says:

First, the original question didn’t include C++, so I didn’t include it in the answer.

But C++ is clearly one of the major development environments. Large, highly technical companies rely on it for their most critical core components.

C++ is a complete superset of C, so most of the pro’s and con’s of C also apply to C++. This is especially true in a comparison of C++ to VB.NET. The ‘C’ family of languages allows (in fact, requires) a lot more attention to memory management issues like and pointers and references. .NET (that is, “managed” code) is fundamentally designed to avoid requiring programmers to deal with those issues because experience has clearly shown that failing to do this right is how most of the really nasty bugs and security holes get into code.

Your point that, “as long as you really know how to code in C++” is right on target. Most of the criticism of C and C++ is based on the fact that code produced by programmers who have not taken the considerable time and effort to learn the skills required for C and C++ end up producing code that is inferior to the much more automated code produced by higher level languages like VB.NET.

The argument is often made that only C and C++ can produce the highly optomized code necessary for writing things like video games, core server functions, and database management systems. With the evolution of better compilers for .NET and Java, that is less and less true. J.P.Lewis and Ulrich Neumann of the Computer Graphics and Immersive Technology Lab at the
University of Southern California write in “Performance of Java versus C++” (http://www.idiom.com/~zilla/Computer/javaCbenchmark.html) provide lab quality proof that “Java performance on numerical code is comparable to that of C++.”

The reason some large organizations still use C and C++ probably has more to do with the large investment they have made over the years in a foundation of C++ code that they can’t afford to rewrite than in any inherent advantage of C++ as a language. But some people continue to ‘believe’ in C and C++ anyway. In the words of Lewis and Neumann, “it is possible that no amount of data will alter peoples’ beliefs, and that in actuality these ’speed beliefs’ probably have little to do with java, garbage collection, or the otherwise stated subject. Our answer probably lies somewhere in sociology or psychology. Programmers, despite their professed appreciation of logical thought, are not immune to a kind of mythology.”

I think that’s especially true of the comparison of VB to other languages. VB offers a commonsense syntax that is fast and easy to learn and results in exceptional programmer productivity. That, combined with the superior performance and security features of .NET, create a development environment that is hard to beat. But many programmers can’t get their head out of the previous century where VB 6 really did lack object oriented features and the ability to program some types of critical, core processes.

Personally, I’m very willing to admit that C++ might be the better language for some types of programming. The real flame throwing C++ haters are the C programmers. A great example is none other than Linus Torvalds, legendary inventor of Linux. In a reply to someone advocating C++ rather than C in a public forum (http://lwn.net/Articles/249460/), Torvalds writes:

—————————

*YOU* are full of bullshit.

C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice.

—————————

Remember, this is Torvalds writing, not me.

January 7, 2009 at 1:13 pm
(19) dawg3294 says:

They’re all very similar to me. If you’re a good programmer, you’ll do ok with any of those languages. I’d recommend doing a hotjobs/dice.com search for each language in your neighborhood. Then just go with whichever language has the most jobs in your area. It’s no use getting all high-and-mighty about a programming language if there are no jobs.

January 9, 2009 at 7:37 pm
(20) Antonio says:

good article. – here are my two cents:
I am a programmer for one of Canada’s largest marketing companies.

Me and the team constantly update the company system or create new applications for the company or for our customers.
Everything we do is in VB.NET and SQL Server.
The company is a million dollar business and growing strong despite the economic recession.
Thanks to VB.NET and SQL Server I have a nice house, my wonderful car and I can afford to enjoy a good life.

To all the C# and Java fanatics out there – Since your language is “better” than VB.NET then we should expect that you can do much more with it and that the language itself can do much more for you as well. having said that I guess you are now in possesion of a very nice private jet and living by the beach, right?

January 15, 2009 at 6:37 pm
(21) BlackBerry Developer says:

I love language wars where nerds fight over which language
is better especially when not one of them can speak
proper English. I have worked in numerous programming
environments after receiving a PhD from Stanford. I’ve
used just about everything from C, perl, Python, C++,
Java, vb, vb.net, c#, delphi, whatever… Each language
presented its own challenges as well as pros and cons.
The fact of the matter is that language is meaningless,
its all about implementation and knowledge of concepts.
The language is just a tool to achieve your result.

If you are unable or unwilling to use a certain language
or platform perhaps you are in the wrong industry. Learning
new languages is wonderful and essential for any programmer
worth his/her salt. Remember its not the arrows its the Indian.

January 15, 2009 at 8:52 pm
(22) Macu says:

Agreed 100% with Antonio and with Blackberry developer.
If you are a good programmer you will do good no matter the language you use.
At school our of my programming teacher make us learn algorithms and leaves the language to be our own choice.
I have seen good code written in VB.NET running faster that its C# counterpart. Many enterprise applications are built upon VB.NET and they really rock.

January 16, 2009 at 10:57 am
(23) visualbasic says:

I agree as well. I’d like to highlight the fact that the Blackberry Developer made these points with very good English. I always consider that to be a plus for any comment.

Although you can create software systems in just about any language, the time and cost will vary widely depending on a number of factors such as the nature of the problem, the previous technology investments of the organization, and the native features of the language itself. (That last factor was listed last deliberately.)

Visual Basic has shown itself to be an excellent language for creating systems with great programmer productivity. When the other factors don’t argue against it, Visual Basic is an excellent choice for developers looking for the optimum environment in a competitive world.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore Visual Basic

By Category

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.