C#,C++ Some insight (Not about performance)
#1 Members - Reputation: 301
Posted 17 December 2012 - 08:59 AM
I have been programming in the .Net platform for about 6/7 years, so I quite like to think of myself as a "decent" programmer, and no matter what C# is one, if not, my preferred language.
I have been thinking in writing a (another) game this days, the thing is I am feeling divided by what approach to take.
I am not sure if I should go for c++ or c#, I am proficient in both, but I am not sure which one to pick.
My doubts are mostly because I don't want to reinvent the wheel, and I feel that C# lacks a lot of good libraries that are available in C++. I talking mostly about physics and other components that are needed for game. I don't want to roll my own on everything, why should I since there are many great ones available already out there that simplifies the job.
So my question, I think, is more on what language would be "easier" and more future prof to write the game. I am not worried about portability, since c++ would probably win hands down, even with mono laying by C# side.
I was thinking in using OPENGL / DirectX with C#, no XNA since I have grown a dislike on the lacking features of DirectX and how hard it is to implement some of features.
I want to hear your insight on this subject, how viable is C# to make a decent game, or if I should scracth it an go with the market choice of C++. Once more I am not asking how performant they are, and lets be realistic I am not going to make a AAA game, so my question is not really which is the best language, but which one would make development easier/faster.
Check out my new blog: Morphexe
#2 Members - Reputation: 311
Posted 17 December 2012 - 09:31 AM
And, personally, I think that if C# is so great, then good libraries will show up sooner or later. But perhaps it is not that great...
#3 Members - Reputation: 301
Posted 17 December 2012 - 09:39 AM
But I find myself beliving that C++ is the way to go in this case, I just feel sad leaving my beloved C# behind. One of the aspects I love in C# is the fast prototyping we have and great compile times in huge projects mostly. I guess, in this case, I will just take the dust of my c++ skills and go with the industry standard.
Check out my new blog: Morphexe
#4 Members - Reputation: 1673
Posted 17 December 2012 - 09:54 AM
#5 Members - Reputation: 301
Posted 17 December 2012 - 10:02 AM
Also on another subject, OpenTK,ShapDX etc, how close are they to their native counterparts?
Check out my new blog: Morphexe
#6 Members - Reputation: 636
Posted 17 December 2012 - 10:04 AM
For sharpDX: http://code4k.blogspot.com.au/2011/03/benchmarking-cnet-direct3d-11-apis-vs.html
#7 Members - Reputation: 187
Posted 17 December 2012 - 10:11 AM
If I had to recommend one or the other flat out, I'd say C++. Like I said, you really can't go wrong with it. It also feels pretty good not being shackled by the .NET framework. Muh freedoms.
Edited by Magdev, 17 December 2012 - 10:19 AM.
#9 Members - Reputation: 1308
Posted 17 December 2012 - 11:37 AM
Also, this way, you are not paying the price of constant context switching that you get when using things like OpenTK and SharpDX happening at every single function call, and you can keep this cost under control by grouping more calls into a single "engine" call.
This for the software.. then there is the programmer's brain context switching cost.. I find this remarkably annoying, especially when you are forced to go "down" into C++ code because you need something not available in C# land... I did this for my last project project and I didn't really like it, so for my current project I am back to C++ only approach. Somehow, working with C++ only makes you forget how much it sucks to deal with forward declarations, includes, stupid compiler error description and so on... having part of your code in a decent language like C#/F# is a constant reminder of how much suckage there is in C++.
Edited by kunos, 17 December 2012 - 11:37 AM.
#10 Members - Reputation: 555
Posted 17 December 2012 - 12:40 PM
And as the other posters have said, perhaps one of my favorite things about C# is how easy it is to pluck useful libraries from the native world. This was one of the main selling points for .NET/C# way back when I was still doing things in Java.
Starnick
Tesla Graphics Engine | AssimpNet | DevILNet |
#11 Members - Reputation: 130
Posted 17 December 2012 - 06:38 PM
#13 Members - Reputation: 518
Posted 17 December 2012 - 07:44 PM
No matter what you can trick with precompiled headers in C++, you won't have the same fast design-and-run round trip you can have while developing in C#. A typical large scale C# projects with thousands of classes compiles in few seconds, even if you change an API that requires to rebuild all assemblies. Faster compilation cycle implies more refactoring/design options and no fear about making large refactoring when they can help your application to be more future proof. Concerning access to existing underlying C++ API from C#, It really depends on your needs, most of .NET wrappers useful for game dev are often up-to-date (Though OpenTK is seriously lacking some updates from latest 4.3 specs, but I wouldn't use OpenTK for a Windows only project).
Also It will depends a lot on your requirements, and there are several questions that are independent of the language of your choice: What are you willing to develop for your game? Only 2D or 3D? Full game engine from a ground up? Only game logic? What about a scene editor? What about mesh loader/converter? Are you proficient with shaders, GLSL/HLSL languages?...etc.
if you are going to build everything using raw level API like DirectX, prepare to have several months of work to build something useful from this API. If you have strictly no experience with DirectX, this could be even more than a few months. It will be a bit worse with raw C++ and DirectX, as you have to handle yourself the raw nature of the API (sometimes only #defines instead of enums, lots of method check for HRESULT, lots of APIs that are more laborious to work with - DirectInput...etc.). For C#, using MonoGame, or probably SharpDX.Toolkit would help a lot. For C++, DirectXTk would be your best option if you want to have a very minimal bootstrap above the raw API. But they are not game engines, just higher level API around DirectX.
But then, you could also consider using a game engine like Unity3d and concentrate on game logic (The scripting is in C#, under the hood, the engine is in C++ using Mono for the scripting) and you could build a prototype game in just a few hours.
#14 Members - Reputation: 1414
Posted 17 December 2012 - 08:46 PM
I am not sure if I should go for c++ or c#, I am proficient in both, but I am not sure which one to pick.
We both know that this is exactly why each language would be fantastic for you. I write the obvious for a reason, as a given, so you could end right there and flip a coin to decide or use both languages, though your .NET experience should influence you.
I have been programming in the .Net platform for about 6/7 years, so I quite like to think of myself as a "decent" programmer, and no matter what C# is one, if not, my preferred language
This alone should weigh heavy in your consideration, of course, because transferring ship in the middle of an ocean is not the wise choice.
My doubts are mostly because I don't want to reinvent the wheel, and I feel that C# lacks a lot of good libraries that are available in C++.
Both C# and C++ have plenty of libraries to take anyone from newbie to AAA popular game developer, so really what you wrote is only true for huge development organizations. You will never be able to take full advantage of those extra C++ highly advanced and specialized libraries until you have a gigantic team working with you and probably far beyond your budget to buy software, tools, and licenses to take advantage of them. If you happen to stay indy, then you will be forced to not worry about the extra C++ highly advanced libraries. For the Indy game developer or small team, either C# or C++ would be wonderful if you are a proficient programmer for making game source code.
The C# advanced libraries are slowing closing the gap with the C++ ones. Since C# is a relatively young programming language coming into maturity with libraries being added every year, the day will likely come when this is not a even the unrealistic concern of some programmers it is today. The .NET Framework which you are familiar in using is also evolving to allow C# to have smooth gameplay even with many assets, the way C++ currently does. I will reveal the bridge between older C# tech like XNA and the future in a few moments.
A fantastic game source code could be made in either C# or C++, likely easier in C# for most programmers, and a game engine of the highly advanced kind with a gigantic team and huge budget would best be served with C++ in most cases, having programmers each focus on a specialty area of the game to take advantage of those libraries - no other way. Does their strategy sound like yours? No - of course it doesn't, unless you have 5 to 20 years of heavy overtime available to focus only on game development. Technology advances likely would make your coding implementations troublesome by the time you finally release a game, so don't worry about the C++ libraries which the big game developers use. The C# libraries will keep you busy and growing for years as indy or small team.
SharpDX is very cross-platform for Windows based systems, one of the most efficient to learn, and has good performance, too. It is an example of one of several major ways to make a game written in C# run well. It is extensible, too. Plug-ins are available for it.
Unity 3D simply rocks! Here is another example of plenty of C# library to take you to AAA game status.
A bunch of C++ written game engines allow you to make a game written in C# or other language(s) which looks great, runs smooth, and is extensible.
Summary
Both C# and C++ are used to create game coding of AAA popular games. The C# is generally considered more streamlined and easier, while the highly advanced features of some C++ libraries let the large organization take full advantage of the latest and greatest game tech.
Some successful game developers are using C# for game scripting and C++ in a game engine to support it. Among them, some are using an existing C++ game engine to - like you - avoid reinventing the wheel. Other languages are being used and combined in special areas for game development, too. In the coming years, more C# AAA game engines will appear as the current crop of young C# programmers and game devs gain experience and accomplishments. Just like C, Java, and C++, technology will accelerate in order to implement in C# as C# environment comes into maturity with hardware and other advances. This means more libraries are coming in C#!
The C# has all the libraries you will need to make an AAA popular game. The C++ highly advanced libraries will be there until you need them and also until C# eventually catches them in advanced specialty areas. The .NET Framework momentum will lead to only greater things being available from it in the coming years.
Recommendations for you:
1) Find a game engine which allows you to use your C#, C++, and .NET experience.
2) Use C# for scripting the game, handle customizations of the game engine written in C# or C++, and implement by your .NET experience where you can.
Clinton
Edited by 3Ddreamer, 17 December 2012 - 08:51 PM.
#15 Members - Reputation: 301
Posted 18 December 2012 - 09:34 AM
So I guess I will go with C# for now, if some trouble arises or if change is needed, C# -> C++ is not that difficult to translate and I can improve the code and refactor has needed.
Check out my new blog: Morphexe






