What's so special about c#?

This is a discussion on What's so special about c#? within the C# Programming forums, part of the General Programming Boards category; As a beginner to C++, I would just like to ask what makes c# better than C++, and if I ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    38

    Question What's so special about c#?

    As a beginner to C++, I would just like to ask what makes c# better than C++, and if I should wait to learn C++ before jumping right into C#.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,306
    If you actually mean "in what way is C# better than C++", then just search the Web for phrases like "C# versus C++". I easily found C++ vs. C# - a Checklist from a C++ Programmers Point of View.

    Quote Originally Posted by ashinms
    if I should wait to learn C++ before jumping right into C#.
    If you want to learn C#, then learn C#. You can always come back to learn the other one some day.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,590
    Quote Originally Posted by laserlight View Post
    If you want to learn C#, then learn C#. You can always come back to learn the other one some day.
    Knowing C++ already, I found it very easy to learn C#. I have friends who learned C# first, and later learned C++, and most of them said it was hard to get used to the differences in C++.

  4. #4
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    478
    Quote Originally Posted by Elkvis View Post
    Knowing C++ already, I found it very easy to learn C#. I have friends who learned C# first, and later learned C++, and most of them said it was hard to get used to the differences in C++.
    It would not surprise me if this is a common issue for people going C#->C++, instead of the other way around.

    Even in spite of C++ being(Or at least having the possibility to be) somewhat higher level than C, there are still things such as pointers, arrays and so on, which deal with things on a much lower level than you can in C#. This means that were you you start C++ with no idea of programming beforehand, you would be forced to learn the low level ways, and therefore, going a level higher will be cake.

    Going the other way around; e.g. programming without ever having to deal with these things, then going to another language that's a level lower, where you do have to deal with them, will be much harder.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by IceDane View Post
    It would not surprise me if this is a common issue for people going C#->C++, instead of the other way around.
    And not unique for C#->C++, but also applies to moving from any other language that "does memory management for you", such as Java, Python, Perl or Basic and many others.

    C++ (and C) have very basic handling of memory - it requires programmer effort to maintain pointers to valid memory, and to ensure there are no memory leaks or other problems. (This is in the standard language - obviously, with sufficient code added on top of the standard language, we can CREATE the environment for "automatic memory management", e.g. Python and C# are written in C or C++, so obviously the memory management done by those languages can be written in C or C++).

    Almost all other basic principles of C++ are identical between C#, Java, Python - there are some subtle differneces, but for most programmers, those are a simple case of "learning how to do it in this language".

    The principles of managing your own memory is a bigger task to learn.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    2,590
    the feedback I've heard is that it's not just memory management. knowing where to use -> and :: when you've been using the dot for everything can be confusing for some, and the fact that C++ doesn't keep track of how big an array is when you dynamically create it was frustrating for one of my friends a while back.

  7. #7
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    478
    Quote Originally Posted by Elkvis View Post
    the feedback I've heard is that it's not just memory management. knowing where to use -> and :: when you've been using the dot for everything can be confusing for some, and the fact that C++ doesn't keep track of how big an array is when you dynamically create it was frustrating for one of my friends a while back.
    It can be frustrating, yes, but it will in turn make you a better programmer to know how these things work. Deep down under C# and other similarly managed languages, unmanaged memory management is doing the work. Pointers are almost nonexistent in C#, but understanding them is pretty important in my opinion.
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,031
    Quote Originally Posted by Elkvis View Post
    ...and the fact that C++ doesn't keep track of how big an array is when you dynamically create it was frustrating for one of my friends a while back.
    It does, if you use std::vector or std::tr1::array.
    However, by default, it will not do bounds checking.
    For dynamic arrays with vector, however, using the .at member function will guarantee that no out-of-bounds can be made.
    boost::array also raises an assert if an out-of-bounds access is made.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    How about the fact that in theory, your code you write in C# should be language independent to other .net languages. IE a class you write in C# can be inherited from and expanded by a VB.net developer, and you can then take that class and use it in your app.

  10. #10
    Registered User
    Join Date
    Dec 2008
    Posts
    38
    Yes. You helped.

  11. #11
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Quote Originally Posted by valaris View Post
    How about the fact that in theory, your code you write in C# should be language independent to other .net languages. IE a class you write in C# can be inherited from and expanded by a VB.net developer, and you can then take that class and use it in your app.
    They're taking it a step further with C# 4.0, allowing you (with proper binding libraries of course) to call functions and instantiate objects dynamically across any language (javascript, python, ruby, etc).

    That stuff is more advanced and may find little use but it's an interesting addition.

    Personally I haven't done much stuff in C++ lately, would like to get back into it though. I prefer C# because of the frameworks it offers for web development (ASP.NET MVC) and desktop/web applications (WPF, silverlight).
    Here to Deceive, Inveigle, Obfuscate Since 1945

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    C# might have a lot of connectivity features, but the truth is it's really just a big ole kludge. Besides that, any language lacking deterministic destructors just seems inherently flawed to me. I'd say stick with C++ unless you have no other choice.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  13. #13
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Quote Originally Posted by Sebastiani View Post
    C# might have a lot of connectivity features, but the truth is it's really just a big ole kludge. Besides that, any language lacking deterministic destructors just seems inherently flawed to me. I'd say stick with C++ unless you have no other choice.
    You can still have the deterministic deallocation of resources via Dispose(). Plus, it helps improve performance -- if a large number of objects go out of scope at once, they don't need to all be destroyed immediately while your thread sits on its ass waiting. Rather, they can be garbage collected whenever there's time available to do so.
    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.

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,306
    Quote Originally Posted by Cat
    You can still have the deterministic deallocation of resources via Dispose().
    hmm... I was surprised to hear that C# has deterministic destruction, but a quick check shows that Dispose() is not automatically called when the object goes out of scope, so that does not adequately address Sebastiani's point.

    Quote Originally Posted by Cat
    Plus, it helps improve performance -- if a large number of objects go out of scope at once, they don't need to all be destroyed immediately while your thread sits on its ass waiting.
    A recent garbage collection discussion on the Boost mailing list gives me the impression that a well designed allocator would provide that benefit as well, though in this case it would be about delaying the freeing of memory since the objects would nonetheless be destroyed.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Finalize() is called when an object is being deleted. It is in effect a destructor for C#, usually it's only used to free managed resources. Its syntax is also similar to C# as in ~ClassName();.

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

Similar Threads

  1. Printing a special type?
    By blernblan in forum C Programming
    Replies: 1
    Last Post: 06-02-2009, 04:35 PM
  2. locking actions to special threads
    By pheres in forum C++ Programming
    Replies: 2
    Last Post: 09-24-2008, 11:17 AM
  3. special characters removing from srting
    By cnu_sree in forum C Programming
    Replies: 5
    Last Post: 06-06-2007, 09:30 PM
  4. special function detection
    By zyd in forum C Programming
    Replies: 7
    Last Post: 02-28-2006, 03:25 PM
  5. Special (non) Keyboard Characters
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2002, 01:08 AM

Tags for this Thread


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