PC Review


Reply
Thread Tools Rate Thread

From C++ to C# and back again....

 
 
Aaron
Guest
Posts: n/a
 
      15th Feb 2005
I taught myself C++ a while back, but never got to
involved in actually writing applications with it. I
actually spent the last 6 years working for numerous
internet web firms as well as doing a plethora of
freelance web development work. Lately I started learning
c#. The idea is to stop using coldfusion and switch to
writing c# using asp.net. The advantage I believe is that
I can develop websites and software that reuse code and
are tied together in a Solution. This idea is very
exciting to me.

One of my other passions and interests is game
development. I've looked around at a lot of different
websites and have read over and over again that although
game development with c# is possible; it's just not
pratical, due to peformance issues brought on by
using .net, etc.

It is my understanding, however, that as a .net
application runs the called functions are compiled to
native code through the JIT compiler. Only functions that
are called are compiled, but once compiled, are not
recompiled through the life of the program. In addition to
this, the compiled code is more effecient since it is
compiled specifically for the system and processor it is
running on. And typically speaking, as a .net program
runs; it gets faster and faster (obviously hitting a
plateau when all code is compiled).

If this is the case, wouldn't a game programmed
using .net, have better performance? Isn't it possible to
still use pieces of assembly code or otherwise unsafe code
for specific functions where performance is key?

I was looking at the Mangaged C++ port of the Quake II
engine the other day and was reading that "Running Quake
II.NET in the timedemo test indicates the managed version
performs about 85% as fast as the native version."
(http://www.vertigosoftware.com/Quake2.htm). The didn't do
much explaination as to why the managed version was
slower.

C# itself doesn't seem like it was meant for game
programming. Am I right? What advantages does the C++
language have over C# that makes it better for game
programming (as far as syntax goes, not performance)?

Thank you.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      15th Feb 2005
Aaron,
You can use C# to develop games. It may be slightly slower than C++ (if
designed and implemented properly) be you will be much more productive.

Games developers are slow to move to C#. They already employ die hard C++
coders and there is a lot of snobbery regarding C#. Also C/C++ is used for
developing games for the consoles.

To start, try the following links.

Download the DirectX SDK
http://msdn.microsoft.com/library/de...st/directx.asp

Managed DirectX discussio
http://msdn.microsoft.com/newsgroups...&lang=en&cr=US

Managed DirectX eposide of the .NET Show
http://msdn.microsoft.com/theshow/Ep...37/default.asp

DirectX on MSD
http://msdn.microsoft.com/library/de...ch_directx.asp

Books on Managed Direct
http://www.amazon.com/exec/obidos/AS...9919604-591356
http://www.amazon.com/exec/obidos/AS...919604-5913560

Good luck.
Phil.

"Aaron" wrote:

> I taught myself C++ a while back, but never got to
> involved in actually writing applications with it. I
> actually spent the last 6 years working for numerous
> internet web firms as well as doing a plethora of
> freelance web development work. Lately I started learning
> c#. The idea is to stop using coldfusion and switch to
> writing c# using asp.net. The advantage I believe is that
> I can develop websites and software that reuse code and
> are tied together in a Solution. This idea is very
> exciting to me.
>
> One of my other passions and interests is game
> development. I've looked around at a lot of different
> websites and have read over and over again that although
> game development with c# is possible; it's just not
> pratical, due to peformance issues brought on by
> using .net, etc.
>
> It is my understanding, however, that as a .net
> application runs the called functions are compiled to
> native code through the JIT compiler. Only functions that
> are called are compiled, but once compiled, are not
> recompiled through the life of the program. In addition to
> this, the compiled code is more effecient since it is
> compiled specifically for the system and processor it is
> running on. And typically speaking, as a .net program
> runs; it gets faster and faster (obviously hitting a
> plateau when all code is compiled).
>
> If this is the case, wouldn't a game programmed
> using .net, have better performance? Isn't it possible to
> still use pieces of assembly code or otherwise unsafe code
> for specific functions where performance is key?
>
> I was looking at the Mangaged C++ port of the Quake II
> engine the other day and was reading that "Running Quake
> II.NET in the timedemo test indicates the managed version
> performs about 85% as fast as the native version."
> (http://www.vertigosoftware.com/Quake2.htm). The didn't do
> much explaination as to why the managed version was
> slower.
>
> C# itself doesn't seem like it was meant for game
> programming. Am I right? What advantages does the C++
> language have over C# that makes it better for game
> programming (as far as syntax goes, not performance)?
>
> Thank you.
>

 
Reply With Quote
 
Aaron
Guest
Posts: n/a
 
      15th Feb 2005
Very nice response. Thank you. I was most interested in
the suggested books (I'm very good with self-teaching
using books), and it would seem (after reading many
comments) that most of the DX9 books have issues with
compiling code because of the latest updates of DX9 from
Microsoft.

What about OpenGL programming with C#? Is OpenGL still a
qualified competitor of DirectX? HL2 uses DX9 right? And
D3 uses OpenGL right?


>-----Original Message-----
>Aaron,
>You can use C# to develop games. It may be slightly

slower than C++ (if
>designed and implemented properly) be you will be much

more productive.
>
>Games developers are slow to move to C#. They already

employ die hard C++
>coders and there is a lot of snobbery regarding C#. Also

C/C++ is used for
>developing games for the consoles.
>
>To start, try the following links.
>
>Download the DirectX SDK
>http://msdn.microsoft.com/library/default.asp

url=/downloads/list/directx.asp
>
>Managed DirectX discussion
>http://msdn.microsoft.com/newsgroups/default.aspx

dg=microsoft.public.win32.programmer.directx.managed&lang=e
n&cr=US
>
>Managed DirectX eposide of the .NET Show
>http://msdn.microsoft.com/theshow/Ep...37/default.asp
>
>DirectX on MSDN
>http://msdn.microsoft.com/library/default.asp?

url=/library/en-us/dnanchor/html/anch_directx.asp
>
>Books on Managed Direct X
>http://www.amazon.com/exec/obidos/AS...25969/qid=1108

480784/sr=2-1/ref=pd_ka_b_2_1/104-9919604-5913560
>http://www.amazon.com/exec/obidos/AS...26612/qid=1108

480784/sr=2-2/ref=pd_ka_b_2_2/104-9919604-5913560
>
>Good luck.
>Phil.
>
>"Aaron" wrote:
>
>> I taught myself C++ a while back, but never got to
>> involved in actually writing applications with it. I
>> actually spent the last 6 years working for numerous
>> internet web firms as well as doing a plethora of
>> freelance web development work. Lately I started

learning
>> c#. The idea is to stop using coldfusion and switch to
>> writing c# using asp.net. The advantage I believe is

that
>> I can develop websites and software that reuse code and
>> are tied together in a Solution. This idea is very
>> exciting to me.
>>
>> One of my other passions and interests is game
>> development. I've looked around at a lot of different
>> websites and have read over and over again that

although
>> game development with c# is possible; it's just not
>> pratical, due to peformance issues brought on by
>> using .net, etc.
>>
>> It is my understanding, however, that as a .net
>> application runs the called functions are compiled to
>> native code through the JIT compiler. Only functions

that
>> are called are compiled, but once compiled, are not
>> recompiled through the life of the program. In addition

to
>> this, the compiled code is more effecient since it is
>> compiled specifically for the system and processor it

is
>> running on. And typically speaking, as a .net program
>> runs; it gets faster and faster (obviously hitting a
>> plateau when all code is compiled).
>>
>> If this is the case, wouldn't a game programmed
>> using .net, have better performance? Isn't it possible

to
>> still use pieces of assembly code or otherwise unsafe

code
>> for specific functions where performance is key?
>>
>> I was looking at the Mangaged C++ port of the Quake II
>> engine the other day and was reading that "Running

Quake
>> II.NET in the timedemo test indicates the managed

version
>> performs about 85% as fast as the native version."
>> (http://www.vertigosoftware.com/Quake2.htm). The didn't

do
>> much explaination as to why the managed version was
>> slower.
>>
>> C# itself doesn't seem like it was meant for game
>> programming. Am I right? What advantages does the C++
>> language have over C# that makes it better for game
>> programming (as far as syntax goes, not performance)?
>>
>> Thank you.
>>

>.
>

 
Reply With Quote
 
paradox
Guest
Posts: n/a
 
      16th Feb 2005
What about my question concerning assembly and unsafe code; I haven't
gotten to unsafe code in my c# book yet, can assembly code be used in a
c# application where peformance is imperative?

 
Reply With Quote
 
=?Utf-8?B?UGhpbCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      16th Feb 2005
Aaron,
Personally, I've never looked at OpenGL. Suggest you try the following links.

http://www.opengl.org/
http://www.taoframework.com/
http://www.codeproject.com/csharp/csopengl.asp
http://sourceforge.net/project/showf...group_id=33241

Regards,
Phil.

"Aaron" wrote:

> Very nice response. Thank you. I was most interested in
> the suggested books (I'm very good with self-teaching
> using books), and it would seem (after reading many
> comments) that most of the DX9 books have issues with
> compiling code because of the latest updates of DX9 from
> Microsoft.
>
> What about OpenGL programming with C#? Is OpenGL still a
> qualified competitor of DirectX? HL2 uses DX9 right? And
> D3 uses OpenGL right?
>
>
> >-----Original Message-----
> >Aaron,
> >You can use C# to develop games. It may be slightly

> slower than C++ (if
> >designed and implemented properly) be you will be much

> more productive.
> >
> >Games developers are slow to move to C#. They already

> employ die hard C++
> >coders and there is a lot of snobbery regarding C#. Also

> C/C++ is used for
> >developing games for the consoles.
> >
> >To start, try the following links.
> >
> >Download the DirectX SDK
> >http://msdn.microsoft.com/library/default.asp?

> url=/downloads/list/directx.asp
> >
> >Managed DirectX discussion
> >http://msdn.microsoft.com/newsgroups/default.aspx?

> dg=microsoft.public.win32.programmer.directx.managed&lang=e
> n&cr=US
> >
> >Managed DirectX eposide of the .NET Show
> >http://msdn.microsoft.com/theshow/Ep...37/default.asp
> >
> >DirectX on MSDN
> >http://msdn.microsoft.com/library/default.asp?

> url=/library/en-us/dnanchor/html/anch_directx.asp
> >
> >Books on Managed Direct X
> >http://www.amazon.com/exec/obidos/AS...25969/qid=1108

> 480784/sr=2-1/ref=pd_ka_b_2_1/104-9919604-5913560
> >http://www.amazon.com/exec/obidos/AS...26612/qid=1108

> 480784/sr=2-2/ref=pd_ka_b_2_2/104-9919604-5913560
> >
> >Good luck.
> >Phil.
> >
> >"Aaron" wrote:
> >
> >> I taught myself C++ a while back, but never got to
> >> involved in actually writing applications with it. I
> >> actually spent the last 6 years working for numerous
> >> internet web firms as well as doing a plethora of
> >> freelance web development work. Lately I started

> learning
> >> c#. The idea is to stop using coldfusion and switch to
> >> writing c# using asp.net. The advantage I believe is

> that
> >> I can develop websites and software that reuse code and
> >> are tied together in a Solution. This idea is very
> >> exciting to me.
> >>
> >> One of my other passions and interests is game
> >> development. I've looked around at a lot of different
> >> websites and have read over and over again that

> although
> >> game development with c# is possible; it's just not
> >> pratical, due to peformance issues brought on by
> >> using .net, etc.
> >>
> >> It is my understanding, however, that as a .net
> >> application runs the called functions are compiled to
> >> native code through the JIT compiler. Only functions

> that
> >> are called are compiled, but once compiled, are not
> >> recompiled through the life of the program. In addition

> to
> >> this, the compiled code is more effecient since it is
> >> compiled specifically for the system and processor it

> is
> >> running on. And typically speaking, as a .net program
> >> runs; it gets faster and faster (obviously hitting a
> >> plateau when all code is compiled).
> >>
> >> If this is the case, wouldn't a game programmed
> >> using .net, have better performance? Isn't it possible

> to
> >> still use pieces of assembly code or otherwise unsafe

> code
> >> for specific functions where performance is key?
> >>
> >> I was looking at the Mangaged C++ port of the Quake II
> >> engine the other day and was reading that "Running

> Quake
> >> II.NET in the timedemo test indicates the managed

> version
> >> performs about 85% as fast as the native version."
> >> (http://www.vertigosoftware.com/Quake2.htm). The didn't

> do
> >> much explaination as to why the managed version was
> >> slower.
> >>
> >> C# itself doesn't seem like it was meant for game
> >> programming. Am I right? What advantages does the C++
> >> language have over C# that makes it better for game
> >> programming (as far as syntax goes, not performance)?
> >>
> >> Thank you.
> >>

> >.
> >

>

 
Reply With Quote
 
Sean Hederman
Guest
Posts: n/a
 
      16th Feb 2005
No it can't.

From MSDN: "In unsafe code it is possible to declare and operate on
pointers, to perform conversions between pointers and integral types, to
take the address of variables, and so forth"

That's pretty much it I'm afraid. However you could easily write the parts
of your program that required assembler in managed C++, and call that
assembly from your C# code...

"paradox" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What about my question concerning assembly and unsafe code; I haven't
> gotten to unsafe code in my c# book yet, can assembly code be used in a
> c# application where peformance is imperative?
>



 
Reply With Quote
 
paradox
Guest
Posts: n/a
 
      20th Feb 2005
With the benefits of C# in mind, would it make sense to develop a game
mostly in C# and use managed and unmanaged c++ where necessary for
peformance? Would doing so effectively "cure" the performance issues
associated with using .NET for game programming?

To clarify my question. The purpose of using c# in such a case would be
for the ease of use provided by the syntax of the language and using
unmanaged code would be to avoid the cost of garbage collection and
have direct control over memory management. Are there enough advantages
in the syntax of the c# language to decide to write a game that uses it
in conjunction with c++ or would it just make more sense to soley use
c++?

As an alternative approach, would it be possible to develop the engine
in c++ and write the game code in c#? Thank you.

 
Reply With Quote
 
John Puopolo
Guest
Posts: n/a
 
      21st Feb 2005
Hi...

I think the former would work the best. In my experience (15 yrs)
developing software, one tenet has worked well for me... "make it work -
then make it work fast."

It is very difficult if near impossible to determine where your code is
spending its time -- so the only way to know where to optimize it to write
the code (in C#), profile it, then re-write the most-used routines in C/C++
or assembly to get the speed that you need.

You may find, however, that the managed code works just fine and that you do
not need to use unmanaged code at all.

John Puopolo

PS. I'd be interested in how this turns out -- post and let us know!

"paradox" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> With the benefits of C# in mind, would it make sense to develop a game
> mostly in C# and use managed and unmanaged c++ where necessary for
> peformance? Would doing so effectively "cure" the performance issues
> associated with using .NET for game programming?
>
> To clarify my question. The purpose of using c# in such a case would be
> for the ease of use provided by the syntax of the language and using
> unmanaged code would be to avoid the cost of garbage collection and
> have direct control over memory management. Are there enough advantages
> in the syntax of the c# language to decide to write a game that uses it
> in conjunction with c++ or would it just make more sense to soley use
> c++?
>
> As an alternative approach, would it be possible to develop the engine
> in c++ and write the game code in c#? Thank you.
>



 
Reply With Quote
 
thb
Guest
Posts: n/a
 
      21st Feb 2005
Yes it can.

You can't add assembly code inside a C# project, since there is no
machine code in a .NET executable. However, you can create an external
DLL in asm, and call its functions from your managed C#.

This solution is very efficient if you don't switch too often from
managed C# to platform assembly. It ruins the supposed portability
advantages of C#, though.

 
Reply With Quote
 
paradox
Guest
Posts: n/a
 
      24th Feb 2005
Well most games are written in C or C++ and include pieces of assembly
and other code. Almost all of which are not platform independent. By
developing the majority of the project in c#, the components developed
in unmanaged c++ or platform assembly would be the only aspects of the
application that I would need to develop for each platform. This
correct?

I'm sure most games have other conventions they used to narrow down the
amount of code they need to rewrite for each platform; anyone have any
insight into what these conventions are? Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Back-to-Back DoCmd.OpenReport fails if Printer Offline Help with Multi Catalog Microsoft Access VBA Modules 1 21st Nov 2009 02:45 PM
Rolling back a vista upgrade, back to the original version of vist =?Utf-8?B?SmFjaw==?= Windows Vista Installation 2 23rd Aug 2007 04:10 AM
Printing back-to-back on European standard size paper =?Utf-8?B?SHVnaCBI?= Microsoft Outlook Printing 0 29th May 2007 07:53 PM
IE7 Beta 2 click back button brings back to home page Tony Lisanti Windows XP General 4 4th May 2006 06:29 AM
IE 6 navigates back to previous page by itself (as if I had clicked the 'back' button) Nelson Windows XP Internet Explorer 0 26th Jul 2004 06:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:25 AM.