• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
EduardoMoura

C#,C++ Some insight (Not about performance)

14 posts in this topic

Well, let me start by saying this is not asking about which language is better/faster.

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.
0

Share this post


Link to post
Share on other sites
I think it is entirely project-dependent. When you are evaluating project design issues, you have to make some choices - for example, what 3rd party components you will be reusing. If existing C# libraries satisfy your needs, then you should choose C#, because it's obviously easier to develop with this language. If there are no C# libraries you can reuse, you should choose C++ in that project.

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...
0

Share this post


Link to post
Share on other sites
I am not saying C# is better that c++, actually I think they both have their Pro/Con.

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.
0

Share this post


Link to post
Share on other sites
I've found great C# wrappers for many C++ libraries, what in particular do you need? There are native c# physics libraries, and c# wrappers for things like Bullet. SlimDX and SharpDX both wrap DirectX, OpenTK and Tao wrap OpenGL...the list goes on. Aside from mission-cricital performance differences, mitigated by programmer error in many cases, there's no real reason you HAVE to go with C++ unless a specific library you want doesn't have a port or wrapper for it.
1

Share this post


Link to post
Share on other sites
I don't really have specific library in mind, I was just thinking in future I don't want to be mid game development, and then snap I am lacking something.
Also on another subject, OpenTK,ShapDX etc, how close are they to their native counterparts?
0

Share this post


Link to post
Share on other sites
@Morphex

For sharpDX: [url="http://code4k.blogspot.com.au/2011/03/benchmarking-cnet-direct3d-11-apis-vs.html"]http://code4k.blogspot.com.au/2011/03/benchmarking-cnet-direct3d-11-apis-vs.html[/url]
1

Share this post


Link to post
Share on other sites
Above all, you should do what you're most comfortable with. C# has a nicer environment in my opinion, but you really can't go wrong with C++. If you want to be 100% sure you won't run into issues related to your language choice, I'd roll with C++. With the reinventing the wheel thing, I'd say C# and C++ both have a good amount of libraries so you won't have to. From switching from C# to C++ recently though, I've found that C++ has more overall support, and more libraries support it natively, whereas some C# libraries are just C++ libraries with wrappers.

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
0

Share this post


Link to post
Share on other sites
@Xanather, wow that was suprisingly informative, I never expected that the diference would be so small. I guess I was lacking a bit of research on the subject :\. Thanks for the heads up.
0

Share this post


Link to post
Share on other sites
I think the sweet spot in writing a game in C# and C++ would be to have your core engine coded in C++ and then exposed to C# (or any other language that can bind to C) via a C interface (good for portability) or CLI/C++ interface. This way you keep all the game code using the elegance and simplicity of C#/F# while using C++ to interface all the 3rd party libs as it was meant to be.
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
0

Share this post


Link to post
Share on other sites
It's very viable to write games with C# (I've enjoyed several indie games that were all XNA based and really didn't do a lot of in the "game engine" department).

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.
0

Share this post


Link to post
Share on other sites
Well C# would make it easier developing for windows, I personally prefer C++ because it gives you more control of the processor and whatnot and is more platform independent. C# has XNA which makes developing for the 360 super easy but then again there are other engines with basic C++ support which can also export to the the 360 and other consoles as well.. I suppose its where you want to go platform wise. Ive experimented with C# and managed to get graphical apps up and running in a matter of minutes but you're limited to microsoft platforms.
0

Share this post


Link to post
Share on other sites
[quote name='spiralseven' timestamp='1355791096' post='5011865']
...you're limited to microsoft platforms.
[/quote]

No, you're not. I'm working on an iPad and Android game right now and I'm using C#.
0

Share this post


Link to post
Share on other sites
Definitely C# if you care about "easier" and "faster" development cycles and you are only targeting Windows platforms (Desktop, WinRT, WP8). You can develop in C# on other platforms with Mono but it requires a costly license for each platform.

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.
2

Share this post


Link to post
Share on other sites
Hi,

[quote name='Morphex' timestamp='1355756360' post='5011724']
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.
[/quote]

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 [u]both[/u] languages, though your .NET experience should influence you.

[quote name='Morphex' timestamp='1355756360' post='5011724']
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
[/quote]

This alone should weigh heavy in your consideration, of course, because transferring ship in the middle of an ocean is not the wise choice.

[quote name='Morphex' timestamp='1355756360' post='5011724']
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++.
[/quote]

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.


[u]Summary[/u]

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.


[u]Recommendations for you[/u]:

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
2

Share this post


Link to post
Share on other sites
3DDreamer great post you got there, truly enlighten me in way that, well I kind subconsciously had already decided in giving C# a try. You and the other folks replies just gave the incentive I was needing I guess.

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.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0