Game Development Community

Not another damn C++ versus C# post - a country song by dishmal

by Jonathon Stevens · in Technical Issues · 12/21/2005 (9:42 am) · 7 replies

Friends,

our story begins at a microsoft launch event for vs.net 2005, sql server 2005 and biztalk 2006 in minneapolis, mn one cold winter day. as i'm hopping from booth to booth collecting stamps to win an xbox 360 at the end of the event i see the one and only Andrew Troelsen. for those of you who don't know who AT is, here's a quick site with some background: www.intertechtraining.com

as you can see, he's quite famous, at least in this area, for being a HUGE C++ and now a C# guy. where was i? oh yes, the launch event. so, we're talking about how microsoft is the best thing since popcorn and how much we love microsoft (yes, i kiss ass to get answers, shut it) and a thought pops in my head. so i look the bald genious in the eyes and ask "why does everyone think C# is so bogged down with overhead and memory consumption when it comes to game development?" AT smirked for a moment before letting me in on a little known not-so-secret secret. he replies "DirectX 9 and above are built with .net assemblies." wha wha what?! did he just say that directx 9+ IS .net?! well that pretty much just shot the 'C# consumes more resources and has nasty overhead in game development' argument right in the arse.

dish "just opened a floodhole" mal


EDIT: P.S. that would mean that C++ would actually have more overhead with talking with directX =P

About the author

With a few casual games under his belt as CEO of Last Straw Productions, Jonathon created the increasingly popular Indie MMO Game Developers Conference.


#1
12/21/2005 (10:23 am)
No it's not. I don't know who that guy is, but he's full of baloney.

Load up Dependency walker, and take a look at the DLL's. A .Net DLL will require MSCOREE.DLL (the .Net runtime). But if you load the D3D9.dll, you will see that, amongst others, it uses the MSVCRT DLL. This is the Microsoft native code C++ runtime DLL.

DX9 does include .Net assemblies, but they are a wrapper for the COM objects in the other native DLL's.
#2
12/21/2005 (10:36 am)
Yeah.. jaimi is right.

sorry Jonathon, but your idol doesnt know what he's talking about.

in it's current incarnation, managed DX is just a wrapper on top of the native C++ stuff.

and btw, that's not why "games are slow".

The reason why games are slow is becuase of garbage collection. I belive that you can make a fast, performant game in C#, however every "hardcore" game developer learns how to make a game in C++, not in C#. With the garbage collection that goes on in C# you have to be very concious of what you do/dont do in your resource management. And people that start coding a C# game the same way they would do a C++ game are going to be met with failure (huge perf problems)

Also FYI, your idol is actually correct if he meant to be talking about Vista and the Avalon platform. So if you want to think that he is still super-guy then pretend that you misheard him and he was actually talking about Vista (Windows 2007). In honesty, i havent played with avalon yet (I would if it wernt for T2d.net) but it seems like a good step forward.
#3
12/21/2005 (11:50 am)
Hmm.. maybe i misquoted him exactly on what he said. here is a quick bio of him, so i doubt seriously that he's "full of baloney" and "doesn't know what he's talking about."

Andrew Troelsen
Andrew Troelsen is a partner, trainer, and consultant at Intertech-Inc., and is a leading authority on both .NET and COM. His book C# and the .NET Platform won the prestigious 2003 Referenceware Excellence Award and is now in its second edition. Also of note are his earlier five-star treatment of traditional COM in the bestselling Developer's Workshop to COM and ATL mirrored in his book, COM and .NET Interoperability, and his top-notch investigation of VB .NET in Visual Basic .NET and the .NET Platform: An Advanced Guide. Troelsen has a degree in mathematical linguistics and South Asian studies from the University of Minnesota and is a frequent speaker at numerous .NET-related conferences. He currently lives in Minneapolis, Minnesota, with his wife, Amanda, and spends his free time investigating .NET and waiting for the Wild to win the Stanley Cup.

ref: http://www.apress.com/book/bookDisplay.html?bID=10040

anyway, i'm going to email him and shoot him this thread, maybe we can get a response with more detail and possibly accuracy.

dish
#4
12/21/2005 (12:06 pm)
Perhaps he meant DirectX 10. Whatever the case, your argument is wrong - The current DX is not written in .Net. Furthermore, C# IS slower than C++. (When I was at the PDC in LA this year, talking directly with the MS Engineers who implement it, they acknowledge this directly, and say "use C++ if you need raw speed").

Why is it slower? There are many reasons. One of the major ones is Runtime compilation. The compilers just aren't as good as the C++ compiler, which can optimize globally, reorder instructions, unwrap loops, etc. They do this at the cost of compilation speed. As Jason specifies above, Garbage collection is another issue that effects speed (it can cause it to pause in unexpected places, and use up to much memory)

That's OK though. C# doesn't have to be faster than C++ -- It's designed to be *safer* than C++, and easier to program. And at that, it succeeds admirably. If you can be more productive in C#, then more power to you. But it doesn't invalidate that others like C++, or need it's features.
#5
12/21/2005 (12:29 pm)
C++ and c# dont compare..

c# resides in a dingy little island.

c++ however is everywhere.


anything that can only live in one realm.
is Useless to me as a programmer.

many can and will use it tho.
but it does nothing for me.
therefore?
it is utter complete junk
lol.
#6
12/21/2005 (1:45 pm)
Hmm.. maybe i misquoted him exactly on what he said. here is a quick bio of him, so i doubt seriously that he's "full of baloney" and "doesn't know what he's talking about."

Andrew Troelsen
Andrew Troelsen is a partner, trainer, and consultant at Intertech-Inc., and is a leading authority on both .NET and COM. His book C# and the .NET Platform won the prestigious 2003 Referenceware Excellence Award and is now in its second edition. Also of note are his earlier five-star treatment of traditional COM in the bestselling Developer's Workshop to COM and ATL mirrored in his book, COM and .NET Interoperability, and his top-notch investigation of VB .NET in Visual Basic .NET and the .NET Platform: An Advanced Guide. Troelsen has a degree in mathematical linguistics and South Asian studies from the University of Minnesota and is a frequent speaker at numerous .NET-related conferences. He currently lives in Minneapolis, Minnesota, with his wife, Amanda, and spends his free time investigating .NET and waiting for the Wild to win the Stanley Cup.

ref: http://www.apress.com/book/bookDisplay.html?bID=10040

anyway, i'm going to email him and shoot him this thread, maybe we can get a response with more detail and possibly accuracy.

dish
#7
01/14/2006 (3:46 pm)
If DX9 is built with .Net, then how is it that D3D9 games don't require .Net to be installed? Sorry, but that quote is way off.

I'm a Microsoft DirectX MVP, by the way.