C++ vs C#

Discussion in 'NDS - Emulation and Homebrew' started by Malamear, Aug 28, 2009.

  1. Malamear

    Malamear Newbie

    Nov 27, 2008
    United States
    What's the difference?
  2. Malamear

    Malamear Newbie

    Nov 27, 2008
    United States
    Also the Pros and Cons?
  3. Flame

    Flame Me > You

    GBAtemp Patron
    Flame is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Jul 15, 2008
    Pro C#:

    * garbage collection
    * array bounds checking
    * huge .NET-Framework library
    * types have a defined size (e.g. a long is 64Bit)
    * strings are encoded in UTF/16
    * autoboxing - every type can be treated as if it inherits from object
    * supports constructor-chaining (one constructor can call another constructor from the same class)
    * when a virtual method is called in a constructor, the method in the most derived class is used
    * static constructors (run before the first instance of the class is created)
    * exceptions have access to a stack trace
    * advanced runtime type information and reflection
    * supports variadic functions nicely
    * built-in support for threads
    * no need for header files and #includes
    * no fall-through on switch-statements
    * arithmetic operations can be checked for overflow if required
    * objects must have a definite value before being used
    * attributes can be attached to classes and retrieved at runtime
    * no forward declarations required, classes can be arranged at will
    * access to class members / functions is done only by the dot (no more -> or :[​IMG]
    * conditional functions (e.g. for debugging)
    * structs and classes are actually different (structs are value types, have no default constructor in general cannot be derived from)
    * supports properties
    * readonly members are const, but can be changed in the constructor
    * finally block for exceptions
    * arrays are objects
    * support for anonymous functions
    * supports the base keyword for calling the overridden base class

    Pro C++

    * better performance
    * portability
    * multiple inheritance
    * deterministic destruction (allows RAII)
    * any type can be thrown as exception (only classes derived from System.Exception in C#)
    * ability to enforce const-correctness
    * implicit interfaces on generics (in C#, generics must be constrained with an interface)
    * offers pointers (C# only offers pointers in unsafe mode)
    * support for macros
    * support for global variables, functions, constants
    * allows default arguments on function parameters
    * STL
    * supports bitfields

    Where C# is just different from C++

    * value types and reference types exist (struct is value-type, class is reference-type)
    * value types live on the stack, reference types on the heap
    * references can point to null (must not be valid)
    * code is packaged in assemblies in C#
    * no automatic conversion from int to bool in C#
    * main-function is called Main in C#
    * no semicolon after a class declaration in C#
    * everything derives from object or can be treated as if


    google [​IMG]

    one big con of C# is that it needs .net framework, windows only. i think they is some apps on the linux which can make c# run on linux.

    But C# wouldnt work on DS.
  4. sadak5

    sadak5 GBAtemp Fan

    Feb 27, 2007
    Mexico City
    there is a port of the .NET Framework for Linux called MONO. Also, the latests features like Silverlight (programable in all .NET languages) have runtime for mac, windows y linux.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice