I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

July 14, 2004

VB vs. C# -- FIGHT!

If I see one more blog entry complaining about VB's verbosity, or the elitism of C# developers, I think I'm gonna puke. Why can't we all just get along? Part of what makes the .NET Runtime unique is that it offers you a choice of syntax; we should embrace that philosophy, rather than wasting a lot of time sniping at perceived slights. If I wanted a single language to bind them all, I'd be writing in Java. 'nuff said.

One of the first e-books I read after .NET was released was Daniel Appleman's Visual Basic.NET or C# - Which to Choose. And it's still the best one on the topic. The answer, of course, is: it depends. The real choice you make is to use the framework; getting obsessive about the bits of duct tape we use to run the framework through its paces is completely and utterly missing the point. Which brings me to my favorite passage from the e-book:

So let me make one thing perfectly clear. Any of you who feel that the syntax:

if() { }

is somehow morally superior to:

If .. Then
End If

are fools.

And yet, one of the things Dan predicted has come true: C# developers are paid more.

If the perception survives that C# is somehow better than VB.NET, there will be a set of managers and clients stupid enough to pay more for C# programmers than VB.NET programmers with identical experience.

Now, as an ethical programmer, I know that you will question the wisdom of these managers and clients and point out to them the fact that there is no rational basis for paying more for C# developers than VB.NET. Why, you might even show them a copy of this very article to prove the point. But we both know that some will not be persuaded. Language choice is as much an emotional as a logical decision. It seems clear to me that in a case where a manager or client insists on paying more for C# development, you have a moral obligation to take their money, knowing in doing so you help promote the capitalist system that insures survival of the most efficient organizations. Just don't accept your pay in the form of stock or options, because the organization you're working for probably has other efficiency problems as well.

Written in early 2002, and still eerily accurate to this day.

Anyway, since the need to convert between VB and C# comes up on a near-daily basis, here are some resources I've found helpful.

There are other resources out there, but those three are essential.

Posted by Jeff Atwood    View blog reactions

 

« VS.NET 2003 VB outlining broken Go, Monkey! »

 

Comments

Peace! The VB vs. C# debate is getting old.

Clemens Vasters on August 7, 2004 11:58 PM

The FileDisassembler add-in helps a lot when converting VB to C# or vice versa.. very handy!

http://www.denisbauer.com/NETTools/FileDisassembler.aspx

Johnny on August 7, 2004 11:58 PM

This is getting a bit tired. Personally you must understand that you are programming against the CLR so what syntax you use that the upper level really does not matter too much. More on this at my blog:
http://blog.richard-callaby.net/PermaLink.aspx?guid=d135611d-8c50-43e1-a25e-a88a3b8d4f8f

Richard Callaby on August 7, 2004 11:59 PM

I agree that objective better or worse in language-religious debates is rubbish. However, as someone who has spent more than a couple of years with C-ish languages as well as VB, I have to say on an aesthetic level I much prefer writing guard clauses this:

public void foo(string arg)
{
if (null == arg) return;
// code here
}

than this:

Public Sub Foo(ByVal arg As String)
If arg is Nothing Then
Return
End If
End Sub

I would love a VB version of the If statement that didn't require an end if for a return allowing me to have:

Public Sub Foo(ByVal arg As String)
If arg is Nothing Then Return
// code here
End Sub

Is End If so bad that it makes me puke? Hell no. And this is a matter of personal taste. But it bugs me enough to make me select C# for new projects.

Christian Romney on March 8, 2005 09:17 AM

I'd rather hire someone the is programming C# than VB.Net for some reasons I've experienced:

1) Professional/advanced programmers tend to choose C# because of it's syntax.

2) C# programmer most often have background from other programming languages.

3) Every C# programmer I've met reads and writes VB.Net code very good, while VB.Net programmers scratch their head and give up when they see a few lines of C# code.

4) Beginners tend to start with VB.Net. While other programmers start with C# when moving to the .Net platform. Also I've seen many moving from VB.Net to C# after some time. I have never seen anyone move from C# to VB.Net (unless "forced" by management).


This is only what I've seen, and ofcourse isn't the most important aspect of hiring someone for a job.

(I'm programming both C# and VB.Net :)

Jørn on March 8, 2005 09:23 AM

The following C# to VB.NET online converter does an excellent job from my experience:

http://www.developerfusion.com/utilities/convertcsharptovb.aspx

Brian Swiger on March 8, 2005 01:08 PM

Well, the only things keeping me from C# at this point are..

1) Lack of background compilation. It's more productive, period. If people don't like it they should be able to switch it off, but not including it is a misstep. Consider that the #1 most popular (and most prominently advertised) feature of the much-loved Reflector is EXACTLY THAT: background compilation!

2) Case sensitivity is Just Wrong. I cry for a world where "Jeff != jeff". It gets abused, too: I've worked on several C# classes where public variables are named Var1 and private variables are named var1? Yeah, that's not confusing at all.. :P

Other than that, it's a wash, but those two things will keep me in VB.NET for reasons of productivity.

Jeff Atwood on March 8, 2005 01:12 PM

er.. by Reflector I meant JetBrains "Resharper". Sorry.

http://www.jetbrains.com/resharper/

> One of the most powerful and helpful features in ReSharper is its ability to quickly detect and highlight errors in code, **without the need to compile it**. ReSharper automatically analyzes your code while you work and will highlight a variety of possible syntax or logical errors. It can also detect and emphasize statements or constructs that you should be warned about (e.g., unused or uninitialized variables).

Smells like background compilation, and it's the first item listed on their advertising page.

Jeff Atwood on March 8, 2005 04:04 PM

Jeff, I'm with you on background compilation being a nifty feature (done right), but the syntatic productivity gains of C# far outweight that for me. Every so often, I hit CTRL+SHIFT+B out of habit (I think I picked this up from TDD) and it provides enough feedback for me. Besides, I'd lay a substatial wager that you're not as dependent of background compilation as you might think. How often are you *really* screwing up syntax? I'd venture a guess that it's not that often. Also, how many times are you slinging some text around and the IDE is adding in some stuff you're going to have to delete? Here's an example:
Dim mArray As String(5)

Now you might reach over and copy mArray and paste it five times on five consecutive lines in order to initialize each element. Then VB comes along and adds the annoying () at the end and underlines the whole thing in blue. You know what I'm talking about... :)

As for case sensitivity, I most certainly don't think Jeff should == jeff. It's just too easy for programmers to think this is some sort of truth and woe to them when they actually have to worry about encodings and i18n.

Christian Romney on March 10, 2005 09:29 AM

Christian,

My C++ prof would roll over in his grave...
public void foo(string arg)
{
if (null == arg) return;
// code here
}

I use VB, out of preference for the language syntax, mainly, but even in VB, I would do this, rather than using break statements. To me, a lack of break statements is a non-issue, since they're generally considered to not be good practice.

public sub foo(byval arg as string)
if not arg is Nothing then
'code
end if
end sub

Wade Shelton on June 18, 2005 06:21 PM

Another great C# <-> VB.NET converter that works in real time (?!) as you type:

http://www.carlosag.net/Tools/CodeTranslator/Default.aspx

Jeff Atwood on July 8, 2005 08:15 PM

Wow, that real-time converter works great.

I would like to make a couple of points:

"Case sensitivity is Just Wrong. I cry for a world where "Jeff != jeff". "

Well, look at it this way. If you're comparing strings in an application, should Jeff be equal to jeff?

"I've worked on several C# classes where public variables are named Var1 and private variables are named var1? Yeah, that's not confusing at all.. :P"

Stupid naming conventions don't have anything to do with the language you're working in. Just look at Hungarian notation ;). I've seen idiotic naming conventions used in VB as well as C#.

" Lack of background compilation. It's more productive, period."

If this is something keeping you in VB world*, then definitely invest or ask your company to invest in Resharper. I've been using it for the last couple of months, and it's great.

*VB world - where Functions don't HAVE to have a return value.

Marty Thompson on July 9, 2005 06:53 PM

My C++ prof would roll over in his grave...
public void foo(string arg)
{
if (null == arg) return;
// code here
}

Your C++ professor must not have been Martin Fowler who recommends the guard clause technique over nested ifs since they are so much easier on the eye (and it goes without saying with whom I wholeheartedly agree). Of course, this is a matter of preference, but escaping out of the function in one line of code to enforce my preconditions (feel free to throw an ArgumentNullException or other exception rather than simply return) seems elegant to me. Oh yeah, I also believe in programming by contract. ;)

Wade Shelton on September 22, 2005 06:06 PM

> If you're comparing strings in an application, should Jeff be equal to jeff?

Ab-so-fricken'-lutely they should be equal.

Is http://www.Amazon.com the same website as http://www.amazon.com ? Can I get a hell yes?

Case sensitivity is the outlier, NOT the norm. Sure it's necessary in some extraordinary situations, but making it the default is just wrong and violates the 80/20 rule big time.

Jeff Atwood on September 22, 2005 07:11 PM

No moral reason for the discrepancy in pay packet size, perhaps, but the reason (and note I haven't looked at the stats) is because generally the banks are adopting c# big time for the UI (primarily because it's similar to java, and most devs in the banks at the moment are Java, and C++ to a lesser extent). & the Banks tend to pay more... and if other companies are competing with the banks for c# staff (for whatever reason), then they will in turn have to pay more... just a theory.

Adam Young on November 25, 2005 10:31 AM

I like C# because it makes jumping into ActionScript, JavaScript, and other languages easier for me. Suprisingly, I was 95% vbScript in the classic ASP days and I don't miss it one bit. Looking at vbScript just looks funny now.

Do VB.net and C# actually have any real strengths over the other?

Eric Fickes on June 6, 2006 03:16 PM

> If you're comparing strings in an application, should Jeff be equal to jeff?

>Ab-so-fricken'-lutely they should be equal.

Your kidding right? RIGHT??!!!

>but making it the default is just wrong and violates the 80/20 rule big time.

80/20 rule? Well, I guess I shall not pitty the poor sole who only has programed on one platform with only one langage.... Like Directories in MS not being case sensitive yet in the real world, er... I mean Linux C:\home IS different the C:\Home

Your right: http://www.Amazon.com the same website as http://www.amazon.com is the same place... a LOCATION but, if Jeff == jeff in your world how in God's name would you ever test for Jeff !== jeff??!!!!

E on June 15, 2006 08:41 AM

Everyone knows the Linux and UNIX file systems are case sensitive. The question is, is that a good idea?

The English language is not case sensitive, nor are the humans that speak it. Most people will not even see "may-2005" as being different from "May-2005". The psychological different between the two is just shy of nil. So why needlessly complicate things for the user?

Since the compiler is a program that humans work with. Since humans are case insensitive, the compiler should be as well.

As for not being able to test for "Jeff !== jeff", you are just being dense. No one is saying that we should remove the ability to make case sensitive comparisons.

Jonathan Allen on June 15, 2006 12:59 PM

in German common words are starting by a majuscule, but adjectives not. In some sens german is case sensitive.

But anyway I agree with you, case sensitive naming rules is really tricky. I've never seen any arguments in favour

fred on June 19, 2006 08:57 AM

Most of the arguments against case sensitivity are the same ones used as for. Its all a comfort issue. I prefer insensitivity. However, when forced to write in Java as is often the case in my job. I deal with it. The paycheck has the same numbers at the end of the week.

Wow, are we still at this after two years????

ChasMan on June 21, 2006 05:56 PM

> Wow, are we still at this after two years????

I know. And many programming religious wars go back 10, 20, even 30 years. It's amazing any actual work gets done, isn't it?

Jeff Atwood on June 22, 2006 11:15 AM

what about that...?
dim arr as object(0)
????
ugly

VB on July 14, 2006 05:12 PM

I build the parts in C#, and use VB for glue.

Bertus on August 1, 2006 03:52 AM

Christian Romney:

"If arg is Nothing Then Return" is valid (or something like it.. point being you don't need end if)

Dave on August 25, 2006 11:39 AM

Try this in C# with the same amount of code:

Private WithEvents Timer1 as new Timer
Private WithEvents Timer2 as new Timer

Private Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick, Timer2.Tick
....
End Sub

Theo on August 28, 2006 10:40 AM

"The English language is not case sensitive, nor are the humans that speak it."

I'd be forced to disagree. I'm sorry for the mental image in advance, but there is a big difference in meaning in the following two sentences:

"I helped my uncle Jack off a horse."
"I helped my uncle jack off a horse."

jacob on August 28, 2006 01:25 PM

thanx for giving me knowledge abt c#

sugandha on August 29, 2006 11:27 PM

I think C# developers are paid more because many of them come from a C++ or Java background which lends itself to a much better object oriented background. Many VB coders have an extremely hard time truly understanding and applying OO principles. Just wrapping a bunch of functions in a class is not OO.

Also, someone coming from C/C++ will likely have much more technical depth -- having dealt with all the threading and memory management complexities that .NET makes easy.

It's more than what language one uses... its the experience they had prior to picking up VB.NET. I think you'll find few C/C++ and Java developers picking up VB.NET by choice. Actually, many VB'ers only know VB.

Brian Trexler on August 30, 2006 08:11 AM

Dear Friends,

I have been reading a lot about which language is better-
VB vs C# ?

Most techies have strong view points, but they are all based on 'geeky emotions' rather than logic or even common sense.

People say they should use C# because Microsoft is using it, or because it looks complex, or they have to type less, or that C# looks like a computer language and VB does not, or that C# programmers are smarter or that C# programmers are generally C++ programmers and hence they must be good because they can understand all that ridiculous code.

Well, if writing cryptic code = smarter people, then the richest people in business would all be C++ programmers or the leaders of this world would all be ex-programmers. I am not sure if that IS the case.

How many CEOs of medium/large companies are ex-programmers (except for a few CEOs of tech companies)? How many presidents,prime ministers are ex-programmers? None.

By the way I am a programmer myself, and have been for 20 years, and probably a geek too, in many ways.

What is the point? It is simply that we, the programmers, often enjoy writing and looking at cryptic stuff. It gives us a feeling that no one else can read it, and hence we must be smarter. And in doing so we fail to look at the 'big picture'. Big picture could mean many things- What works better? How to save time? What is better for the business? Why are we developing this application? Is there a better and simpler way? And so on.

I think a 'good' development language is one, which allows us to perform the most common (needed) functions in the shortest possible time, and offers a short learning curve, and is relatively easier for another programmer to comprehend.

Based on that- VB is much better, for ALL business needs. May be or may be not for systems programming-- I do not know.

Here is a link from Microsoft. They do not say, one is better than another, but read and decide for yourself, which is easier AND better for business-- the most common use for programming languages.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q308470

I have neither programmed in VB or C# before, but one need not be a rocket scientist to realize which offers shorter development lifecycles. It is certainly VB.

I am not saying C# is 'bad', it is just that it still contains most of the 'primitive' stuff- bad syntax, confusing pointers which are probably never needed in 99% of the applications, hard to read, etc. etc. Remember, C was developed for controlling telephone switches, and at least to me, it still looks that way!

Thank you for reading this long note.

mike on September 11, 2006 06:17 AM

Talked to an old pro. (A guy over 50 with a lot of consulting experience, obviously a C/C++ programmer) Anyway, he said that C# "scales better". Knowing that they are different wrappers on the same CLR, I did wonder if anyone was asserting that out here in the real world...
I didn't find anything like that in this discussion.

For my own development, I have a bit more of a comfort level in VB, so I use that, but it wouldn't bother me to use C# either, finding it readable enough.

I wonder if some truth lurks in his statement; maybe the pointers and whatever else is not used, not needed, and poorly understood by the VB programmers is where that extra power of C# is.

Dana on October 6, 2006 07:39 PM

I just read the MS paper linked to in the post prior to my first one. MS does say there is (almost completely) no difference. Somehow that falls short of completely convincing me that VB would scale as well. I really don't care that much, most of my projects are simplistic, and will continue using VB based on my familarity.

Dana on October 6, 2006 07:52 PM

personally i dont think it is that big of a deal.
Use what you want to, or what your told to.

i do alot of asp.net and we use c# for the framework code, and vb for aplication specific code.

my favorite quote "who cares let the IL do its job"

jr on October 13, 2006 02:43 PM

Please stop with the "vb is better then c# is better then java is better then c++ ..." my compiler can beat up your compiler arguments. The right tool for the right job. (John Holmes say that?)

A professional application should be able to scale, be maintainable, and cost effective. Simply put, if it is works for the business solution at hand use what is best.

I personally think VB.anything is a waste of money and time, my opinion right or wrong. Given that, I would never pay for nor write in VB.NET.

But, given the scope and scale of projects today, coupled by the wide range of programmer's skills, forcing a group to use something because it "seems" better or because someone read it is "cooler" then what they are used to is a death march waiting to happen.

Syntax is syntax and for the most part is nothing but sugar for the head, get through it and you know the language. The real solutions come from the logic you can implement with it. Abstraction, templates, OO, and patterns can be implemented in ANY language, including cobol. The higher the language, read abstracted, the easier to implement, but not always the best choice. The best solution is the most maintainable.

Don't believe it? Remember that bit of perl code you hacked together last summer as a quick way to learn the language? Well, it is central to your day to day operations now and you need to add functionality. (insert homer response here - DOH!)

Now, there are times you have to use a real language, yep that was a shot :-). Embedded is one that requires speed, scaleability, and hard core knowledge of the compiler and system. NEITHER VB nor C# cut it in that world unless your running a MS OS. Even then, you seldom see anyone use them, even MS.

VB .vs. C#, both are syntatic candy inside of the .NET framework which is on top of the CLR which runs using IL. When you get that far abstracted, arguing about the sugar is just silly. Like arguing about which spoon to use to eat desert.

What your comfortable with is what is best in the general case. (Unless it is VB.NET :-) )


Tim on October 17, 2006 02:38 PM

This argument is asinine and a bunch of hot air blowing. I program with VB, C#, Classic ASP, Java, Perl, PHP and old school C. IMO the difference between C# and VB are strictly personal ease of use. If you think that C# developers are smarter or that VB programmers can't understand OO then you're likely going to become one of those jackass managers that no one wants to work for. The biggest plus that I can see for C# is that it's syntatically closer to Java so it makes bridging the gap between the two languages much easier. And for the record, stupid knows no bounds.. I've met plenty of bad coders in every language I've used. Basic happens to have more because beginners do use it, why? Because it's a very inviting language that's much more intuitive to a newbie.

Microsoft in their quest to be everything to everyone made the language a preference and the Framework the important piece. Kudos to them for that... after all, a compiled WebPart written in C# can live in the same environment as that compiled WebPart written in VB. Anything I can write in either C# or VB I can write in the other and I haven't run into a single example of something that can't be done in both. C# vs. VB, Republicans vs. Democrats, Ford vs. Chevy, .NET vs. Java, Linux vs. Windows, Microsoft vs. Google, there's so much polarization it makes my head swim sometimes.

John on November 15, 2006 07:00 PM

"Well, if writing cryptic code = smarter people, then the richest people in business would all be C++ programmers or the leaders of this world would all be ex-programmers. I am not sure if that IS the case."
Smart and rich (and/or powerful) simply are not the same things.
"How many CEOs of medium/large companies are ex-programmers (except for a few CEOs of tech companies)? How many presidents,prime ministers are ex-programmers? None."
Programmers personalities are seldom suited to these kind of jobs.
"I think a 'good' development language is one, which allows us to perform the most common (needed) functions in the shortest possible time, and offers a short learning curve, and is relatively easier for another programmer to comprehend."
Agreed, and therefore this language will certainly not be a form of BASIC.
"Based on that- VB is much better, for ALL business needs. May be or may be not for systems programming-- I do not know."
Yet you have 20 years of programming experience. Surely you've at least looked at system programming in all that time?
"I have neither programmed in VB or C# before, but one need not be a rocket scientist to realize which offers shorter development lifecycles. It is certainly VB."
Well that is complete crap and I'm betting you are actually a VB programmer.
"I am not saying C# is 'bad', it is just that it still contains most of the 'primitive' stuff- bad syntax, confusing pointers which are probably never needed in 99% of the applications, hard to read, etc. etc. Remember, C was developed for controlling telephone switches, and at least to me, it still looks that way!"
The is completely wrong. Not only are pointers extremely useful in certain situations but the are well hidden in C#. The majority of code will not even contain a single unsafe block.
And C was most certainly NOT developed for controlling telephone switches. It was developed as the language to develop the UNIX operating system. You can also bet that the operating system you are reading this with was developed in C; whether it is Windows, Mac OS X, Linux, Solaris, BSD, BeOS, etc.

SCG on December 10, 2006 12:49 PM

If you want to fit in at a party with bankers you wear a suit. If you want to fit in at a party with bikers you wear a black t shirt and ripped jeans.

If a company is going to pay more for C# and thinks that C# is worth more then it's sometimes only because those who say how much to pay for a position are older folks who came up through the ranks when C/C++ was the god. They see curly braces in your IDE and they think you are smart ... like them :). Like a biker seeing the oil stain and the banker seeing the rolex. Humans like what they are like.

Jeff Ricther once told me over bad coffee & worse cake in New Orleans that "there is no difference at all between VB.Net and C#" and yet in that same conversation he said that C# was "better". "Better" because it was easier for him, it was like what he liked. (In the preface to the VB edition of his first CLR book he mentions that his view of VB was changed in that project because of his having to experience VB from a professinal perspective. 'They are the same' becuase more than just words.. becuase he swas forced to really give it a personal try)

I did VB for a long long time, since VB2Pro for DOS. I don't do it all that much any more (becuase I figured out how to make more money by simply doing VB with different syntax (more to come)). BUT I will ALWAYS love VB for what it gave me as an entry into programming, as a great tool that I wsas thrilled to use to show up VC++ people with when they said out of ignorance that VB could not do this or that annd I made it do sometimes even what they couldn't do on time, And I will always respect its history and what IT gave to computing.

Many if not most of the best IDE productivity enhancements came out of VB's IDEs (and remember I saw them all) from all the way back before Java, before Delphi and before VC (because you will recall that the product VB came before the product VC). Intellisense... what respectable IDE would be complete without it? It came first in VB's IDE, background compilation that IS a great thing (just see the ReSharper fans going ga ga over it) was part of VB at least back to 3. Dot syntax code completion... VB's IDE.

Step back a bit and think *Products* because VB is NOT and never was a language, it was - and its main power was - that it was a complete packaged tool; IDE + Syntax + Runtime. Prior to VB.Net VB could only be made in the IDE. "Tool" as in a set of program (IDE) and syntax (scripting for that program) to get things done.

Folks, you're being hoodwinked in this battle. The CLR is a great big huge runtime with all the garbage collection and abstraction for productivity ... that's VB, that is the real power of the heart of VB. And before you foam at the mouth... be a Scientist, do a little non-emotional history checking on the VB Product and think it over.

But keep up the fight for both sides because the more you dig in and LOVE AND KILL FOR your C# and the other guy LOVES AND KILLS for his VB ... Microsoft takes home the money from both of you. And the more money they make the better chance they'll keep making both to keep us fighting, to keep one Product team making something cool in a release while another makes something else for their Product then the next release they do what the other did because of the whining of the core audiences and both gbet better than the other in stages yet they both drive theo other to get better, etc etc.

The day MS decides to stop making one of them is the day we all lose. Becuase then we're locked into just one and like all single products that will stale mighty quick.

VB was not B.A.S.I.C., VB was and is a productivity tool for computers, primarily for business commputing. And if you can see that angle where that underlying truth is what VB really was and what really made it so incredibly wildly popular makes this thing a smart MASM guy once told me make a lot of sense:

"C# IS VB... with curly braces"

Use the one that makes you money, nothing wrong with money and nothing wrong with letting a boss believe that you're "smarter" becuase of using one syntax instead of another ... BUT use the other to know what yours still lacks and demand that yours gets it (and dmand that your other one gets things new too). Woe to the person who doens't use both, opportunities might be missed to do what is really cool: .Net.

:)


smithvoice.com

smith on January 17, 2007 10:07 PM

Well done Jeff Atwood for all your pointless comments.

Amusing that VB people are struggling so badly to defend their flawed language.

Well let's try something else rather than talking about syntax - how about the fact that C# programmers won't be getting RSI quite as badly as you guys. Why? Because they don't have to type twice as much code to get the job done.

I've used C# for 2 years, and VB.Net for a year, and I HATE VB.Net - it's awful. I come from a background in script languages similar to VB but anybody with half a brain can see that C# is the way to go. It's easier to write, less syntax, and its keywords and statements are all more obvious than their VB equivalents.

For example - public internal VS public 'friend'

COME ON!

G on February 20, 2007 02:12 AM

I have neither programmed in VB or C# before, but one need not be a rocket scientist to realize which offers shorter development lifecycles. It is certainly VB.</p>

"I am not saying C# is 'bad', it is just that it still contains most of the 'primitive' stuff- bad syntax, confusing pointers which are probably never needed in 99% of the applications, hard to read, etc. etc. Remember, C was developed for controlling telephone switches, and at least to me, it still looks that way!"

"I have neither programmed in VB or C# before, but one need not be a rocket scientist to realize which offers shorter development lifecycles. It is certainly VB."

mike on September 11, 2006 06:17 AM

The last sentence is pretty obvious - that you've programmed in neither. How, therefore are you qualified to make judgement on this? Anybody who's done programming in both languages would discount your first statement as complete nonsense.

VB does not offer shorter development lifecycles, as it allows non type-safe operations, so in fact your developers are likely to spend far more time debugging. I suggest you go and read up on this.

Kang on February 20, 2007 02:19 AM

Visual Basic is a BASIC language. Generally the code I've seen put together by VB programmers looks like amature crap. It lets you get away with murder - as a language it does not encourage discipline. VB should be used for 1 thing - M$ macros. I used to program in a VB style language and VB (Lotus Script). After learning to program in Java and PHP I left my job because VB style scripting made me want to puke.

Any language based around C is better.

a++ vs a=a+1
a-- vs a=a-1
a+=4 vs a=a+4
a*=4 vs a=a*4

a=a==1 ? 0 : 1;

vs

if a=1 then a=0 else a=1

Etc, etc, etc

guy on February 27, 2007 02:02 AM


a+=4 and a*=4 is recognised syntax in vb aswell.

ML on March 3, 2007 05:14 PM

I started with VB6 but then a few years later moved to VB.NET and used
it to the point when I couldn't use it anymore for what I was doing.

I moved to C# because of the fact I could use unsafe code, pointers in paticular,
something VB doesn't look like it will ever support.
C# also prepared me for C++, a skill I would definately need to use
in the future.

Most .NET developers tend to use it for mostly ASP.Net but I on the
other hand use it for heavy desktop development, as you see in my new blog,
so the more native-like power I get from my language the better.

Otherwise I don't see any reason VB.Net should be considered any better
than C# or J# or any other language for that matter.

On a side note I will admit Phalanger (MSIL compiler for PHP) is looking sexy, especially if
it were to be used as a scripting language inside of a text adventure
engine or something.

Jimmy

Jimmy on March 3, 2007 11:59 PM

Sorry, wrong link.
Anyhow I thought I'd add that C# and VB.NET don't really have any
differences but if you really want power then everyone needs to try
Managed C++. This language is @#%! awesome! Its like C# but without
the limitations of regular C++ and you can
use native code and librarys and other stuff normal .NET will not let
you do.

MC++ FTW!

:)

Jimmy on March 4, 2007 12:03 AM

My big gripe with vb.net is its lack of a multi-line string literal, which makes using embedded SQL a real pain.

C# sugar:

const string sql = @"
SELECT *
FROM table t
WHERE t.column = :p_column";

This 1) improves legibility, both in the code and in app logs, 2) speeds coding/maintenance, and 3) promotes using parameterized SQL.

Post all "you should use stored procs" flames here:
http://www.codinghorror.com/blog/archives/000117.html

Jarrod on March 4, 2007 09:04 PM

To all you C# developers, shut the hell up. The language doesn’t make you elite; it is what you do with it. If you only knew how you sound. Just shut the hell up. You sound like a bunch of bigoted zealots from the old south.

You C sharpees kill me to death. I think you find VB a little confusing so you pick C# the easier language. As far as I'm concerned VB is the more superior language whether it is in the hands of a real programmer or not. VB is not the straight jacket that C# tends to be. VB allows many more ways to skin a cat. Where C# may seem lean and agile it looses its flare and edge. I must contend that C# is not a language of a true artist but then true artists do use the thing. What I’m saying is that language is neutral in a common language infrastructure environment (.Net, Mono, Delphi). So off course if you use one then learning the other is redundant, unless you have to. I would always choose a VB background over C#, C++, java etc, and I won’t tell you why mister smarty pants. Lets be real, you are only building business applications. That is not rocket science or dare I say it, neither is it computer science. The phony elitism by these guys is beyond asinine and I will address who the real idiots are later. What I want to know is have you built any new technologies lately. Oops, sorry about that low blow to the testicles. Just having a little mean spirited fun at your expense. I’ve been ignoring this crap from you guys for years. So back atcha. You try to persuade that VB and its users are inferior for all the wrong reasons. I’ve used Basic, VB, Assembler, C++, java, oh what ever. C# is not a new invention friends. C# is just a C, C++ and java knockoff. C# is a bastard 3 generations removed and you want to bust our balls. Yes you guessed it; I don’t intend to relieve you of your ignorance. I like you just the way you are. I don’t want to persuade you to like or use VB. Why, because I enjoy feeding my arrogance with your ignorance. So on that point I am leaving you in the dark where I found you.

In the end VB and C# are just tools. The real intellect comes from choosing the one that suites you and the job best. The tools don't make the man, the man makes the tools.

Sharpees also try to put on airs because they are able earn slightly better pay then Vebras (VB developers). I just love bursting this little Arian fable you guys like to spin about. As Yoda would say, "Well rounded, you are not". It is a simple matter of economics (supply and demand), there are far fewer C sharpees. If you intend to get one of the little buggers you will have to pay a premium. Do you remember PowerBuilder and SQL Gupta. Well that’s good because that’s all they are now, a memory. At one time they both commanded more than VB in the market place. So there you are my little grass hoppers. Those Idiots use the same dumb arguments you like to spread around today. Here is my Mr. T impression, “I pity the Fools”. It’s easy to hop on a bandwagon, the trick is being savvy enough to hop on the right one. VB is still here and they are not. There you go hot shots, so you can stop clicking your boots and saluting Hi-Hitler. If sharpees had any real sense they would just shut the hell up. Why would you want more people to start using your language and bring down your stock (A.KA your earning power). Just shut the hell up. Only an Idiot would bandy such nonsense.

I hope I have offended someone, or we haven’t started having any fun yet. Please read on.

Oh and why do I call C# users C sharpees? The language and the name (C#) remind me of that little ugly dog.

Anyway we have much bigger fish to fry in the near future so it won't matter if you are a vb, cc, dd, c#, blah, blah, Blah.

If you really want to know what the elite is all about I guarantee you won’t find it in C#. If you really want to broaden your horizons you better find out what Linux and Mono is all about. You sharpees don’t even know you are just slaves. Common Language Infrastructure under Linux will set you free. I’m sure most of you want to be elites are scratching your heads now so I will rap this up because I have wasted enough time with you chaps. You now have real elite knowledge. Off course if you where elite as sharpees like to pretend then this thrashing would not have been necessary. In any case we all want to be the best that we can be. I just shared the path with you. You have ability to be much more than just programmers and developers. You should strive to be Computer Scientists. That is what the world needs. The world could give a rat’s ass about the contents of your tool box.

The Great Desdubler has Spoken …


desdubler on March 9, 2007 11:55 PM

I've programmed old VB form several years and then turned to C++ and C# as I became a professional. I'm sure there are many good VB.Net-programmers out there, but still I'm personally a bit prejudical when I meet one. I think that he is either a) a beginner, b) he's previously worked functional or other non-mainstream languages, or c) before VB.Net he used old VB and for some reason never switched to a professional language.

Before I became a c++-programmer I used VB for several years (from version 2.0). It took me some time to undo the poor practices I had been forced to develop as a VB-programmer. Old VB is a horrible (despite its RAD IDE) language compared to c/c++. I agree that VB.Net and C# are very similar - I've worked with both a lot - which shows that even the VB-developers finally realised how flawed their original creation was.

So I agree with Brian Trexler's post, the background of a c# and a vb.net-programmer is what really differs.

Tomas on March 13, 2007 01:28 AM

Ok.

First. I admit that VB.NET and C# are in syntax and power context *VERY SIMILAR* and *MOST* of the things you cand do with C# you can actually do them in VB.

Though. There are some things that you can't help like unsecure programming. Ok, Ok, many of you would say that you don't usually do that. But in terms of being productive, you couldn't use ZLib, o PDFLib or other standard library in .NET (in ANY languages) if C# and C++.NET wouldn't be out there, and sometimes you need that king of thing. (Note: I know that in .NET 2.0 and above there are a clas for compression with ZIP standards).

Another thing is the attachment of events. It's just so easy to add or even quit events in C# from a class, and even easier to create new ones. Not so in VB where you can only use one method at a time and you must to handle the manner inside the procedure of the event which can be tedious to manage if you want a specific control or component act different in given enviroment variables.

I think is a *little* bit more optimized C# than VB because is a new language. (Note to Java developers: Please do NOT start a new discussion thread on this. I already DO agree with you).That means it has nothing to do with backward compatibilities like optional arguments that MSIL does not support like C++ and VB and pascal do.

That's all. I don't think any programmer should feel superior to another because "hey I'm programming in C#. Chek my 7331 skills". I honestly use C# because I *PERSONALLY* like its semantics specially in casting and treating the null clause. (again, THIS IS MY PERSONAL opinion).

Juan on March 14, 2007 01:18 PM

Wow... you guys get quite passionate. I admit... i hate VB. But i certainly dont think C# is better then it. I just happen to find the syntax easier for MYSELF to read. Whenever I see !value i instantly know what it is. seeing if not value forces my brain to read it like a logical sentence instead of just recognizing it as it is. It also feels like without the ending semi colons its a big long run on statement. However i've talked to some old Cobol programmers here that complain C# looks like an operating system language, not a real programming language :). They say the C# is completely unreadable. Whenever i look at VB code i get a headache. Whenever they look at C# they get sick looks on their face. I guess its just a matter of what your used to looking at. They both do the same thing.

scott on May 30, 2007 12:25 PM

"The English language is not case sensitive, nor are the humans that speak it."

I'd be forced to disagree. I'm sorry for the mental image in advance, but there is a big difference in meaning in the following two sentences:

"I helped my uncle Jack off a horse."
"I helped my uncle jack off a horse."
jacob on August 28, 2006 01:25 PM

Technically, the first sentence should read "I helped my Uncle Jack off of a horse"

English on July 18, 2007 01:13 PM

I concur with English. You must use your helping verbs A.K.A. your linkin verbs. They are the verbs that help connect the subject with the predicate, helping you to form complete sentences.

BorisV on July 23, 2007 10:36 AM

OMG English that was brilliant.

I'm a C# dude I find it to be less forgiving to my mistakes and forces me to write better code.

I started in VB and moved to C# and didn't go back.

I find Me. a bit immature and this. so much more adult like ;)

Either way though both languages end up as the same thing and don't look much like the code you wrote. I'm at the bottom rung of programming.

I have heard that the IDE is written in C#.

Also I always though the the code I write is in a language designed to be easy. It goes through several transformations before the machine gets it's hands on it.

A good understanding of Assemble and C/C++ is where the professionals are at. I never had aspirations to get there though. I like the simplicity of .Net

Robert on July 27, 2007 08:55 AM

In teaching myself how to program, I started out in VB and had to listen to all of the self-proclaimed Gods of programming shouting their C++ sermon on the mount. People that code in VB aren't real programmers.

When I went back to college, my courses were in C#. Now, I code in nothing but C# because it's the language I prefer - I found it easier. The .Net framework really makes the argument rather moot.

I think the most important thing about your code is that your users never see it, that it doesn't implode. I'm not sure that case sensitivity is a huge factor, Uncle Jack not withstanding.

(I laughed for a while over Uncle Jack - thanks English!)

LinkinPlanck on July 27, 2007 11:56 AM

My only concern is which language will survive the longest. I Love Perl so I'm very familiar with C-esq syntax, but I like VB for web development better. I like the verbosity of it which tends to help debugging and knowledge transfer. But I would switch if I thought MS was planning to dump VB any time soon.

Al on August 29, 2007 11:18 AM

I recall BASIC being the acronym for Beginner's All-purpose Symbolic Instruction Code.

Michael on October 11, 2007 06:46 AM

Well, since this topic is still getting posts, I might as well have my say too.

One thing that I haven't seen mentioned here (and I admit, I haven't read every single reply, all the way through) is finding answers to questions and general documentation issues.

I personally find no major differences between VB.Net and C# in terms of what they can do. I have been a VB/VB.Net programmer for a number of years and I have come to like writing in C# even more, and for one reason in particular. Regardless of whether one language is "better" or another, I have found that when I am looking for the answer to a particular problem, I more frequently find the answer written in C#.

Numerous tutorials and how to's also use C# as the primary language. Personally, I think everyone should learn to use both. It will give them a lot of insight into how the CLR works, but as far as finding additional help goes and getting at resources to assist in development, it seems like there is more support overall for C#.

This technically has nothing to do with the language or the syntax.

For a long time, I didn't feel that Microsoft Office actually held any particular benefit over some of the other office suites. In fact there were some things that I loved in word perfect over word any day. Even so, I found that Word ended up being the better application for me, for the simple fact that so many other people used and supported it. I feel similar toward C#, whether it is technically better or worse than VB is not the main point. I find that when I need help, I find it much quicker to find for C# than for VB.

ChrisS on October 19, 2007 01:21 PM

Personally I prefer C# because it feels more natural to implement object orientation, defining delegates and events, using generics, and casting using the C syntax. However, there are areas in Visual Studio 2005 IDE where the only code you can write is in VB.NET, such as the code modules of Reporting Services.

So I guess it helps to be familiar with both.

cyclo on October 19, 2007 01:32 PM

Supposedly, there is very little difference between VB.NET and c#.NET, they are all compiled via .NET, and using visual studio intellitype makes the difference between then negligible.

However, comnig from php and jumping into .net i was posed with choosing c# or vb.

To me it was a simple choice of c#.

I find vb looks childish. An odd attempt to combine English and code, which just adds charaters to the code you have to read.

I find the usage of braces { } makes the code look segemeted and clean, but words such and Then and End If are difficult to distinguish from other code at a quick glance.

Also, i guess my experience in PHP and then having to code in ASP VB for some projects was quite an eye opener, VB just felt so strange.

Usage aside, I personally feel c variants, php and java braces style programming etc just looks more professional than VB.

Laurence on November 21, 2007 07:35 AM

VB.NET is a useless language. It is not simple (as any basic in the world - even as MS old VBs). It is exactly (almost) as a C "like" language. You must type-create-make all the things you type-create-make in a "complicated" language like C# but with more typing!!. So VB.NET is Visual not Basic language and hence there is no need to have such discussions as VB.NET vs C#.
public void foo(string arg)
{
if (null == arg) return;
// code here
}
C# 65 typings
Public Sub Foo(ByVal arg As String)
If arg is Nothing Then Return
// code here
End Sub
VB.NET 83 typings
(Please, this is posted with no offensive mood)

ilias on December 5, 2007 07:02 AM

I am currently a Senior Programmer in a large health insurance company. We are predominantly a .NET plateform, but you know, we work with whatever tools are necessary. We have a project coming up in '08 that uses some existing IBM technologies, and the way we are tailoring it to our particular use and interfacing with parts of it is through Java. No biggie. Like some have said, you select the tool that helps you get the job done. You should never become too attached to any one tool. Most of the time we use VB, and I really enjoy it. I first cut my teeth on Java and C++, but I eventually got around too C# as well. It really is not as big a deal as people are making it, but aren't programmers known to argue over trivial things, or just to be arguing? If I am under a time crunch, I will use VB. It's quick and dirty. If I have time to breathe, then I will most likely use C# to switch things up and keep things interesting. If your customers need fast results, then use whatever it is that helps you deliver. They don't really care what language you are using, or how many languages you know. They just want it to work, and work yesterday.

I also disagree with the sentiment that VB programmer are less intelligent or capable than C# programmers. That's like me saying anyone who didn't graduate from the mighty University of Illinois got an inferior education - it can sometimes be fun to make such statements, but you shouldn't really believe them. A good programmer will thrive no matter what language he is using. A lazy programmer will take shortcuts any change he/she gets. I have met masterful VB programmers and ghastly C++/C# programmers. I think part of it depends on your own aptitude, and part depends on what you were exposed to and how good your teachers were. The guy who taught Java was Polish, with a very thick accent that made it very difficult to understand. But in lab, the lady was Indian, and although she had a thick accent as well, she was very good at breaking it down. By the time I got to Advanced OOP, I was well prepared. The guy I learned C++ from had no business teaching in a university. Most of the class came to me when they had a question. But for people who may not have had a talented peer or a motivated professor, their knowledge will be incomplete at best and outright wrong at worst. And their future colleagues will make them feel like they are stupid because of their deficiencies and inexperience. Hey, these are people who need to put people down to feel good about themselves. I can say without hesitation that knowing what someone's primary platform is no indication of their grasp of OOP or anything else. If I found myself out of work, I feel I can jump to whatever language is necessary and still TCB.

GrayFox on December 8, 2007 12:13 PM

Eventually everyone will be programming. I think that VB or VB-like language will survive over a C-like language because of the English-like syntax. They will be teaching it in elementary schools.

CodeHead on December 11, 2007 07:45 AM

hmmm, i working on a project ... image processing application (ACDSee like). And i cant decided which to use, C# or Vb 6....

-vip-

vidyaputra on December 12, 2007 11:48 PM

As someone who wrote his first program before most of you were born (aplologies to anyone born before September 1964)and has written software in numerous assembler languages, COBOL, Fortran, VB, C#, C++ and a number of other languages no one has heard of I would say that from a maintenance point of view VB is superior.

VB allows optional arguments which means you only have to have one version (I know more versions are generated under the covers) visible in the code. This means you only have to make changes in one place instead of in several overloaded versions of a routine. If fact overloading doesn't cover all cases - consider a routine with two optional strings. Dead easy in VB; Can't be implemented with overloading.

VB also allows named arguments, which in addition to providing useful documentation about the called routine, provides a safety net if the routine's interface changes.

The features may seem trivial, but if you consider the lifetime maintenace costs of a system are typically 3 times the development cost anything which reduces maintenance is a good thing;

llorracj on December 14, 2007 07:16 AM

You guys amaze me! You think there's a difference between C#.net and VB.net? The syntax is near as dammit identical! Swap me/this, =/== and add or remove a few ; and {} and you've got the other language. Wise up you C# elitists - Microsoft's secret is that C# is actually VB with curly braces ( a has already been pointed out).
If you don't beieve me, look at any programming book that provides code examples in both C# and VB. After a couple of chapters, you can't tell the difference!
Before the advent of the .net languages, it really was a case of the best tool for the job; a competent VB dev would be more productive on a typical business client/server app than an equally competent C developer, simply because the higher level of abstraction was appropriate for the requirement. Similarly if the intention was to write a competitor to Word, then C would beat VB hands down - once again, because it was the tool for the job. Again, writing something that gets even closer to the hardware - real-time idustrial control, say, or a driver or even an OS - would require assembler or C or a mixture of both; or VB for the UI and C to talk to the hardware. To say one of _those_ languages is 'better' is simply as meaningless as saying a dentist's drill is 'better than' a Bosch hammer drill.. . .but to argue about the minute differences in the syntax of the CIL pre-compilation dialect you happen to prefer is just utterly absurd . . . .


pg on January 10, 2008 02:31 PM

There is a VB equivalent to:
public void foo(string arg)
{
if (null == arg) return;
// code here
}

Write it like this (as of .NET 2.0):

Public Sub Foo(ByVal arg As String)
If arg is Nothing Then exit sub
' code here
End Sub

Jonny B on March 26, 2008 09:09 AM

oups... looks like I've jumped up the screen tonight :)
was looking for a benchmark comparison between VB6 and C# and all i get is VB.NET VS CSHARP that both does the same SMILE !
A small article and a big bunch of comments for it... well let me say that's all folk guys.
When you don't need speed but need design patterns, maintenability, interoperability... everything that's end with bility... just use .NET or .JAVA. But for speed let's say that c with no sharp is better and eventually c++... and eventually VB if you don't want to deal with pointers and memory stuff. What we see today is .NET using COM interop and low level black boxes. I always keep in mind that the first and only thing is the customer SMILE so.
All this "verbiage" around who's the best language is just ... You can do ... with C# to !
Sorry for that bad spelling frenchy token ring stuff!

vicolachips on April 11, 2008 12:59 PM

Ok, I just read through 3 years worth of posts here and I didn't have my question answered.

Background: I pretty much just started into the world of programming. I am mainly interested in web development but, it's all good to me. I have done some research in most main-stream languages and have been mostly working with PHP for my server-side stuff.

I have been feeling like the .NET path is the way to go from here. I have always known that the best programmers don't stick to just one language. Why else would there be so many? Anyway, to cut to the chase, I know to truely be an employable developer, I need to know both C# and VB.

My question to the masters is: which should I learn first?

Oh, and just so you know, I'm already leaning toward C#, just because of the easy transition into other C based languages.

I would love any feedback though, thanks already!

Xaq on April 16, 2008 07:10 AM

Xaq - it doesn't matter which you learn first. They're almost the same language except for differences in syntax. You could learn both side-by-side I suppose without much extra effort.

KG on April 16, 2008 09:26 AM

I think it's a more personal preference thing. If I came from a background of C/C++, I would prefer C#, but considering my background is from VB, definately I would look at first at VB.NET.
Like what most have said, choose the right tool for the right task.
A C++ syntax would fall as a 3rd GL, and a VB syntax would fall as 4th GL. Isn't it?

j2e on May 11, 2008 06:26 AM

Actually...

Jeff != jeff even in the English Language. The reason one places the first character in upper case is because of a particular reason. Read up on the history of why proper nouns are made upper case.

It does boil down to a class of society issue, but that, in the end this debate is about just that: C# society vs. VB society.

Adron on May 31, 2008 09:40 PM

well. (clears throat) some interesting banter here. now on with what's important. would a developer please convert the following to VB for me. muchas gracias mi amigos.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Reflection;

namespace ClassLibrary1
{
public static class MyExtenders
{
public static DataTable ToDataTable(this IEnumerable collection)
{
DataTable dt = new DataTable();
Type t = typeof(T);
PropertyInfo[] pia = t.GetProperties();
//Create the columns in the DataTable
foreach (PropertyInfo pi in pia)
{
dt.Columns.Add(pi.Name, pi.PropertyType);
}
//Populate the table
foreach (T item in collection)
{
DataRow dr = dt.NewRow();
dr.BeginEdit();
foreach (PropertyInfo pi in pia)
{
dr[pi.Name] = pi.GetValue(item, null);
}
dr.EndEdit();
dt.Rows.Add(dr);
}
return dt;
}
}
}

Adam Cox on June 10, 2008 10:38 PM







(hear it spoken)


(no HTML)




Content (c) 2008 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.