views:

311

answers:

8

Possible Duplicate:
Should I learn VB.NET or C#?

Question

I have 30+ years of C experience, 15 of C++, no Java and rusty, 25 year old Basic (a bunch of other, probably not relevant, languages: PHP, Pascal, Ada, various assembers, etc).

I will be using Visual Studio Express to create both Windows applications and brower based apps.

I am not interested in career advancement, so, given the above, should I learn VB or C#, neither of which I have coded before? Are there any technical advantages of one over the other, wider support, etc, etc?

The apps and web apps will probably use ODBC for database access


Edit: the Visual studio express page compares VB, C# & C++ and says that only C++ has the "Full Capability" to "Create native Win32 applications" (look under "Visual Studio 2010 Express Product Feature Chart")! Am I misunderstanding something here?

Meta-comments

BTW, although this was an earnest question, it was not without tongue-in-check until some humourless automaton changed the title. Kudos to all who recognized the reference to http://thedailywtf.com/Articles/5_years_C-pound_experience.aspx


Closed as "possible" duplicate .... although the rote, boilerplate close-test says "This question covers exactly the same ground as earlier questions on this topic" .. oh, no, it don't ...

I have explicitly stated below why this question is not a duplicate - and that I have searched for, and read, every question that might be relevant, but found that none answered my particular question - but, you, who closed this as duplicate, obviously know better (or cannot read, YMMV)

A: 

There isn't much difference technically, especially with 4.0. I think a lot of employers would accept either if you knew the .NET framework really well. (And just in case it's not a joke, it's C-Sharp, not C-pound)

Lou Franco
Sorrry, I am abosultely not interested in the markeeting of my skills ( for personal; reasons, which I won't state here). Please take that as a given. If that were the only advantage of one over the otehr, then it woudl be a tie in my eyes.
Mawg
@mawg: It is insulting that you would copy / paste the same comment to three different thoughtful answers. Methinks you protest too much -- in a really silly way...
drewk
@drewk, I could stand that on it's head and say that it is insulting that three people couldn't be bothered to read my question, or did read it and decided to answer the question that they think that I ought to have asked. I spend a lot of time on various fora, usually answering more than asking and find that I tend to qualify my questions, anticipating the answers that people think that I ought to have asked rather than that which I did. No offense intended here. It forces me to clarify my thoughts to such an extent than many questions don't even get asked
Mawg
@drewk (+1 to show no hard feelings) If people can't be bothered to take the time to read my question, why shoud I be bothered to reply to them individually, or, indeed, at all? At elast cut/paste shows that I read their "answer" and why I think they missed the mark - widley. It's all etiquette, I guss
Mawg
I read the question. It was "Are there any technical advantages of one over the other?". My answer was "There isn't much difference technically, especially with 4.0." Frankly, the question as it was originally worded was confusing and distracting, which is why I probably missed the career advancement part. It is worse now (with the embedded meta-discussion). It would be nice if you'd edit it down to the actual question only, so that this page is more useful. The links to the duplicate questions will also be useful to those seeing it in the future.
Lou Franco
+1  A: 

Even if you're not interested in career development, you probably should be interested in marketability of your skills.

To that end, I would choose (and, in fact, have chosen) C#. I'm afraid that VB is still stained as being considered a toy language even though it's every bit as powerful as the vast majority of other languages.

This is not a technical argument (since I haven't used the latest VB) but I do keep my finger on the pulse of people who hire and fire and there is still that perception there, however unfounded.

Given that both C# and VB use the underlying .NET, there's probably not a great deal of difference under the covers. But, since you already have experience with languages more like C# than VB (C/C++), I would go with that.

I've found WPF quite easy to get used to, coming from a Java Swing world and my application, after a little help from the SO crowd, actually look quite good.


And, if I were not even interested in skills marketability, I would choose the easiest path which, for you, is likely to be C#, simply because of your huge exposure to C/C++.

paxdiablo
Sorrry, I am abosultely not interested in the markeeting of my skills ( for personal; reasons, which I won't state here). Please take that as a given. If that were the only advantage of one over the otehr, then it woudl be a tie in my eyes.
Mawg
+1 for easier path" (even though I would tke the more dififcult, if it were the "better"). Thnaks
Mawg
+11  A: 

C# will most definitely be easier to pick up if you have 30 years of C style languages.

All your knowledge of the core language structures (if/for/while/etc..) will carry right over as well as the basic bracket layout of your code. Variable declarations will mostly be the same as well. I also find there's a lot more sample code/tutorials/open source project available for C# as well. Chances are if you are searching google for how to solve a .net problem the solution you find will be in C#.

jwsample
Thanks (+1). That helps
Mawg
+1  A: 

I would say that if you are aimming for a career based language you should get a niche or a high demand language.

Tiobe.com has one of the most comprehensive indexes around.

5   5       (Visual) Basic  5.413%      -3.07%    A
6   7       C#              4.986%      +0.54%    A

They are both closed coupled together. VB seams to be going down and C# up. The higher the ciommunity the better the support (not always but lets just assume). Also C# is much closer to what you are used to... would go with C# in a blink.

Frankie
Sorrry, I am abosultely not interested in the markeeting of my skills ( for personal; reasons, which I won't state here). Please take that as a given. If that were the only advantage of one over the otehr, then it woudl be a tie in my eyes.
Mawg
@mawg sorry, misread your question; updated the answer.
Frankie
+1 for question -) Thanks
Mawg
+1  A: 

I'd recommend c#, as it more closely resembles languages you are familiar with. vb.net isn't all that much different in how you use it, but the language is sloppier. if you later have to make the transition from one to the other, i think it's easier to go from strict to lazy, rather than vice versa.

you can build windows apps with c# or vb.net, but the machine has to have the .net framework installed for the app to run. c++ can build a native win32 app that does not require a framework installed.

lincolnk
VB is as strict as C# if you use `Option Strict` - and you always should. C actually isn't very strict. If you tell the C compiler a cast is valid, it believes you.
MarkJ
+1  A: 

C# by far. The C# community is growing. The VB community is declining. That means it will be easier to find help with C# and there will come a time when new features are added to C# that are not added to VB, if that time hasn't already come.

Wade Williams
Anything to back this up? Microsoft say there are more programmers using VB than C#, and they also recently committed to maintain parity between the two languages. I would agree that the C# online forums seem to be more active than the VB.
MarkJ
No, I don't have hard stats. Just my experience in the industry and observing the programmer community.
Wade Williams
+6  A: 

As a C programmer, you will definitely be much more comfortable with C#, at least with the syntax which tends to be less verbose than Visual Basic. Here's an example to declare a class.

Visual Basic

Public Class MyClientClass
    Implements IMyClient

    Private _id As Integer
    Private _company As String
    Private _phoneNumber As Long

    ''' <Summary>
    ''' Constructor...
    ''' </Summary>
    Public Sub New()
    End Sub

    Public ReadOnly Property Id As Integer Implements IMyClient.Id
        Get
            Return _id
        End Get
    End Property

    Public Property Company As String Implements IMyClient.Company
        Get
            Return _company
        End Get
        Set (ByVal value As String)
            If (String.IsNullOrEmpty(value)) Then Return

            _company = value.Trim()
    End Property

    Public Property PhoneNumber As Long
        Get
            Return _phoneNumber
        End Get
        Set (ByVal value As Long)
            _phoneNumber = value
        End Set
    End Property
End Class

C#

public class MyClientClass : IMyClient {

    private string _company;

    /// <summary>
    /// Constructor...
    /// </summary>
    public MyClientClass() { }

    public int Id { get; private set; }

    public string Company {
        get {
            return _company;
        } set {
            if (string.IsNullOrEmpty(value)) return;

            _company = value.Trim();
        }
    }

    public long PhoneNumber { get; set; }
}

The above C# code is valid only from version 3.0, as it handles the getters and setters through an in-memory generated variable that you, as a programmer, don't need to care about when you do not require special handling, but to assign and to retrieve the property's value.

Visual Basic explicit implementation can be fun when you want to rename the implementations of your proerties or methods. C# doesn't allow so, but permits implicit implementation by the method's or property's name.

In short, since you have so much experience with the C syntax, and C++ keywords such static, abstract, etc. you'd rather go with C#. Your learning will seem a lot easier for you. Then, keep in mind that both languages are using the .NET Framework. So, as long as you stick with the .NET Framework, you will become fluent in both languages in no time, this will only be a matter of syntax afterwards.

For example:

abstract (C#) = MustInherit (VB)

internal (C#) = Friend (VB)

static (C#) = Shared (VB)

virtual (C#) = MustOverride (VB)

and so forth.

In the end, it may be no more truthful with .NET 4.0 coming out, but even in .NET 3.5, C# had many advantages over VB.NET as for stuff you could do in C#, and couldn't in VB. C# is (or was before .NET 4.0) THE language with which Microsoft wanted to launch its .NET platform. As a matter of fact, plenty of interesting technical stuff you could do with C# couldn't be done with VB. For instance, the use of InternalsVisibleToAttribute in .NET 2.0.

The InternalsVisibleToAttribute is similar to the C++ keyword friend, which allows one assembly to access internal members osf an alien assembly. Very practical for testing. Making your internal members of your core assembly visible to your testing assembly saves you lot of work with reflection. In .NET 2.0, it's available and functional in C#, but not in VBNET 2.0. (See here for further information).

Using lambda expressions is very funny when you can use them. In VBNET, the keyword used for a lambda expression is Function. However, if you had to use a lambda expression which doesn't actually return a value, you had to work around like illustrated in this question of mine. So, making a call to the address of the actual sub-routine you wanted to perform. But even though you only had to use this sub into just one location, this lambda expression, you had to fully declare a Private Sub, and passing the AddressOf the sub so that the compiler calls it when it is time to do so.

Nevertheless, I know that Microsoft stated she wanted to come up with a fully loaded Visual Basic with the coming of .NET 4.0, making the gap between the two languages thinner and thinner and thinner again so that there is no longer this kind of war "C# is better than VBNET", if you get my point.

Such technical difference was supposed to be corrected in .NET 4.0. I just don't yet know if they did. Anyone knows if they did so?

Hope this helps! =)

Will Marcouiller
Minor correction. The current version of VB, version 10 released in April, also [has automatically implemented properties](http://msdn.microsoft.com/en-us/library/dd293589.aspx) As you say Microsoft have declared they will give the languages parity from now on, so it should mean almost no difference between VB and C#.
MarkJ
@MarkJ: Thanks for the update about the automatically implemented properties in Visual Basic. I didn't know Microsoft had gone this far for their wish for parity in the latest release. That sounds very good to my ears. =)
Will Marcouiller
@Will, I'm a c# coder, but will cry "cheat" as the bracing style you've used is a tad unfair, plus it's (at least based on the code I've seen and the way VS formats code, by default), a non-standard style. That said, I dodn't dispute that VB is more verbose, that's fact =)
Rob
+3  A: 

VB.NET and C# are two "CLR" (common language runtime) languages. They compile to the same intermediate representation. You can probably do anything in VB.NET that you can do in C# with a little finagling, and the execution speed should be the same.

That said, there is a lot more code being written in C# than in VB.NET. This includes the examples at MSDN. VB.NET also has certain constructions ("UBound" comes to mind) that make for icky code. I don't write in either of these languages, but if I had to pick one I'd pick C#: more popular and less ugly.

The other thing you asked about is only C++ being able to create "Native Win32 applications". That is true. But Microsoft does not want to anyone to write "native" Win32 applications any more; the new standard is "managed" applications that run under the .NET framework. (For this reason, you'll probably want to be using ADO.NET instead of ODBC.) If you are starting a new Windows app from scratch there is no reason to use the Win32 API instead of the .NET framework; you give up a little speed but you gain stability.

One disadvantage of both VB.NET and C# is that they are very "Microsofty". Yes, there is Mono on Linux, but practically speaking if you are writing in C# you are targeting Windows. Not that there's anything wrong with that, but plenty of people are writing web applications in non-Microsoft environments. (Python and Ruby seem to be particularly popular.)

Robert Calhoun
+1 for thoughts about managed applications, and moving away from Microsoft specific languages.
MarkJ
+1 for thoughts about managed applications, and moving away from Microsoft specific languages (and +1 to @MarkJ)
Mawg