Is C# Better?

  • Scott Roberts-430649 (11/13/2009)


    peter-757102 (11/13/2009)


    There will be a distinction in software that needs more power and has to go multi-threaded or at least be aware of it and thus require subsequently more programmer control, and the single thread coding we are all used to from today/yesterday. There really is no magic middle ground that isn't been used or in use today already. From this angle I rather see people actually learn how things work and become good at programming (controlling things) then learn to accept blind faith that the magic platform will solve it all.

    Both C# and VB support multi-threaded applications just fine. I'm not sure I follow you.

    peter-757102 (11/13/2009)


    The question of which GC language without time precise destructors is better is therefore utterly irrelevant.

    I'm not a huge fan of GC either. And the notion that you don't have to worry about memory management with a GC language is flat out false. You still have to remember to "derefenence" all objects - which isn't always as easy as it sounds.

    The latter is exactly the point I am making....you do need to care about memory and thus it is the programmers responsibility always. It should not be coated over as if you dont't have to care, which is exactly what the compromises the GC enforced in a language and the associate gospel does. As for the threading part, yes you can...but then what is the added value over previous languages if it reintroduces the associated complexities in the language while the sole purpose was to make it less difficult to program in...at the expense of control? I am all for a clean start and throw away unneeded baggage, but the .NET and java are both not it.

  • To answer Steve's question about the technical differences between the languages and what makes one better than the other I've listed some things that I've come across in my time. It is due to these differences that I say, "C# is 'better' than VB.NET".

    Paul brought up the fact that originally VB.NET didn't support Xml documentation, which is a very big feature and one of the reasons I chose C# when .NET was first released. (I had been programming in VB 5 and VB 6 with some experience in C and C++). C#, being a completely new language didn't have all the "legacy crap" carried over into it like VB.NET did. For example, as richardd also stated, And and Or statements in VB were never short-circuited. So in VB.NET they came with "AndAlso" and "OrElse". And for michael.rosquist, your code example is hard to read because of your coding style. Not the syntax style, but the code itself.

    if (((exactType == true) && (oControl.GetType() == oType)) ||

    (oType.IsInstanceOfType(oControl)))

    {

    if (null != controlMethod)

    {

    controlMethod(oControl, delegateParam, depth);

    }

    }

    Can be:

    if (exactType && controlMethod && oControl is oType)

    {

    controlMethod(oControl, delegateParam, depth);

    }

    You see, you don't need to specify " == true". Also, a reference type will evaluate to false if it's null, so you can move that one variable name up into the first if() statement. Finally, by using the "is" operator, we can check to see if oControl can be cast to type oType. Meaning it is either of type oType or is derived from it.

    Can you do the same thing in VB.NET? I don't know. I have not kept up on the syntax and features.

    Another big thing for me in C# .NET 2.0 is anonymous methods. To my understanding, they are not available in VB.NET (in .NET 2.0). However, with .NET 3.5, each language does support Lambda Expressions, but it appears that VB.NET does not support multi-line Lambda Expressions.

    VB.NET doesn't have shortcuts for %=, <<=, >>=, &=, ^=, |=. And it flat out doesn't have the bit shift operators "<<" and ">>". It doesn't have prefix increment or postfix increment operators.

    VB.NET reuses the term "Or" for both bitwise operations and logical operations. So what does

    If 0 Or 1 Then

    do?

    C# allows you to write "unsafe" code and actually declare and use pointers. I have had one instance were this was needed and it helped performance tremendously.

    VB.NET does not support block style comments. Actually, I don't use the /* */ for blocks, I use them for actual inline comments.

    if (var1 == 42 /* short important comment */ && var2)

    VB.NET doesn't have the "volatile" key word.

    One shortcut I really like in C# is the using clause (which is finally available in VB.NET)

    using (FileStream fs = new FileStream())

    {

    }

    It ensures that all objects that implement the IDisposable interface are properly wrapped in a try/finally block so they are disposed of.

    Case sensitivity also really helps out when writing classes and declaring private members and public properties.

    C# has the null coalescing operator "??" which is very nice sometimes.

    Ed W. said that C# doesn't support optional arguments. That's not completely true.

    public static void Serialize(BinaryWriter bw, string someVar, params object[] args)

    {

    }

    I also like and completely agree with jwhitmer comments about strong typed languages.

  • I have been using structured error handling in VB.NET since day one. 😎

    From my experience running a 2500+ .NET User Group, folks who come up the C, Java, C++ route are more comfortable with C# as expected. Those of us with decades of experience and 10 to 20 languages with widely different syntax like VB or don't have a strong preference. Pascal and Delphi were my most productive languages, but VB and C# provide a much better income. I do like the XML support in VB.NET but it's really 80% Framework and 20% language. I'm still a bit more productive in VB.NET, but C# is certainly widely used. Hate to sound crass, but pay me and I'll code in it.

    In the interest of full disclosure, I am an MVC in VB.NET.

  • Steve, you were looking for something specific.

    Delegates.

    Up through 2005 anyway VB.Net is unaware of Delegates.

    Don't ask me what they are, I came from VB6 and I'm still trying to understand them, but when I talked to a C# instructor, he said this was the one conceptual item that hangs up most VB developers.

    On another note, you mentioned that they all operate on the CLR, so aren't they the same (except syntax)? How about this comparison? Since they have ported Pascal 7 to .NET, does that mean you can type all C# functionality into a Pascal app. I don't think so. I think it depends on what is in the ported libraries, and this is true for VB and C#, the C# Object libraries are quite different. I know MS published Class library posters, I wonder how different they look.

    This same C# instructor told me that C# was a language progression of C++ and Java (with some other stuff to), and that the growth of VB was not in the same direction, so there will definitely be class differences.

  • After a good few years doing classic ASP development, using, of course, lots of javascript to enhance the user experience - and doing a few other projects in VB6 - I got asked to take over a pretty big development project that had been started in C#.

    I had never written a line of C# or C or Java - but I had written bucket loads of javascript. With the intellisense in Visual Studio and the similarity to javascript, it took me about 2 days to get up to speed.

    Now, when I have to maintain old sites done in vbscript - or projects done in VB6 - I hate it.

    I guess 'whatever you're using at the moment' is what is best. I'm glad I took up C# - there is a lot more demand for it.

  • I come from a C++ background, but learned VB6 for my first job then VB.NET. Now I am thankful for that knowledge because we are writing SSIS packages for SQL 2005. We have to convert old DTS scripts and C# is not supported in SQL 2005. Although it now is in SQL 2008, I find that being conversive in both is sometimes necessary.

  • If VB.NET has OPTION STRICT set ON, then the code produced is equally as efficient as C#!

    There is are plenty of C# programmers who decry VB.NET whereas the reverse is very rare. The fact of the matter is that once you know the Dot Net framework, learning the other is a matter of a few days work.

    And what is my favourite of the two? The one that gets me the next contract!

  • Hi

    I'm a C# and I have no problem with VB.NET. I just don't understand why features like "Option Explicit Off" or "On Error Resume Next" are still supported. I've started with VB long time before .NET was available and I never understood those "features"...

    I'd be happy if any VB guy could tell me any case where those things might be helpful. (Except: "Because some Excel VBA players don't know how to define variables and how to handle errors".)

    Greets

    Flo

  • As per Microsoft (I believe…) there are 3 personalities among programmers: Einstein, Elvis and Mort.

    C++ the language and IDE settings are for Einsteins, C# is for Elvises and VB (VB.NET) is for Morts.

    Einstains build Operating Systems and the like. Elvises build high end systems (high performance, high scalability, etc..). Morts build little systems to accomplish immediate business goal.

    The majority of very good programmers work as either Einstain or Elvis and most of them will prefer C#. Morts are quite often business users that solve business needs by writing code (not necessary a great code but even that inferior code might have a big business value).

    I think that it explains why C# programmers look down at VB programmers. It does not mean that there are no great programmers that prefer VB.NET but I think that assumption that C# programmers will build better (higher quality, better scaling..) system VB.NET programmers might be a quite valid one.

    Personally, I hate VB syntax and I hate VS IDE settings for VB. Sometimes, I try to help with VB.NET projects and I am lost in VB IDE settings. Advanced functions hidden, namespace not added and so on. I have seen VB.NET developers troubleshooting issues in VB that I never had in C# because of cryptic error messages or because of project settings that do not enforced good programming practices. It’s easier to find good code examples of advanced topics in C# than it is to find them in VB.NET.

    So in my opinion: for big, state of the art projects it’s better to use C#. So, in a sense C# is a better language.

  • Coming from C/C++ background, I naturally gravitated towards C#. But having done VB and C# projects, I find C# less verbose and easier to maintain. For this same reason, I'm now attracted to F#. A few CLR functions I migrated to C# showed how this can simplify code further.

  • In a business context (i.e. getting the job done quickly, good quality and maintainable!)

    VB.Net = simple, so productive

    C# = techie, so less productive.

    The difference comes down to the 80/20 rule; actually more like 95/5. i.e. 95% of most business applications can be written in VB.Net faster than C#.

    The difference IMNSHO is that C# is preferred by programming snobs who think the more technical and verbose the language is the better it must be.

    Take an extreme example: COBOL vs C++. For procedural code (batch programs, web services, etc.) COBOL wins hands down as its about getting a process coded not how fancy the coding is. While its possible to write unmaintainable code it COBOL, you need a real noddy to achive it. Using C++ however you can write stuff that nobody will ever understand and will keep you in a job for years. But use COBOL to OO based programming like for a UI and C++ starts to come into it's own. Low level OS,multi-threading, caching coding is another example as you can't use COBOL for these tasks.

    So its a horses for courses call based upon coder productivity and not which language is "better".

  • It's just a preference(whether personal or imposed by employer).

    I find c# code a little more brief and geeky.

    whereas VB code looks more humane 😀

    I use c# now

  • So its a horses for courses call based upon coder productivity and not which language is "better".

    may i quantify additionally?

    years and years ago, i was at the home of this programmer (i don't even call him 'developer') who boasted to me that he earned more than a million from selling his version of tax program to small businesses. he had self-learned foxpro so i am sure i don't even need to see his code if it was an art, i just knew it wasn't.

    but the program ran and he had livelihood. at that time then, i could not help comparing that i, with all the training and studying of computer coding, systems designs, etc. was applying for a job.

    musashi, to paraphrase the legendary swordsman, said 'it doesn't matter whether its a long sword or short sword as long as it does the job of cutting.' i guessed he used both.

    if there is language in the world which should be better, it should be your choice of language that gives you the 😀 money and makes you happy :w00t:

  • Samurai sword or Machete, that guys found himself in the right place at the right time. Its called luck my friend and the ability to recognise and take the opportunity when(if) it comes.

Viewing 15 posts - 136 through 150 (of 176 total)

You must be logged in to reply to this topic. Login to reply