Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. 10 Reasons Why Visual Basic is Better Than C#

10 Reasons Why Visual Basic is Better Than C#

Scheduled Pinned Locked Moved The Lounge
csharpcomquestion
143 Posts 57 Posters 126 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mycroft Holmes

    I am about to go up in front of a bunch of VB developers and explain why the company standard is C# and why they need to change their language. The primary reasons for the change have NOTHING to do with any of the points made by this author.

    Never underestimate the power of human stupidity RAH

    C Offline
    C Offline
    cpkilekofp
    wrote on last edited by
    #117

    What are the primary reasons?

    "It's not what you don't know that will hurt you the most, it's what you think you know that isn't so." - Unknown

    M 1 Reply Last reply
    0
    • P Pascal Ganaye

      I can write both languages equally. I just hate the snobbery that is displayed by some C# programmers. The differences between the languages is getting slimmer with every version. As I see it C# is much nearer to VB.Net than it is to C. There are many things that were in VB long before they appeared in C#. The article is right, the Visual Studio IDE recompile on the fly and show syntax errors faster in VB than it does in C#. This is not about the language but it can be taken into account when you choose a language. This days I work mainly in C# and I enjoy it. The one thing I miss is the ability to put a property in a ref our out parameter. VB can do that and C# (at least 3.5) can't.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #118

      Pascal Ganaye wrote:

      There are many things that were in VB long before they appeared in C#.

      And vice versa. There's nothing wrong with this either way; it's good that languages take on positive features of other languages.

      Pascal Ganaye wrote:

      The one thing I miss is the ability to put a property in a ref our out parameter.
      VB can do that and C# (at least 3.5) can't.

      Are you talking about:

      public void MyMethod(string text, out int retValue1, ref int retValue2)
      {
      retValue1 = 10;
      retValue2 = 20;
      }

      If you are, this has been in C# since v1.

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      P K 2 Replies Last reply
      0
      • OriginalGriffO OriginalGriff

        To add to the above: 1) Case is case - and people use it for different things. Personnaly, I like case to be maintained as it ensures camelCase it not lost halfway through - and since Intellisense sorts it out for you, it is hardly a problem. 2) I will give them that one - but the case statement is not meant for things like that: if statements are. 3) Is it so much work to do this? Rename works to re-assign the handler in C# anyway... 4) If you can't work out symbols for operators, perhaps you would be better off with COBOL... 5) I prefer the C# snippet "prop":

        prop[TAB][TAB]

        public int MyProperty { get; set; }

        Ready to be filled in... 6) Char.IsNumber anyone? 7) For the same reason that most languages have a full stop at the end of the sentence. 8) Doctor Jones, anyone? Professor Plum? Constable Smith? Mr White? Mrs Black? 9) Strictness is a virtue of C# not a problem - hence the existance of type safe List<T> rather than ArrayList 10) And what do you think ReDim Preserve is doing behind the scenes? At least with the C# version it is obvious that this is going to consume time and memory... IMHO Andy Brown needs to get a bit more real-world experience before shooting his keyboard off...

        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

        L Offline
        L Offline
        louthy
        wrote on last edited by
        #119

        OriginalGriff wrote:

        1. Char.IsNumber anyone?

        If he really wants IsNumeric, just add an extension method to the Object class.

        public static class ObjectExtensions
        {
        public static bool IsNumeric(this object @this)
        {
        return Microsoft.VisualBasic.Information.IsNumeric(@this);
        }
        }

        Usage:

        string test = "123";
        if (test.IsNumeric())
        {
        // Woah! I can extend the functionality of systems by writing code.
        }

        Then every object will have the functionality which is clearly stopping such a talented individual from getting the most out of C#.

        OriginalGriffO 1 Reply Last reply
        0
        • P Peter Adam

          That's nice regarding the number of the parentheses but it is a condition around the is operator under the hood - it is slower and emits an useless null on failure.

          L Offline
          L Offline
          louthy
          wrote on last edited by
          #120

          Which is why most professional C# programmers don't work directly with Object, and work with strongly typed objects. They will use various polymorphism techniques to handle type specialism. If the entire issue with C# is "how do I tell one type from another" then I'd say there are bigger issues for the programmer to deal with. Like, education, training, reading. I posted this on another reply if that's all you need in C#;

          public static class ObjectExtensions
          {
          public static bool IsNumeric(this object @this)
          {
          return Microsoft.VisualBasic.Information.IsNumeric(@this);
          }

          public static T ConvertTo(this object @this)
          {
              return (T)System.Convert.ChangeType(@this, typeof(T));
          }
          

          }

          Usage:

          string test = "123";
          if (test.IsNumeric())
          {
          // Woah! I can extend the functionality of systems
          // by writing code.
          }

          int number = test.ConvertTo<int>();

          But I would argue you should very, very rarely have to do this kind of thing. Perhaps when deserialising, but definitely not in general case coding. Subclasses should be used to provide type specific functionality, and objects should be held with references of the type they represent, or in base-type references with virtual methods for accessing subclass functionality.

          P 1 Reply Last reply
          0
          • P Pete OHanlon

            Pascal Ganaye wrote:

            There are many things that were in VB long before they appeared in C#.

            And vice versa. There's nothing wrong with this either way; it's good that languages take on positive features of other languages.

            Pascal Ganaye wrote:

            The one thing I miss is the ability to put a property in a ref our out parameter.
            VB can do that and C# (at least 3.5) can't.

            Are you talking about:

            public void MyMethod(string text, out int retValue1, ref int retValue2)
            {
            retValue1 = 10;
            retValue2 = 20;
            }

            If you are, this has been in C# since v1.

            *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

            "Mind bleach! Send me mind bleach!" - Nagy Vilmos

            My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

            P Offline
            P Offline
            Pascal Ganaye
            wrote on last edited by
            #121

            More something like this:

            Sub Main()
                Parse("5", A)
            End Sub
            
            Property A As Integer
            
            Sub Parse(text As String, ByRef retValue1 As Integer)
                retValue1 = Int32.Parse(text)
            End Sub
            

            Would translate in C# into

                static void Main(string\[\] args)
                {
                    Parse("5", out PropertyA);
                }
            
                static int PropertyA { get; set; }
            
                static void Parse(string text, out int retValue1)
                {
                    retValue1 = Int32.Parse(text);
                }
            

            The C# compiler doesn't like it though. Error 1 A property, indexer or dynamic member access may not be passed as an out or ref parameter For info the vb compiler compiles something like this:

                int tmpA = A;
            Parse("5", ref tmpA);
            A = tmpA;
            
            P K 2 Replies Last reply
            0
            • C cpkilekofp

              What are the primary reasons?

              "It's not what you don't know that will hurt you the most, it's what you think you know that isn't so." - Unknown

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #122

              Support, standardisation and availability of resources, both human and code. Standardisation mostly, we have an uncounted number of teams all doing their own thing, repeating earlier problems and building unsupportable nightmares.

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              • P Pascal Ganaye

                More something like this:

                Sub Main()
                    Parse("5", A)
                End Sub
                
                Property A As Integer
                
                Sub Parse(text As String, ByRef retValue1 As Integer)
                    retValue1 = Int32.Parse(text)
                End Sub
                

                Would translate in C# into

                    static void Main(string\[\] args)
                    {
                        Parse("5", out PropertyA);
                    }
                
                    static int PropertyA { get; set; }
                
                    static void Parse(string text, out int retValue1)
                    {
                        retValue1 = Int32.Parse(text);
                    }
                

                The C# compiler doesn't like it though. Error 1 A property, indexer or dynamic member access may not be passed as an out or ref parameter For info the vb compiler compiles something like this:

                    int tmpA = A;
                Parse("5", ref tmpA);
                A = tmpA;
                
                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #123

                I see, although I can't see a situation where I would want to do this.

                *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                1 Reply Last reply
                0
                • L louthy

                  Which is why most professional C# programmers don't work directly with Object, and work with strongly typed objects. They will use various polymorphism techniques to handle type specialism. If the entire issue with C# is "how do I tell one type from another" then I'd say there are bigger issues for the programmer to deal with. Like, education, training, reading. I posted this on another reply if that's all you need in C#;

                  public static class ObjectExtensions
                  {
                  public static bool IsNumeric(this object @this)
                  {
                  return Microsoft.VisualBasic.Information.IsNumeric(@this);
                  }

                  public static T ConvertTo(this object @this)
                  {
                      return (T)System.Convert.ChangeType(@this, typeof(T));
                  }
                  

                  }

                  Usage:

                  string test = "123";
                  if (test.IsNumeric())
                  {
                  // Woah! I can extend the functionality of systems
                  // by writing code.
                  }

                  int number = test.ConvertTo<int>();

                  But I would argue you should very, very rarely have to do this kind of thing. Perhaps when deserialising, but definitely not in general case coding. Subclasses should be used to provide type specific functionality, and objects should be held with references of the type they represent, or in base-type references with virtual methods for accessing subclass functionality.

                  P Offline
                  P Offline
                  Peter Adam
                  wrote on last edited by
                  #124

                  Maybe I lack education, training and reading but I don't see how your conversion framework helps the crippled typecasting in C# I spoke about: just let the parentheses around the object not around the type and a pair of them is saved.

                  L 1 Reply Last reply
                  0
                  • P Peter Adam
                    1. type casting: one can save a pair of parentheses, compared to C#.
                    P Offline
                    P Offline
                    Paulo_JCG
                    wrote on last edited by
                    #125

                    Peter Adam wrote:

                    1. type casting: one can save a pair of parentheses, compared to C#.

                    WHAT!!!!??? first thing tomorrow is changing all code to VB

                    Paulo Gomes Over and Out :D

                    1 Reply Last reply
                    0
                    • P Peter Adam

                      Maybe I lack education, training and reading but I don't see how your conversion framework helps the crippled typecasting in C# I spoke about: just let the parentheses around the object not around the type and a pair of them is saved.

                      L Offline
                      L Offline
                      louthy
                      wrote on last edited by
                      #126

                      The point is you shouldn't be typecasting very often - it's a sign of a broken design (an exception would be serialisation). If you are then you're not using the OO features of the language to their full extent. If I ever see a cast from one type to another then I tend to treat the code with suspicion. Fair enough sometimes the framework itself doesn't always have the support required for strongly typed objects (like DataRow), that however isn't a failing of the language, it's a failing of the framework. It really isn't tough to write wrappers for the times when you need to do this. You posted this: int _ownerid = ((dsApartmentHouse.OwnerLookupRow)((DataRowView)OwnerLookupBindingSource.Current).Row).OwnerId; That is exactly the situation I'm talking about. A proper OO solution wouldn't return a reference to an Object for 'Current'. So this is a failure of the framework. You could in this instance subclass BindingSource and provide a property called CurrentRow which returns a type of dsApartmentHouse.OwnerLookupRow. You can then do: int ownerId = OwnerLookupBindingSource.CurrentRow.OwnerId; Which keeps the code nice and clean, and hides the papering over the cracks between your code and the framework. You could even create a template version which does it for all types of BindingSource.

                      P 1 Reply Last reply
                      0
                      • J Jorgen Andersson

                        Here[^] Now, where was that bulletproof vest? <Takes cover under a fireproof blanket> A bulletproof vest can take at least one 45ACP, right?

                        Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

                        S Offline
                        S Offline
                        Spiro Kourouklis
                        wrote on last edited by
                        #127

                        In order to get my degree I had to learn, or more appropriately become familiar with, VB, C#, Java, as well as some scripting languages. So in order for me to become really good at developing programs, I decided to concentrate on one. However, the language I really wanted to learn was C/C++. Why? Because that is the grandfather of most of the programming languages we use today. Now, since Java and C# are similar to C/C++, and since I was already familiar with Java and C#, and since using Visual Studio for creating programs makes thing much quicker and easier, I decided to concentrate on C#. Is my reasoning sound?

                        K 1 Reply Last reply
                        0
                        • M Mladen Jankovic

                          case-sensitivity alone is sufficient reason to ditch C#!

                          If he meant it seriously, then he's a complete moron.

                          M Offline
                          M Offline
                          MarvinMartian
                          wrote on last edited by
                          #128

                          Trust me, he's complete!

                          1 Reply Last reply
                          0
                          • J Jorgen Andersson

                            Here[^] Now, where was that bulletproof vest? <Takes cover under a fireproof blanket> A bulletproof vest can take at least one 45ACP, right?

                            Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

                            K Offline
                            K Offline
                            KP Lee
                            wrote on last edited by
                            #129

                            Well, I'm not going to shoot bullets at you nor the author. I think the main discomfort is: "Whichever language you are most comfortable with, is the better language." The problems in each language generally translate into a lack of understanding of the language. The best argument I saw was the lack of case logic and that's because I'm familiar with case logic in other languages. However if...else if...else... works just fine in C# without break statements. You could also argue that is more like regular english than case logic ever will be. My main gripe with VB.NET is that in VS it understands and can use existing intellesense to help you with routine/parameter definitions, but there is no way you can build intellesense definitions in VB.NET. My main gripe with C# is that

                            int sss = int.MaxValue;
                            if (sss + 1 == int.MinValue()) Console.WriteLine("{0} + 1 equals {1}", sss, int.MinValue);

                            produces: 2147483647 + 1 equals -2147483648 (The precompiler doesn't allow if (int.MaxValue + 1 == int.MinValue()) because IT runs in checked mode) And that was because I didn't know about "checked"! Before that, I was sure I'd found a bug in C#, when it really is a lazy execute feature. I do admit to swearing at VB.NET when I found out 2/3 was 1. Until I found out 2\3 was 0 just like "always" and you get a choice of which "int" math you wanted to use. I was a little disturbed by his get/set property. You have a text field that has "unrealated info" in it, and you execute Name="my related info"; and Name will now return "unrealated info" until you change the text field to "other unrealated info", now Name returns "other unrealated info" while name has "unrealated info" and "my related info" goes off into never-never land. That pretty much cinched it for me. The author was intentionally begging to be shot at by C# bigots.

                            1 Reply Last reply
                            0
                            • S Spiro Kourouklis

                              In order to get my degree I had to learn, or more appropriately become familiar with, VB, C#, Java, as well as some scripting languages. So in order for me to become really good at developing programs, I decided to concentrate on one. However, the language I really wanted to learn was C/C++. Why? Because that is the grandfather of most of the programming languages we use today. Now, since Java and C# are similar to C/C++, and since I was already familiar with Java and C#, and since using Visual Studio for creating programs makes thing much quicker and easier, I decided to concentrate on C#. Is my reasoning sound?

                              K Offline
                              K Offline
                              KP Lee
                              wrote on last edited by
                              #130

                              You're making me feel old, I believe C came out around 15 years AFTER I started my programming career.

                              1 Reply Last reply
                              0
                              • B bwallan

                                A few of the reasons I'll stick w/ VB for serious coding! Although I do have to venture into C, C# and C++ code on occasions to convert it to VB...

                                K Offline
                                K Offline
                                KP Lee
                                wrote on last edited by
                                #131

                                Other than personal preference and general dislike of the other languages, why do you HAVE to convert it?

                                1 Reply Last reply
                                0
                                • J Jorgen Andersson

                                  Here[^] Now, where was that bulletproof vest? <Takes cover under a fireproof blanket> A bulletproof vest can take at least one 45ACP, right?

                                  Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

                                  C Offline
                                  C Offline
                                  ClockMeister
                                  wrote on last edited by
                                  #132

                                  I have systems written in VB6, VB.Net and C#. I like working in all 3. For new things I generally prefer C# but both it and VB.Net are very up-to-the-task and both work great. The rest of you may get religious about your choice of language if you like. -CB :-)

                                  1 Reply Last reply
                                  0
                                  • P Pascal Ganaye

                                    More something like this:

                                    Sub Main()
                                        Parse("5", A)
                                    End Sub
                                    
                                    Property A As Integer
                                    
                                    Sub Parse(text As String, ByRef retValue1 As Integer)
                                        retValue1 = Int32.Parse(text)
                                    End Sub
                                    

                                    Would translate in C# into

                                        static void Main(string\[\] args)
                                        {
                                            Parse("5", out PropertyA);
                                        }
                                    
                                        static int PropertyA { get; set; }
                                    
                                        static void Parse(string text, out int retValue1)
                                        {
                                            retValue1 = Int32.Parse(text);
                                        }
                                    

                                    The C# compiler doesn't like it though. Error 1 A property, indexer or dynamic member access may not be passed as an out or ref parameter For info the vb compiler compiles something like this:

                                        int tmpA = A;
                                    Parse("5", ref tmpA);
                                    A = tmpA;
                                    
                                    K Offline
                                    K Offline
                                    KP Lee
                                    wrote on last edited by
                                    #133

                                    I'm lazy, I assume a string came from the user, so I further assume it is screwed up and would use int.TryParse and either throw an error or override it with a default when the string really is screwed up. ("int" because its shorter and exactly the same as Int32.)

                                    1 Reply Last reply
                                    0
                                    • P Pete OHanlon

                                      Pascal Ganaye wrote:

                                      There are many things that were in VB long before they appeared in C#.

                                      And vice versa. There's nothing wrong with this either way; it's good that languages take on positive features of other languages.

                                      Pascal Ganaye wrote:

                                      The one thing I miss is the ability to put a property in a ref our out parameter.
                                      VB can do that and C# (at least 3.5) can't.

                                      Are you talking about:

                                      public void MyMethod(string text, out int retValue1, ref int retValue2)
                                      {
                                      retValue1 = 10;
                                      retValue2 = 20;
                                      }

                                      If you are, this has been in C# since v1.

                                      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                                      K Offline
                                      K Offline
                                      KP Lee
                                      wrote on last edited by
                                      #134

                                      I get two "A property, indexer or dynamic member access may not be passed as an out or ref parameter" as errors from the last statement:

                                          static int val1 { get; set; }
                                          static int val2 { get; set; }
                                          static void MyMethod(string text, out int retValue1, ref int retValue2)
                                          {
                                              retValue1 = 10;
                                              retValue2 = 20;
                                          }
                                          static void Main(string\[\] args)
                                          {
                                              MyMethod(" ",out val1,ref val2);
                                      

                                      How do YOU pass properties as out or ref parameters? Personally, it makes total sense to me. Properties are an abstraction level that protects the value that stores the actual storage location. out and ref are both asking to have direct access to the storage location. That violates basic principles of properties. I would be EXTREMELY surprised if VB.NET allowed that to happen. Seems like inexperience in what properties are, that would cause the complaint.

                                      P 1 Reply Last reply
                                      0
                                      • L Lost User

                                        That 'snobbery' comes from bad experiences, at least in my case. When someone like the guy who wrote that article claims to have many years of experience and then has nothing else to worry about than case sensitivity, switch/case statements, IDE support or array redimensioning, then something is seriously wrong. It may just be my perception, but thst kind of extremely narrow view and VB often come together. Let them sit in their little world and think they are the best, I don't care. But if I have any choice, I avoid having to work with such people.

                                        I'm invincible, I can't be vinced

                                        U Offline
                                        U Offline
                                        User 7670143
                                        wrote on last edited by
                                        #135

                                        I am a VB developer. Actually I am an application developer who uses VB. I am not your better, but I am your equal. If you know how to design an build applications, the language is irelevant.

                                        1 Reply Last reply
                                        0
                                        • L louthy

                                          OriginalGriff wrote:

                                          1. Char.IsNumber anyone?

                                          If he really wants IsNumeric, just add an extension method to the Object class.

                                          public static class ObjectExtensions
                                          {
                                          public static bool IsNumeric(this object @this)
                                          {
                                          return Microsoft.VisualBasic.Information.IsNumeric(@this);
                                          }
                                          }

                                          Usage:

                                          string test = "123";
                                          if (test.IsNumeric())
                                          {
                                          // Woah! I can extend the functionality of systems by writing code.
                                          }

                                          Then every object will have the functionality which is clearly stopping such a talented individual from getting the most out of C#.

                                          OriginalGriffO Offline
                                          OriginalGriffO Offline
                                          OriginalGriff
                                          wrote on last edited by
                                          #136

                                          louthy wrote:

                                          clearly stopping such a talented individual from getting the most out of C#

                                          LOL! 5!

                                          Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups