Advertisement

C# vs C++

Started by December 14, 2002 12:47 PM
27 comments, last by Fuzztrek 21 years, 11 months ago
C# is a great language, it offers a lot of improvements over its father C++ and its cousin Java.
C# is safer than C++ (and maybe even safer than java) by using its "managed code", its own garbage collector, and its intermediate language.
C# is faster than java, because it runs as native code, it is a little slower than C++ due to the just in time compilation (passing from Intermediate language to native code) and its garbage collector.
C# is as flexible as C++ because you can still use pointers if you feel that you need them under "unmanaged code", it also has
a better implementation for function pointers, the delegates.
C# has a great support for componentes and for multithreading.
C# is as easy to learn as Java.
C# is an awesome Object Oriented an Component based language.
However, right now it is not the best choice for game developming, because it is a Microsoft dependent technology (that is not that bad, the main platform for pc gaming is Windows), but it has not direct support for DirectX (However C# DOES have support for it). C# support DirectX via COM interoperability using type libraries (the ones that VB uses to support DirectX). This indirection of course adds some overhead,and when we are developing games we care a lot about speed.
DirectX 9 will have support for managed code, thats what Microsoft promised, so until then, for game programming it''s better to stick with C++. (By the time DirectX 9 is released maybe C# will be the option).
Some final words
C# is NOT an scripting language like PHP or java script, is a complete OOP language just as it is C++ and Java. It works like the business logic behind ASP.NET (as vbscript did it for ASP)but that does not mean that it is its only function
C# can build applications for non-internet environments
C# does support DirectX (not directly at the moment but it supports it)


All that is gold does not giltter,
Not all those who wander are lost;
The old that is strong does not wither,
Deep roots are not reached by the frost.
From the ashes a fire shall be woken,
A light from the shadows shall spring;
Renewed shall be blade that was broken,
The crownless again shall be king.
All that is gold does not giltter,Not all those who wander are lost;The old that is strong does not wither,Deep roots are not reached by the frost.From the ashes a fire shall be woken,A light from the shadows shall spring;Renewed shall be blade that was broken,The crownless again shall be king.
quote: Original post by Drakex
from what i understand

The next time you find you want to start a post with that phrase, don''t bother posting at all.


For those who believe in God, most of the big questions are answered. But for those of us who can''t readily accept the God formula, the big answers don''t remain stone- written. We adjust to new conditions and discoveries. We are pliable. Love need not be a command or faith a dictum. I am my own God. We are here to unlearn the teachings of the church, state, and our educational system. We are here to drink beer. We are here to kill war. We are here to laugh at the odds and live our lives so well that Death will tremble to take us -- Charles Bukowski
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Advertisement
Just a quick question: Will it be possible to use DX9 with a free compiler such as Borland C++ 5.5.1, or do you have to use a .Net language such as C# or VB.Net? Just wondering.

Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
if you wonna have fun with pointer and like to control it yourself choose c++
If you wonna feel comfortable to find source-code to study choose c++
if you wonna have fun with memory leak and some mysterious BUGs choose c++
if you wonna violate your OS choose c++
On the other hand,
If you like JAVA but also love BILL GATES,YES C#
If you like actual concept of Object Oriented Programming,c#
If you don''t wonna waste your time to restart your computer because of out-of-memory and blue-screen, choose c#.
If you wonna try something different,C#
My english is very poor.Please correct me if There are any mistakes in my post
quote: Original post by Tron3k
Just a quick question: Will it be possible to use DX9 with a free compiler such as Borland C++ 5.5.1, or do you have to use a .Net language such as C# or VB.Net? Just wondering.

I don''t think there is a reason to think DX9 will be any different from DXs 1, 3, 5, 6, 7 and 8 in that respect. IE, it will be available to any C++ compiler as long as someone can be bothered to create import libraries in the correct format.

As for free - the .NET Framework SDK is a free download from Microsoft which contains the commandline C#, VB.NET, JScript.NET and MC++ compilers. No IDE, but there is a graphical(as well as a commandline) debugger.


For those who believe in God, most of the big questions are answered. But for those of us who can''t readily accept the God formula, the big answers don''t remain stone- written. We adjust to new conditions and discoveries. We are pliable. Love need not be a command or faith a dictum. I am my own God. We are here to unlearn the teachings of the church, state, and our educational system. We are here to drink beer. We are here to kill war. We are here to laugh at the odds and live our lives so well that Death will tremble to take us -- Charles Bukowski
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Hmm. I''m still confused, if not more. To me, it seems as though C#''s only pitfall(s) is that it needs a runtime (which isn''t that bad, I''m sure Microsoft will force it on us anyway) and that it is "slower" than C++. Perhaps someone could elaborate on how much slower it is? I can''t see it being that much slower (at least noticably slower.)

¬_¬
Advertisement
I haven''t used C# for long - just a few months - but I am happy with it. I am not using it for programming games but for windows development the .NET Framework makes some things a lot simpler. C# currently allows Visual development via WinForms drag and drop - but so will C++ when Everett (Visual Studio .NET 2003) is released. C# garbage collects - but so does managed C++.

Basically managed C++ (C++ for .NET that runs through the Intermediate Language (IL)) vs C# comes down to language preference, C++ had to have some new constructs added to allow it to be .NET - if you have a large collection of "normal" unmanaged C++ you might be able to port it easier. If you want the language to have been built from scratch for .NET and feel a little less "clunky" then go with C#.

Unmanaged C++ is more portable (although you probably won''t port many games as other API constraints may exist - I am aware of OpenGL etc - maybe you will be porting ) It can be faster because it doesn''t go through the IL (although it may be that Microsoft optimised some IL functions to be faster than you could write ?). It has been around for a while - you can use many different compilers, theres a lot of source code and help and you can use some advanced functionality not yet available for C#.

All languages have their pros and cons but C# vs managed C++ vs unmanaged C++ is almost like comparing three shades of red - their pretty similar and it comes down to personal preference.

I use C++ at work because I code under Unix and NT and it has to be portable. I''m using C# at home so I can be familar with it and choose the right language later. So far .NET functions are much easier than MFC or Win32 (although you can''t always access things for example double buffering is not easy with "managed" code).

Maybe I''ll use managed C++ at some point but personally I''ll probably use C# for pure windows programming and C++ for portable coding.

Hope this helps,

MJDALWAYS
I wanted to point out that Java isn''t a scriptting language because its a compiled language (someone said it was script). &#106avascript on the other hand is a scripting language designed to do many things including making java more capable.
quote: Original post by mjdalways
So far .NET functions are much easier than MFC or Win32 (although you can''t always access things for example double buffering is not easy with "managed" code).

Windows Forms has built-in support for double-buffering. Try the following in the ctor of your form:

  this.SetStyle( ControlStyles.DoubleBuffer, true );this.SetStyle( ControlStyles.AllPaintingInWmpPaint, true );this.SetStyle( ControlStyles.UserPaint, true );  


Doing double buffering manually isn''t all that hard, either.


For those who believe in God, most of the big questions are answered. But for those of us who can''t readily accept the God formula, the big answers don''t remain stone- written. We adjust to new conditions and discoveries. We are pliable. Love need not be a command or faith a dictum. I am my own God. We are here to unlearn the teachings of the church, state, and our educational system. We are here to drink beer. We are here to kill war. We are here to laugh at the odds and live our lives so well that Death will tremble to take us -- Charles Bukowski
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
leaks and bugs are indeed a lot of fun!

C++ is for smart people, C# is for n00bs.

.lick

This topic is closed to new replies.

Advertisement