Homebrew C++ vs C#

Flame

Me > You
Global Moderator
Joined
Jul 15, 2008
Messages
7,269
Trophies
3
XP
18,700
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 :
smile.gif

* 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


http://www.thinkingparallel.com/2007/03/06...-point-of-view/


google
yay.gif


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.
 

sadak5

Well-Known Member
Member
Joined
Feb 27, 2007
Messages
421
Trophies
0
Age
40
Location
Mexico City
Website
Visit site
XP
169
Country
Mexico
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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    ButterScott101 @ ButterScott101: +1