Why do you prefer C#?

This is a discussion on Why do you prefer C#? within the C# Programming forums, part of the General Programming Boards category; I have been going over some C# documentation all day as well as MS code examples and it looks very ...

  1. #1
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100

    Why do you prefer C#?

    I have been going over some C# documentation all day as well as MS code examples and it looks very interesting.

    Why do you guys prefer to use C#? What are it's advantages and most importantly, it's disadvantages? It seems like it is worth giving a try.

  2. #2
    Devil™
    Join Date
    Oct 2007
    Location
    IIT-Kharagpur, India
    Posts
    104
    I prefer sometimes.. as that is the only programming language that MS gave for getting things done well without much effort & also multiplatform (to some extent) like java..
    VB was there.. but I dont like it, I am afraid that I will become a scrip coder throughout my life
    Most important reason.. is my friends only know C# and not C/C++..
    they find C/C++ coding as stupidity.. doing a lot of things for one simple code..
    C's Motto: who cares what it means? I just compile it!!

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    C# is good for getting GUI apps up and running fast and yet still use an object oriented language...unlike VB. C++ was not built for Windows GUI and MFC while very handy is also very picky about how you design your apps. It takes quite a bit of MFC 'under-the-hood' knowledge to really get creative and break out of the mold. C# does not require this and thus development time is significantly shortened.

    However I don't like C# because interop is a pain (with unmanaged code) and the fact that there are no pointers essentially makes everything a pointer underneath it all. .NET is sorta crazy with all the System.Windows.Forms.yada.yada.yada stuff but it gets the job done.

    I do like the ArrayLists and other containers that can contain any object. This is a great idea but can also be done in C++ - with a bit more code.

    Main reason for using C# - development time.

  4. #4
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Quote Originally Posted by Bubba View Post
    However I don't like C# because interop is a pain (with unmanaged code)
    That is interop?


    So is C# as powerful as C or C++? I've read that you CAN use pointers with C#.

  5. #5
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Quote Originally Posted by gibsosmat View Post
    VB was there.. but I dont like it, I am afraid that I will become a scrip coder throughout my life

    What do you mean a scrip coder for life?

    Also, how portable is a C# program?

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,435
    You can use pointers, but they're "unsafe" and has restrictions in the langauge last I remember.
    Good luck getting anything built on .NET to run on anything but Windows. At least so far.

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The core of the C# language is standardized, and there are two alternative implementations available. (By the Mono project and by Gnu). However, only a tiny part of the .Net framework has the same honour, so these two projects spend a lot of time trying to get a compatible implementation from just reading documentation and making test cases. The result is that the .Net framework is only partially implemented, making most C# programs unportable.

    Practically, the design of System.Windows.Forms is so tightly coupled to the Win32 windowing model that Mono has given up on trying to implement it on top of typical Unix toolkits, and now base it on Wine.

    Is C# as powerful as C or C++? That depends on how you define power. In computer theory, all three languages are Turing-complete, and thus can solve any known numeric problem, if given infinite resources. In reality, there are some things you can do in C - like writing device drivers - that the implementation model of C# makes impossible (no .Net runtime in the kernel) and that of C++ makes hard (no exception handling and dynamic initialization in the kernel). On the other hand, C# generally allows you to do more with fewer lines. That is a sort of power, too.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    Devil™
    Join Date
    Oct 2007
    Location
    IIT-Kharagpur, India
    Posts
    104
    Quote Originally Posted by Welder View Post
    What do you mean a scrip coder for life?
    that was a typo.. it should be script coder
    If one gets used to scripting language they get those language habits..
    both in coding style & realization methodology..

    Quote Originally Posted by Welder View Post
    Also, how portable is a C# program?
    with windows having .NET they will work fine.. since it has runtime it will depend on the runtime.. I dont know how portable is .NET runtime, on different systems. I never tried.

    Quote Originally Posted by Welder View Post
    So is C# as powerful as C or C++? I've read that you CAN use pointers with C#.
    computer science power is different, it has a proper definition..
    putting it simple
    'if one thing can be done in a language and the same could be done in another language they are said to be equally powerful'
    development time & running time are not a constraint here.. but if it can be done at all or not is the only thing considered..

    yes, you can use pointers.. but the compiler keeps yelling,
    as that will force runtime not to assume things for granted for optimization and garbage collection

    Quote Originally Posted by Bubba View Post
    Main reason for using C# - development time.
    I feel like its the only reason to choose C#.. rest all are available in C++ .NET


    Quote Originally Posted by CornedBee View Post
    Practically, the design of System.Windows.Forms is so tightly coupled to the Win32 windowing model that Mono has given up on trying to implement it on top of typical Unix toolkits, and now base it on Wine.
    so what now? will MS help project wine?
    C's Motto: who cares what it means? I just compile it!!

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Unlikely. As far as I know, MS only supports the Moonlight effort, and Forms is not part of Silverlight.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    Devil™
    Join Date
    Oct 2007
    Location
    IIT-Kharagpur, India
    Posts
    104
    Quote Originally Posted by CornedBee View Post
    Forms is not part of Silverlight.
    I didnt understand..
    C's Motto: who cares what it means? I just compile it!!

  11. #11
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    You can use pointers in C# but they are used in 'unsafe' sections of C# code. Also I'm not sure you can use an unmanaged type inside of a managed block of code. As well there is the issue that C# objects move around in memory at run-time so to use unsafe objects you pretty much have to use gcroot<> which tells the C# memory manager to lock the location and don't move it AFAIK. If C# went ahead and moved your unsafe pointer or object the next time you try to use it or access it you would have a very bad experience.

    That is interop?
    Interop is using modules/objects from dissimilar languages and/or .NET or non .NET modules/classes.

    For instance you cannot just export a C++ class into a DLL and then import that DLL into C#. There isn't a :: scope resolution operator in C# so if you have 2 or more classes with the same function names but inside of different objects there is no way for the compiler to do function resolution. Also C++ class functions are called with this call and C# does not understand this call. I did see a blurb on the internet about specifying this call instead of std_call when you import the DLL but I never tried it so I don't know if it works.

    The biggest issue comes when you attempt to interop unmanaged code with managed code and since C# is managed, mixing it with non .NET C++ can be quite troublesome. I would venture to say that C# is most likely not very portable at this time but may be so in the future.
    As with all languages other companies have gotten into the mix and now offer C# compilers. I'm not sure about the legality of all of that but it's good for cross-platform folks.

    I just started learning C# last week so I'm fairly new to the scene but since my first project at work is C#...I pretty much have to crash course learn it.

  12. #12
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Quote Originally Posted by gibsosmat View Post
    I feel like its the only reason to choose C#.. rest all are available in C++ .NET
    Development time, but also clarity of code. C# code tends to be more compact than its equivalent C++ code, and one feature of this clarity is that maintenance of the code becomes easier. A program spends the vast majority of its life in the maintenance phase, not the development phase, so gains here matter most.

    Oh, and on the original topic, what I dislike most about C# -- lack of const member functions and const-correct coding. Granted I think about 1% of all the C++ code I've ever seen actually uses const correctness, but it's a powerful tool and one I feel C# lacks.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,435
    More compact? More bloated if you count the .NET runtime.
    Cannot agree on maintence - that's something that depends on how well written the code is an the experience of the developer. It really has no effect on what language you use.

  14. #14
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    The code is more compact. Not the compiled executable, just the code.

    It's way easier to maintain for inexperienced programmers.
    It's easier to learn.
    It has garbage collection.

    GUI creation C# vs C++ isn't even comparable. I love C++, but anything that will go to a customer for daily use is better built in C#. Because there is no way to tell a customer that his wishes, how crazy they may be, cannot be fulfilled. C# is "can do", C++ is "can do for an enormous amount of money to finance our enormous amount of development time" when it comes to GUI creation. And by GUI creation I don't mean two buttons and a textbox.

    I miss const-correctness though.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  15. #15
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,435
    Quote Originally Posted by nvoigt View Post
    The code is more compact. Not the compiled executable, just the code.
    Uhuh, but so what does this do, exactly? A little less code, yet bigger executables?

    It's way easier to maintain for inexperienced programmers.
    It's easier to learn.
    It has garbage collection.
    Yes! For inexperienced devs, but not for experienced ones!
    I can maintain a C++ program just as well as a C#. We can divide them into categories - for inexperienced and experienced.

    GUI creation C# vs C++ isn't even comparable. I love C++, but anything that will go to a customer for daily use is better built in C#. Because there is no way to tell a customer that his wishes, how crazy they may be, cannot be fulfilled. C# is "can do", C++ is "can do for an enormous amount of money to finance our enormous amount of development time" when it comes to GUI creation. And by GUI creation I don't mean two buttons and a textbox.

    I miss const-correctness though.
    It certainly is harder to do GUI in C++, but with all those libraries out there, it's DO-able. One just needs to know how.

    C# is easier to use, but I cannot agree that it's easier to maintain. Plus it creates bigger executables and it's easier to reverse engineer.
    But there's also the speed question. If something takes 5s to do, just like clicking a button, then I'd find that program very bloated and unfun to use. And this might just be the example of C# and .NET. It takes such a big performance hit to use it. Heck, I believe even VB apps start and execute faster (well, they are native, after all).
    It would be nice for a mix of C++ and C#, with C++'s power and C#'s easy GUI, but I guess we can't have all...
    Last edited by Elysia; 12-03-2007 at 03:59 AM.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. which way you prefer
    By l2u in forum C++ Programming
    Replies: 4
    Last Post: 06-07-2007, 11:39 AM
  2. What Font Size do you prefer?
    By SourceCode in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 03-23-2003, 03:58 AM
  3. Which one will you prefer: cout or printf
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 35
    Last Post: 02-06-2002, 09:42 PM
  4. what do you prefer
    By whistlenm1 in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-28-2002, 08:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21