Why use C#?

This is a discussion on Why use C#? within the C# Programming forums, part of the General Programming Boards category; I've been learning some C# (I'm a C++ programmer) and I have yet to see any reason for me to ...

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Why use C#?

    I've been learning some C# (I'm a C++ programmer) and I have yet to see any reason for me to use it instead of C++. Could anyone give some examples of where C# could be better/easier/more useful?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Native code? Lots of people don't/can't have the .NET framework installed.

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Doesn't C++ compile to native code?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Sorry. I misread your post. I thought you were asking why one should use C++ instead of C#.

    In that case, ignore my previous post.

    Use C# only if you have to.

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Use C# only if you have to.
    Back to square one. Why would I have to?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    1. Your employer wants you to.

    2. You want to use managed code. You can do it via C++ too, but I find C# much easier to work with the .NET framework.

    3. Preparing for Longhorn.

  7. #7
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    If you don't need the speed or fine control of C++, then there is really no reason wasting time on all of C++ drawbacks when you can use a RAD language. C# is one of them and really nice.
    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.

  8. #8
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Nvoigt pretty much summed it up. It's pretty well known the .NET framework can shorten development time by months. C# has/is also been standardised, and is avaliable on Linux. My understanding is C# code created for windows, so long as it doesn't contain any native stuff, should run on linux without being recompiled (http://www.go-mono.com for more information).

    It's also just so much more simple to use because the .NET framework has almost everything you could ever need. Make a library? All you need to give people is the DLL - no headers or any of that rubbish. The DLL's contain meta-data, which handle all the functions of the .LIB and header files in one (plus a lot more stuff). Lets see you do database access with Access and SQL server at the same time - I've never even seen this done in C++, but my guess is its probably a lot faster in C#/.NET.

    It can also be used for ASP.NET web pages, and is much more structured and easier to read (IMO) than Perl/PHP. Theres also Web Services, which allow you to store all your business logic on a server for you clients to access - sorta like calling a DLL remotely.

    Finally - NO POINTERS, nearly everything you need pointers for can be done using the object class.

  9. #9
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    >Finally - NO POINTERS, nearly everything you need pointers for can be done using the object class.

    1. C# does have pointers if you need them.
    2. You must be one of those Java lovers, aren't you? Pointers in my opinion are essential in understanding how things work in the background. About 50% of the Java programmers I know don't have a clue how things work back there or what a pointer is. Tsk tsk. Look at the woes of Java.
    3. The object class is not the reason why things can be done without pointers. The reason things can be done without pointers is because in actuality, EVERYTHING is a pointer in C#, they just dont look like it. It is the same way in Java. EVERYTHING is a pointer. So in actuallity everything is being done with pointers, you just dont see it. It has nothing to do with the object class. The object class serves a different purpose: inheritance, generality, and portability

    But anyways, C# is a very nice language. In fact, I started writing tutorials on my webpage just this past week, and I opted to use C# instead of C++ (that is a big step for me since C++ is my primary language) because of its versatility. I decided I would rather use IComparable objects in my examples rather than writing out templated classes like I would be doing in C++. Either way is perfectly okay, but I decided to go the way of less typing.
    My Website

    "Circular logic is good because it is."

  10. #10
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    But can anyone run a program made in C#? Don't they need the .NET framework?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  11. #11
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Everyone will need the .NET Framework ( free download from MS and included with Longhorn ) or the Linux equivalent to run .NET applications the same way everyone need a VM for Java applications.
    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.

  12. #12
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Is it possible to package the framework with a C# application?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  13. #13
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Legally ? No problem, you can redistribute the Framework.

    Programmatically ? Yes, but you have to do it yourself. Back in beta MS provided a merge module that could be included in the installer and would install the Framework automatically, but this didn't make it into release for unknown reasons. So if you write an installer package, check for the framework and install it if it's not on the target machine, it should work.
    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.

  14. #14
    not-a-geek
    Join Date
    Apr 2004
    Posts
    210
    Quote Originally Posted by DavidP
    You must be one of those Java lovers, aren't you? Pointers in my opinion are essential in understanding how things work in the background. About 50% of the Java programmers I know don't have a clue how things work back there or what a pointer is. Tsk tsk. Look at the woes of Java.
    Actually, I love the way things can be done without pointers, too. Of course it would be best if everyone understood pointers, but than again it would also be better if everyone understood Einsteins theory of relativity just because Newtons analysis of gravity isn't 100% accurate (hint: this refers to your pointer vs. object argument).

    Quote Originally Posted by DavidP
    The object class is not the reason why things can be done without pointers. The reason things can be done without pointers is because in actuality, EVERYTHING is a pointer in C#, they just dont look like it. It is the same way in Java. EVERYTHING is a pointer. So in actuallity everything is being done with pointers, you just dont see it. It has nothing to do with the object class. The object class serves a different purpose: inheritance, generality, and portability
    There are differences between a pointer and a reference to an object. For one, pointers can point to an invalid location in memory. References can't because you cannot change their target. You cannot call everything that stores a memory address a pointer. At the very least, you need to compare with autopointers because in C# objects are not guaranteed to stay in one place.

  15. #15
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    I also remember reading something about a linker for .NET so that (AFAIK) your clients wont need the .NET runtime. All the runtime code you use is compiled into the executable, and what you dont use is ignored. IIRC though, it was only for VB.NET. I'll try and find it...

    Edit: http://www.remotesoft.com/linker/
    Seems to work for managed C++, C# and VB.NET.
    Salamander .NET Linker and mini-deployment tool allows you to link .NET assemblies together into a single file, and to deploy your application without installation of the whole Microsoft .NET Framework
    Last edited by nickname_changed; 06-02-2004 at 04:22 AM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

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