Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advantages of using C# over VB.Net 2

Status
Not open for further replies.

Terpsfan

Programmer
Dec 8, 2000
954
US
I've been mostly an Access/VB6/SQL Server developer and am excited about the trek to Visual Studio.Net. I'm wondering what would be the advantages of using C# over VB.Net. I'm mostly dealing with your standard form interfaces to databases, but will get more into the web development phase later this year. I'd appreciate some feedback on whether it's advisable to go with C# or learn VB.Net first then gravitate towards C# since it's more complex. However I've heard so many good things about C# maybe I should go down that route first and not waste my time with VB.Net.
 
I'm mainly a Visual C++ experience, but with lots of experience in other languages and OSs. To my mind VB and VC++ were very different, so the trip from the former to the latter was very steep.

I haven't used VB.Net at all, but from what I read, it's pretty close to C#, which has dropped many of the complexities of it's partial C++ origin.

The advantage you might find in tackling C# right away is that C#, like Java, has a more modern syntax than VB, whose original design dates back to Dartmouth University around 1970.

Good luck,
Richard

 
Ummm, this has been addressed several times before in this forum.

But to answer your question: If you think learning C# is hard, wait until you try and learn the .NET framework! There is a *lot* in there. Don't freak out, though. You'd have to learn the framework no matter which language you choose. Luckily, the online docs are much better than in the past, so it's pretty easy to find things.

Learning C# is just like learning any other modern O-O language - all the concepts are the same, it's just the syntax which is different. The thing that probably trips up most newcomers is the difference between the assignment operator (=) and the comparison/equality operator (==). In VB they were the same (which was a bad choice, but given the origins of the language, understandable).

Chip H.
 
I like C#. I was mainly programming in c++ and in Java Swing. I'm certified in Java 2 programming. It is not that hard to use C#. I just joined a company which uses Msft platform. I was given a c# window application right away. It is the first time I touch c#. But now I am in the project for a month and happy with c#. The libray is so rich. When you are thinking of sth., search the online library with some keywords, you will find it. I think anyone with OOP experience can adapt to c# and .NET quickly.
 
My background was in VB and I started learning VB.NET. I have since moved to C# but that was because of certain limitations of VB.NET (you can't overload operators in VB).

There are two things you'll need to learn - a language (VB or C#) and the framework (.NET). They are pretty much independent - most things you can do in either VB or C# - in fact, lots of books provide examples of both languages.

So, either way works.

If you have the time to learn C#, I would recommend you go that route. If you want to get moving quickly, do things in VB. You'll pick up the C# pretty well as you go along. Visual Studio allows you to use both VB projects & C# projects so, if you code reasonably Object Oriented, you can re-use the VB code as you move to C#. I do it all the time, it works great.
---
dino
 
Thanks everyone for your help, this will help guide me in the right direction.
 
Managed C++ has some real advantages. Particularly if you are coming from a C++ background. I am not a hard core C++ programmer so C# ended up being a lot easier for me.

It has been nice to have so many options without much of a barrier between them. So the decision ultimately lies with the intent & plans of the user - Any of these options work.

I am looking forward to when they have CLRs for Unix and Linux....

---
dino
 
When will they have CLR for unix/linux. Read an article. It predicts that in two years, .NET users will be more than Java/J2EE users. Now c# users is 1/15 of Java users.
 
Dino,

Question about your comments. I have been learning C# thru reading and going thru appdev's c# training cd's. They specifically recommended against overloading operators because they said it is the easiest way in .net to create impossible to understand code.

Do you have an example of overloading operators that is shows why they would help?

Thanks,

Pf
 
Don't really have a code example, but one circumstance where it might be useful might be:

A client sends you an XML file containing an invoice (via XML or something). You'd create an invoice object, then add line-items to it using an overloaded "+" operator.

Is that better than coding an "Add" method? Maybe. Depends on what you're used to. I wouldn't use the phrase "impossible to understand" ... it's just a different way to accomplish the same task.

One situation where using operator overloading would be bad, is if you had to interoperate with some VB.NET assemblies. The VB code would be unable to use your overloaded operator.

Chip H.
 
chiph is spot on as to the downside. Although, it is not a problem if the overloaded operator "+" calls the objects "Add" method. So in VB you'd have to use the Add method. I learned that the hard way.

But I don't know why someone would think overloading operators leads to confusing code. In my case, created an object that was a vector (in the algebraic sense ie. magnitude & direction) and I wanted to add & substract & otherwise manipulate vectors as a datatype.

Obviously, you could use the methods but adding vectors a & b as

c = a + b; // is exactly how you would write it down on paper.

there is an underlying Add method but this code is a lot easier to understand (yeah yeah this is a trivial example but imagine a big block of code manipulating lots of vectors!)
---
dino


---
dino
 
They didn't really go into details about why they thought overloading can create bad code. But they kind of hinted at programmers who might overload "+" for some object, but have it do something that has nothing to do with what you would expect "+" to do.

pf
 
Overloading like most things can be abused. It simply gives programmers much greater freedom to abuse it than most other concepts.

IMHO, it greatly attributes to C++'s reputation as being the worlds only 'Write Only' language.
 
lol. :)

I think C# is a lot more understandable than C++ but I was not brought up on C++. Of course, part of the problem was working with Win32 calls in C++ as well. Learning C# & .NET has been a lot easier. ---
dino
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top