Results 1 to 30 of 30

Thread: VB and C#

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    VB and C#

    I am now learning C# in class and already know alot on VB. I was wondering, Are there noticable benefits to using C# over VB? I was thinking performance would be better in C# but VB has a better verbose-type statement structuring making it easier to program an application far faster.

    Thoughts?
    Currently Using: VS 2005 Professional

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: VB and C#

    Learning C# will be easy since you know VB.NET already. While the rest of the posts in this thread will tell you about how C# performs better or is better than VB.NET for whatever pompous reasons, the thing you have to keep in mind is that your job prospects increase if you know both languages.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    Well, I have a passion for programming and I want to learn everything I cann about everything I can. I do, however, like to stick to a primary skillset that is most beneficial in the aspects I need it to be.

    I have been reprogramming a SQL DB application I recently started from VB to C# and noticed that C# seems to run faster, at least from inside the IDE. Syntax is about the only thing I am struggling with, but with 2 classes of C++ from earlier in college I am not struggling as much as I thought I would.

    Are there performance benefits in certain types of applications that C# will prevail over VB in? For example, maybe in web applications, or database applications, etc.

    Thanks to all those who reply!!
    Currently Using: VS 2005 Professional

  5. #5
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: VB and C#

    Well you can use unsafe code in C# which can speed up certain operations. But in spirit of Mendhak's post it's mostly a matter of preference.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    Are pointers considered unsafe code? I have little experience in pointers from my C++ classes. My thoughts are that the use of pointers in function calls would certainly give performance gains and protect against memory leaks because you are not creating a whole new object.

    Thoughts?
    Currently Using: VS 2005 Professional

  7. #7
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: VB and C#

    yeah in C# you can only use pointers inside an unsafe{} block, also a compiler directive must be set.

    And I doubt it would help with memory leaks.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    So you cannot put a pointer variable in the arguments of the function you are calling? I know you could in C++.
    Currently Using: VS 2005 Professional

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB and C#

    Quote Originally Posted by tacoman667
    I was thinking performance would be better in C# but VB has a better verbose-type statement structuring making it easier to program an application far faster.
    Funny you should mention that, as that's exactly what the difference is supposed to be. VB was designed as a language that the non-technical user can get up and running with very quickly. C# is easier to deal with than C/C++, but retains much of the power of those languages. Generally speaking the difference in execution speed between the two languages in neglible to zero. There are situations, though, where C# can provide significant speed increases. The main reason for this is the ability to use pointers, but some C# code is inherently more efficient than the equivalent VB.NET because of the very syntax you mention. Like so many things, what is a weakness in one situation is a strength in another, and vice-versa. For the average developer the difference between the two languages is purely which syntax you prefer.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    For the power user, the choice would be C#?

    Can C# stand up to the abilities of C++?
    Currently Using: VS 2005 Professional

  11. #11
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB and C#

    Not exactly, but close. C++ will still reign in speed and capabilities. It even supports inline assembly. Not sure if C# supports assembly though.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    What is inline assembly?
    Currently Using: VS 2005 Professional

  13. #13
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: VB and C#

    Personally, i often use both.

    VB as the main app or "front-end" as i feel it is a much much more friendly language, and a DLL in C# for the nitty gritty code.

    As for your IDE being faster comment, you will notice that's because VB will tell you within seconds that what you have done will not compile, where as in C# it will not tell you until you actually go and compile it, thats why c# runs faster in the IDE.. as Jm points out this is one of thsoe things that has a + and -

    Also, do not choose C# purely because you think your code will be faster, and especially do not use unsafe code if you do not need to, because it is exactly that, considered unsafe. You have a large operation you need to boost performance on (i am talking something that you will actually notice a delay on which will bother a user) than yes, thes emeasures are appropriate, if you are talking operations which happen instantianously anyway, there is no need.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    How about DB programming? Would performance be better in that area in C# over VB? I know VB is pretty quick in that but I will have DB's with well over 500000 records at times.
    Currently Using: VS 2005 Professional

  15. #15
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: VB and C#

    that has to do with the Database software you are dealing with, not the language connecting to it, the DBMS is the one running the query, not your application.

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB and C#

    The majority of GUI applications will see no noticeable speed increase with C# over VB.NET because a GUI spends most of its time waiting for the user anyway. When you do something like retrieve large amounts of data from a database, all your code does is call Fill on a DataAdapter. The rest is up to the Framework and the database, so it is not affected at all by your code. Where you may see a speed benefit from using C# is in long, computationally intensive loops, where the slightly more efficient IL produced by the C# compiler in some cases will produce a speed increase that is compounded with each iteration of the loop. The other area is the ability to use unsafe code, as there are many operations that will receive a speed boost by using pointers. The use of pointers obviously makes coding more complex though, so that is the trade-off. If speed is critical then you should be using unmanaged C++. Assembly language is another jump closer to machine language so it will run faster again, so the ability to write assembly code directly into your C++ can give additional speed increases, at the expense of additional complexity again. If you will be performing operations that you know will benefit from the use of pointers then use unsafe C# code, Otherwise, the difference between C# and VB.NET will be pretty much negligible in the majority of cases.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    People keep saying that C# will do things that VB cannot. Can you give me an example of this?
    Currently Using: VS 2005 Professional

  18. #18
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB and C#

    Quote Originally Posted by tacoman667
    People keep saying that C# will do things that VB cannot. Can you give me an example of this?
    Unsafe code is the major difference. C# supports pointers through unsafe code and VB.NET does not. C# also supports operator overloading but VB 2005 has added that now. I'm not aware of any other major differences, although I am not using C# much at the moment so others may be aware more differences, although I think any others would be minor.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  19. #19
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: VB and C#

    An example of somthing which utilises unsafe code and the speed of C# is NoteMe's and WossNames DoomSharp() project which aimed to create a 3d game without any hardware acceleration.

    Pino

  20. #20
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Re: VB and C#

    Quote Originally Posted by tacoman667
    I am now learning C# in class and already know alot on VB. I was wondering, Are there noticable benefits to using C# over VB? I was thinking performance would be better in C# but VB has a better verbose-type statement structuring making it easier to program an application far faster.

    Thoughts?
    why does vb statement structuring make it easy to program far faster? I always thought it was exactly the OPPOSITE as you have to write far less in c# than you have to do in VB
    \m/\m/

  21. #21
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Re: VB and C#

    Quote Originally Posted by tacoman667
    People keep saying that C# will do things that VB cannot. Can you give me an example of this?
    at least in the old VB you could not make operators overloading
    \m/\m/

  22. #22
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: VB and C#

    Isnt overloading a good thing?

    also i suppose that somthings in vb take longer but som things in c# take longer for example there is no With statement in c#

  23. #23
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: VB and C#

    C# code can take much longer to debug and other team members to read, as it is a more cryptic language, VB is mostly words so very fast to read, and the IDE is always checking for errors in VB code.

    why does vb statement structuring make it easy to program far faster? I always thought it was exactly the OPPOSITE as you have to write far less in c# than you have to do in VB
    once again, because it is plain english, and we are IT pros, typing a word instead of a letter is not a big difference, it is thinking and testing time that we spend, not typing.

    As i said before, they are both great tools in their own right, i use both. I think everyone should learn to fluently use both the languages, as they will both prove useful.

  24. #24
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB and C#

    Quote Originally Posted by Phill64
    C# code can take much longer to debug and other team members to read, as it is a more cryptic language, VB is mostly words so very fast to read, and the IDE is always checking for errors in VB code.
    I'm going to have to disagree with that. C# may be more difficult for a VB.NET developer to read, but no more or less so than VB.NET for a C# developer. It all comes down to your familiarity. If you're familiar with a C-based language already then C# is no more difficult to read than anything else. Any language, whether we're talking about programming languages or written languages like English, etc. are all just a series of symbols and indentifiers. Once you're familiar with those symbols and identifiers the rest is easy. VB was and is supposed to be easier for the less technically minded. It succeeds in that in part because of its more Engish-sentence-like syntax. Once you're experienced though that isn't really an advantage or disadvantage anymore.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB and C#

    If that were the case, jmcilhinney, then why do'nt they just have 1-2 high-level languages instead of 4+? Say, C++ and VB?
    Currently Using: VS 2005 Professional

  26. #26
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB and C#

    Quote Originally Posted by tacoman667
    If that were the case, jmcilhinney, then why do'nt they just have 1-2 high-level languages instead of 4+? Say, C++ and VB?
    All languages have their pros and cons. Each was created to fill a certain need. That doesn't mean that any one is specifically harder to read because of a cryptic syntax. If you know a language then you know it. It would take me a while to read Japanese but it would take just as long for many Japanese people to read English. It all comes down to familiarity. I have used VB.NET much more than C# but I have no more trouble reading C# code than VB.NET because of a C/C++ background. VB.NET is almost certainly easier for the beginner programmer to learn, but the statement I took issue with was:
    Quote Originally Posted by Phill64
    C# code can take much longer to debug and other team members to read, as it is a more cryptic language
    as that will depend on who's doing the debugging and reading. A C++ developer with no VB.NET experience would take longer to read and debug VB.NET code than C#. Many people prefer the C-style syntax and specifically dislike the VB syntax.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  27. #27
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: VB and C#

    i can accept that. It is true i have only used C-syntax languages for Uni and hobby, all my commercial products (until i got into c#) have been VB, so i have used the VB syntax much more actively.

  28. #28
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: VB and C#

    I prefer C# because it is standardized.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  29. #29
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: VB and C#

    Quote Originally Posted by dee-u
    I prefer C# because it is standardized.
    and VB isn't? well, classic VB definetly isnt, but VB.NET uses all the same objects as C#, and structures the same way, and the vb namespace is entirely optional.

    unless you are refering to the operators

  30. #30
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: VB and C#

    Quote Originally Posted by Phill64
    and VB isn't? well, classic VB definetly isnt, but VB.NET uses all the same objects as C#, and structures the same way, and the vb namespace is entirely optional.

    unless you are refering to the operators
    You can have a look at the first link given by Rob in post #2, it was one of the mitigating factors why I chose to learn C# more than VB.Net...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width