• 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
igna92ts

C# and C++

22 posts in this topic

How much harder is c++? because i was considering learning one or the other and I really don't have much time in my hands and i hear that c#and , for example , XNA are way faster to develop than c++ and ,say, sfml.
PS: I dont care about portability
0

Share this post


Link to post
Share on other sites
I can't tell if this is a troll or someone who just woke up and decided to make a game. C# is a less complex language, however I wouldn't consider it harder. And there are more than 3 threads about this same thing on the first page of the beginners section.
1

Share this post


Link to post
Share on other sites
Any language will initially be difficult for a beginner -- but yes, C#/XNA is generally considered to be a bit easier and more approachable than C++ and SFML/SDL/Allegro, [i]unless you're already an experienced C++ programmer[/i].


Do you have any prior programming experience, even if you think it might not be relevant to games?

What exactly do you mean when you say you don't have much time available? Do you mean you don't have much time each day, or do you mean you have a deadline (6 months to complete a game for an assignment for example?) you need to meet? If you only have a little time each day and are trying to be productive then any language you're comfortable with should be fine, but if you have a fixed deadline you might want to consider easier options than C# [i]or[/i] C++ to help ensure your success.


I agree with the above response: trying both languages out for yourself and making a more informed opinion based on your own personal preferences is an excellent idea. Although C# is [i]generally[/i] considered easier and faster to develop with, some people absolutely swear by C++ instead, and you may well be one of those people.

You might also consider the amount and quality of reference materials available: for each language, think up a couple of topics you think you'll need to look up/learn about, and try to find resources for each language. Take note of how much material is available for each language, and check the quality of some of them is suitable.


Hope that helps! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
2

Share this post


Link to post
Share on other sites
I say just go ahead and learn C#. It's an essential skill for modern Windows programming to know C# (or at least [i]some [/i].NET language) and how to use the .NET Framework. C# will be much less painful to learn and you will be a deadly programmer when you learn it. Moving on to learning C and C++ will be [b][i]FAR [/i][/b]easier, as you will already understand programming and the languages are very similar in style, syntax and structure. But, in the end, you will need to know [i]both[/i] to be a really effective game programmer and be eligible for a wide variety of jobs in the games industry... I just think learning C# first will be much easier.

Don't fall into the trap of thinking language A is "better" than language B. Most such claims are complete nonsense, unless we're saying BASIC and VB.NET sucks (just kidding! lol). Programming languages also do [u][b][i]not[/i][/b][/u] (I repeat, do [u][b]NOT[/b][/u]) have any attribute, element or property called "power". All Turing-complete languages are "powerful". Theoretically, any Turing-complete language can calculate the entire span of existence of the known universe. C# is not "less powerful" than C or C++, nor is the reverse true. Likewise, assembly language is not more "powerful" than C... Languages also do not have any sort of fixed performance. The performance/speed of code varies from machine to machine, API to API, programmer to programmer, etc... Some languages can be [i]theoretically [/i]faster than others due to physical limitations or advantages (e.g., JIT compiling or interpretation), but no programming language has a "top speed". Well-written C# code can easily outrun badly-written native code, and vice-versa. Managed languages, despite being theoretically slower due to JIT compiling, can sometimes be superior in performance to native code considering the gains in memory efficiency, reduced bugs, cleaner and better-written code, etc. While I can usually squeeze a couple more milliseconds out of C than I can with C#, sometimes complex algorithms can be faster in C#. It really all depends... just, like I said, never subscribe to any belief that any language is necessarily "better", "faster" or "more powerful" that any other (provided we're talking about practical, Turing-complete languages...not [url="http://en.wikipedia.org/wiki/Brainfuck"]brainfuck[/url] or anything impractical).

If you start with C#, then you'll have the opportunity to learn the essence of Windows application programming (via Winforms) and the essence of DirectX (via XNA Framework). Both of these are easy-to-use APIs that are quick and easy to get started with but provide very deep, far-reaching and low-level capabilities. There's no reason you can't write a big, bad multi-million dollar Windows application with C#, just like you can with C or C++! There are plenty of them out there! When you feel you have "outgrown" the XNA Framework, which is like to happen when you want to write next-gen games for Windows, XBox or other platforms, then move on to learning SlimDX (the C# wrapper for DirectX and all its related APIs) and OpenGL.
2

Share this post


Link to post
Share on other sites
[quote name='ATC' timestamp='1347848057' post='4980764']
I say just go ahead and learn C#. It's an essential skill for modern Windows programming to know C# (or at least [i]some [/i].NET language) and how to use the .NET Framework. C# will be much less painful to learn and you will be a deadly programmer when you learn it. Moving on to learning C and C++ will be [b][i]FAR [/i][/b]easier, as you will already understand programming and the languages are very similar in style, syntax and structure. But, in the end, you will need to know [i]both[/i] to be a really effective game programmer and be eligible for a wide variety of jobs in the games industry... I just think learning C# first will be much easier.

Don't fall into the trap of thinking language A is "better" than language B. Most such claims are complete nonsense, unless we're saying BASIC and VB.NET sucks (just kidding! lol). Programming languages also do [u][b][i]not[/i][/b][/u] (I repeat, do [u][b]NOT[/b][/u]) have any attribute, element or property called "power". All Turing-complete languages are "powerful". Theoretically, any Turing-complete language can calculate the entire span of existence of the known universe. C# is not "less powerful" than C or C++, nor is the reverse true. Likewise, assembly language is not more "powerful" than C... Languages also do not have any sort of fixed performance. The performance/speed of code varies from machine to machine, API to API, programmer to programmer, etc... Some languages can be [i]theoretically [/i]faster than others due to physical limitations or advantages (e.g., JIT compiling or interpretation), but no programming language has a "top speed". Well-written C# code can easily outrun badly-written native code, and vice-versa. Managed languages, despite being theoretically slower due to JIT compiling, can sometimes be superior in performance to native code considering the gains in memory efficiency, reduced bugs, cleaner and better-written code, etc. While I can usually squeeze a couple more milliseconds out of C than I can with C#, sometimes complex algorithms can be faster in C#. It really all depends... just, like I said, never subscribe to any belief that any language is necessarily "better", "faster" or "more powerful" that any other (provided we're talking about practical, Turing-complete languages...not [url="http://en.wikipedia.org/wiki/Brainfuck"]brainfuck[/url] or anything impractical).

If you start with C#, then you'll have the opportunity to learn the essence of Windows application programming (via Winforms) and the essence of DirectX (via XNA Framework). Both of these are easy-to-use APIs that are quick and easy to get started with but provide very deep, far-reaching and low-level capabilities. There's no reason you can't write a big, bad multi-million dollar Windows application with C#, just like you can with C or C++! There are plenty of them out there! When you feel you have "outgrown" the XNA Framework, which is like to happen when you want to write next-gen games for Windows, XBox or other platforms, then move on to learning SlimDX (the C# wrapper for DirectX and all its related APIs) and OpenGL.
[/quote]

This should be required reading for everyone before posting on a [name of managed language x] vs C++ thread :)
1

Share this post


Link to post
Share on other sites
[quote name='superman3275' timestamp='1347820482' post='4980685']
I can't tell if this is a troll or someone who just woke up and decided to make a game. C# is a less complex language, however I wouldn't consider it harder. And there are more than 3 threads about this same thing on the first page of the beginners section.
[/quote]

nooooooooo, C# is a more complex language - it has much more in it than C++ and is growing all the time (even if half of what they add these days is confusing people about the best way to use it) :) But programs written in C++ are more complex out of the necessity of dealing with a lot of machine level concepts that are dealt with for you by the C# runtime. C# has features that are far beyond anything C++ by itself can comprehend such as support for dynamic typing, memory management and a completely different system of linking & compiling that's much faster, cleaner and more advanced. There's nothing stopping you from making all these things in C++, and there are low level things you can make C++ do that are unavailable in C# (without unsafe code or interop) but those are available by virtue of the language being simple, not complex :)
-2

Share this post


Link to post
Share on other sites
This is a really good question and a lot of people are asking it now that Microsoft has been completely silent about the future of the premier C# game programming framework, XNA. I wracked my brain for weeks a few months back on whether or not I should go C# or C++ for my future projects and I decided to stick with C#. I honestly haven't reached any computational limits with C# on rendering, collision detection, or animation yet that would warrant me going to C++. I probably will never go C++ at this point considering I don't have a team of programmers to even come close to creating a complex enough game to warrant the need for the level of tweaking that C++ gives you.

I guess if you actually plan on pursuing a career in game programming for a large studio then you might want to go C++... I think if you want to just making something cool and don't want to quit your day job doing it then go C#. Personal opinion though.
0

Share this post


Link to post
Share on other sites
I used to be hooked on C, but since using C#, I appreciate the way the language stops me from making stupid mistakes.
0

Share this post


Link to post
Share on other sites
@JamesTheNumberless: Thanks, I tried my best to put the point into words! :-)

@crispetersinc:

I ended up leaving XNA when 4.0 came out and deeply disappointed me... having turned away from the PC platform [i]drastically [/i]in favor of XBox and mobile device programmers. Then there's the fact that XNA is just a wrapper and framework for DirectX, and it leaves you [i]stuck[/i], without any choice, with 32-bit apps/games and terribly outdated D3D9... D3D9 is over a decade old! So I finally figured why not use the [i]best[/i] and most up-to-date DirectX technologies that will still be respectable in the next few years when I start finishing up and releasing software. If I started a big 4+ year long project with XNA then D3D9 would just be even more dated... who knows, it might end up being unsupported by graphics hardware and newer Windows OS's in several years and be a complete waste for anything beyond its legacy uses? That's why I migrated to SlimDX, and am hunting for a permanent OpenGL wrapper to use. I feel that a good, well-written C# game engine can do anything XNA can do but do it better, faster and more beautifully. XNA, after all, isn't even an engine...
0

Share this post


Link to post
Share on other sites
Another thing, does developing in c++ really takes THAT much more time?? I mean let's say i was making a game in sfml and it took me 1 year. How much time do you think it would take me in c# and XNA?
0

Share this post


Link to post
Share on other sites
[quote name='igna92ts' timestamp='1347983517' post='4981283']
Another thing, does developing in c++ really takes THAT much more time??
[/quote]

I've programmed in C++ for around a decade, C# for around 7 years now. Unless I'm doing work on buffers (or trivial work), I can complete the task in about an order of magnitude less time using C#, with an order of magnitude fewer bugs. YMMV.

So for [i]me[/i] a C++ game in a year would take a month and half or so in C#. For beginners, I would expect that to be far worse due to added bugs introduced by not knowing C++ best practices.
1

Share this post


Link to post
Share on other sites
[quote name='igna92ts' timestamp='1347983517' post='4981283']
Another thing, does developing in c++ really takes THAT much more time??
[/quote]

No. It probably takes even more.
1

Share this post


Link to post
Share on other sites
[quote name='igna92ts' timestamp='1347983517' post='4981283']Another thing, does developing in c++ really takes THAT much more time??[/quote]
No it doesn't, comments like that usually are made by trolls who attempt to start a language flame war, it's best to not feed those trolls.

First of all, you should make a difference between language and framework. In almost every flamewar somebody comes up with the "GUI application with C++" example, when actually showing win32 window creation code written in C. Comparing two languages by comparing two GUI libraries, it's like comparing a highway with a dirtroad by looking at two random cars that happen to drive on those roads at a particular moment: complete nonsense. In fact, based on this kind of argument, I can easily prove that C++ programming is faster then C++ programming, which doesn't really make sense. The truth here is that the [i]framework[/i] or [i]engine[/i] is of major influence on the development speed of your application. Of course the language is of influence on how the easy the framework can be, as these frameworks rely on the features the language has to offer.

It's true that C++ has lots of ways to screw up then, and some of those are hard to debug. However in reality these bugs are only a minor part of all bugs, and the majority of the bugs are logic errors that will not be different in other languages. In fact one of my old C++ projects I made when still learning the language only has one known crash, which ironically happens on a smart pointer rather then a raw pointer, the other bugs are all logic errors. And some logic errors can be just as hard to debug as pointer errors, in fact at one point it took me around 10 hours to track down one incorrect if-condition that was causing an object that was explicitly marked as invisible to suddenly being rendered 20 minutes into the game. This can happen in any language, even if you would have a language that has validation logic for every variable you want to set and test it against the class invariant, as you can still describe the invariant incorrect.

As long as the developers are experienced with the chosen language, it will not make a lot of difference in development time. With raw memory management languages as C++ you may have some additional bugs to fix involving memory leaks and dangling pointers, but languages with garbage collectors have their own kind of bugs to deal with, as it's definitely not the case that garbage collectors take away the whole trouble of handling pointers nicely. If you don't design your classes properly, garbage collectors can easily break your class invariant and trigger undefined behaviour of your application.

So in the end, programming isn't easy at all. If you as a beginner are thinking of the choice between a language with raw memory management or a garbage collector, you forgot the third option: a language without any memory management. There is no need to use "new" in your first application, there is no need to start making classes when you don't know what a for-loop is yet, and there is no need to make an MMORPG if you don't know how an array works.
-5

Share this post


Link to post
Share on other sites
[quote name='MichaBen' timestamp='1347997057' post='4981370']
If you don't design your classes properly, garbage collectors can easily break your class invariant and trigger undefined behaviour of your application.[/quote]
Wait, come again?

Garbage collectors collect [b]garbage[/b]. Otherwise known as 'unreferenced objects'. Unless you have whimsical class invariants that require objects to which you do not hold a pointer to stay at fixed memory addresses, a garbage collector can't break your invariants. And such whimsy is impossible in a Java-style language, because you can't create pointer values from arbitrary memory addresses in the first place.
2

Share this post


Link to post
Share on other sites
So bottom line, does it take more time or not?? (please only answer this question if you are skilled in both c++ AND c#)


PS: If the difference is. for example, if a project takes 1 year in one in the other it takes 1 year and 10 days then the difference doesn't matter to me as 10 days is not a lot of time
0

Share this post


Link to post
Share on other sites
[quote name='Telastyn' timestamp='1347998207' post='4981381']
[quote name='MichaBen' timestamp='1347997057' post='4981370']
As long as the developers are experienced with the chosen language, it will not make a lot of difference in development time.
[/quote]I call bullshit.[/quote]I think it's less bullshitty, [b]if [/b]you factor in both the experience of the language user [b]and importantly [/b]the nature of the problem that you're trying to solve.

There will be [b]some[/b] small set of problems where it will be quicker for an experienced author to solve it in C++ rather than C#.
[i]e.g. "refactor this collision detection system so that it generates no more than 5 cache misses per frame"[/i].

I'd say (IMHO) this kind of task is more suited to C++, but if the code was in C#, and I was a C# expert, then I'd be able to use explicit struct layouts, etc, to achieve the same results in a similar time.

As usual, generalizations only give us a general idea of the truth.[quote name='igna92ts' timestamp='1348196715' post='4982222']So bottom line, does it take more time or not??[/quote]It depends on the problems being solved. I use both languages professionally -- about half my code is C# and the other half is C++.
For the half of the code-base where C# is my chosen language, I do find it to be much less taxing on my brain energy... Edited by Hodgman
2

Share this post


Link to post
Share on other sites
[quote name='igna92ts' timestamp='1348196715' post='4982222']
So bottom line, does it take more time or not??
[/quote]
Unfortunately, the "bottom line" answer has to be [i]it depends[/i].

It depends on the knowledge and experience of the programmer in question. It isn't always enough to figure out the syntax of a language and be able to write a syntactically correct and error free program; if you haven't also adjusted to the style and idioms of that language you might still be using it in a sub-optimal way. A programmer who knows a language brilliantly might still be less efficient at solving a particular problem if they happen to be unaware of the library or a specific language feature that can help to solve that problem.

It also depends on the problem at hand. Certain problems are better expressed in different languages, and otherwise equivalent solutions in two different languages may have vastly different performance. In some cases certain problems become trivial in certain languages thanks to specific language features or existing solutions provided by libraries.

[quote name='Hodgman' timestamp='1348202507' post='4982235']
As usual, generalizations only give us a general idea of the truth
[/quote]
I'd have to agree with this. There isn't a universally applicable answer to your question, but my own personal attempt at a general answer might be:
[bquote]"for [i]most[/i] people, programming in C# is [i]generally[/i] more productive than programming in C++ [i]unless[/i] the problem at hand is poorly suited to the language, [i]assuming[/i] they have taken the time to properly learn the language and libraries available."[/bquote]


I'd still strongly advise taking a little time to [i]try both languages yourself[/i], and then make your own informed decision based on your own initial impressions and experiences. Where there might be a huge productivity advantage for one programmer, there might be only a small one -- or even a disadvantage instead -- for you. C# [i]can be[/i] significantly more productive than C++, but it might not be [i]for you[/i]. You'll have to spend a little more time doing your evaluation, but if you really value your time in the long run it should get you the best result[sup]1[/sup], as you'll be able to make a decision that matches [i]your[/i] needs rather than relying on a general case or the experiences of others.


You know what the least productive thing you can do is?

Spending forever trying to choose between two languages rather than actually getting started. Ultimately, [i]both[/i] are very capable languages that should be able to meet most -- if not all -- needs you are likely to have. It's possible that you might be more productive with one of them rather than the other, but it's a certainty that you'll be more productive using either of them rather than spending day-after-day trying to choose between them.

Either start going about the process of trying both so that you can make an informed opinion, or just pick either one -- flip a coin if you're still not sure but don't want to spend time trying both -- and get started learning! You could spend months researching and asking questions without getting better answers than you've already received, or in the same time you could possibly finish your first game!


[size=1][sup]1[/sup]Assuming you mean that you have limited time per-day rather than a strict deadline such as a 6 month period in which you must complete a project. If you're dealing with a strict deadline pick [i]either[/i] language and get to work![/size]

Hope that helps! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
1

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