c++ or c sharp?

11f03724ca393a9faa38a252c52ebf05
0
Doyle 101 Jan 24, 2011 at 03:17

New to coding, which should I start using?

Is c sharp just plain out superior to c++? I’m looking into eventually making a game engine after lots of learning so which would be better suited for such a task?

Thanks in advance.

25 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Jan 24, 2011 at 03:45

If you’re brand new to coding, I would suggest starting with either Python or C#, then picking up C++ later.

C++ is more widely used in game development, is available on more platforms, and can be faster for performance-critical code. But it’s not a good language to start with. It is powerful, but also complicated, low-level (you have to handle more details like memory management on your own) and has a lot of little quirks and gotchas.

C# is a cleaner, more modern, higher-level language, and is easier to learn. There are several game engines that let you script in C#, and it is also the most natural language to use with Silverlight or XNA. I’m not sure whether a full-featured 3D game engine has been written entirely in C#.

Python would be my recommendation for a first language because the syntax is exceedingly simple, which lets you spend more time focusing on learning how to conceptualize a program, organize code and data, and design algorithms rather than learning syntax rules. Those are the most important skills in programming, as they are the ones that cross language boundaries. There are a few game engines that let you script in Python, and some lower-level frameworks like PyGame, as well.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Jan 24, 2011 at 09:49

Totally agree with everything Reedbeta says.

c++ is a complete mess, its full of redundant parts, c# is the way to go for a new guy, learn decent habits straight away.

Me? im still writing hybrid c, c++ cause its how I learnt spanning 10 years ago… if it ever gets to the point where it becomes obsolete completely im sure id be able to learn c# in a couple of days, so theres no big issue. c# is easy to pick up for an old c guru.

Go hell for leather with objects/classes, I suggest, build nice object structures and benefit from all the extra instancing youd get out of it, even though I still write procedural code most of the time. but I know what im doing, you can still use pascal these days if you really want to, its just as powerful as an objective language if you use the functions right.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Jan 24, 2011 at 13:37

No language is superior to another.

Allow me an analogy: is a nailgun superior to a hammer? Well, when you’ve got umpteen linear feet of crown molding to put up, you reach for the nailgun. Speed is it’s forte… until the damn thing jams. But, if you are putting together a jewel box, well, the nailgun will blow the delicate work out. A hammer, with more control, is the call.

Reedbeta is right, though, some languages are more approchable than others. C# or Python are great because of not only the higher-level nature manages more for you automagically than C++, but there’s more material available on the net for inbound devs.

But, in the end, it doesn’t matter because a dev that only knows one language is just as versatile and useful as a carpenter that only uses a hammer.

3cebb31c36b36bb9f29a8032ae7fe8ff
0
Steven 101 May 19, 2011 at 06:44

c# is easier to learn and use, but has overheads..
C++ is more efficient, but harder to learn and use as less of the more difficult programming aspects such as resource management are abstracted from you.
Birthday Party Treasure Hunt

8563f7b73aeb34bb8604f1dd8f546c88
0
Mattias_Gustavsson 101 May 19, 2011 at 08:39

Start with C++. I think it gives you a better understanding of what goes on. It might take a bit more effort to get going with, but imo, it’s effort well spent.

A8ad6ed2ccabff274cfa91dbbe500c96
0
Grandmaster_B 101 May 19, 2011 at 10:28

Go with C/C++, its not easy but its the real thing. C# is nice but i believe you may waste your time if you get serious with an engine someday, only with C/C++ you can make everything you dream of (that should be motivation enough). In either language, you do not have to have learned everything to make cool stuff.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 May 19, 2011 at 12:37

@Mattias Gustavsson

I think it gives you a better understanding of what goes on.

Depends on what you mean by “what goes on”.

If you want to see the memory management guts, the pointers, the bit pushing and all the low-level stuff, then yes, C++ shows more of what’s under the skirt than C#. However, if you want to be able to see the “higher-level flow”, the algorithm, taking all that clutter away gives C# the edge. That’s why it’s an easier starter language for a noob…

6aa952514ff4e5439df1e9e6d337b864
0
roel 101 May 19, 2011 at 16:45

C#, it will save you time, tears and pain. You don’t need max time performance of the cpu-side code, that would otherwise be the only reason to use C++.

B29237c2e6976af375c56ee8e6eaa720
0
Kekke88 101 May 19, 2011 at 17:10

I’d say it depends on what you want to do.

Do you want to build game engines? go C++.
Do you want to build easy smart cool games? go C#.

Do you want to work at a game company (you will probably need lots of education as well though)? go C++.
Do you want to program for fun and as a hobby? go C#.

Do you want to spend much time, more code but eventually (maybe) get a cooler and more powerful game? go C++.

I don’t think the statements above are 100% accurate but maybe they will help you decide.

99f6aeec9715bb034bba93ba2a7eb360
0
Nick 102 May 20, 2011 at 08:45

@Doyle

I’m looking into eventually making a game engine…

If you’re serious about your goal, then concentrate on C/C++. It’s a steep and long learning curve, but once you master it you’ll be able to take on any programming task.

If your goal is to become such a skilled programmer, I don’t think learning a more domain-specific programming language first is worthwhile. They’ll teach you a certain paradigm (rules you’re supposed to follow), but when you transition to C/C++ you’ll find that there are no strict rules and there are many successful paradigms to reach specific goals, and you’ll get very confused/scared and try to avoid C++ and never become good at it. So in my opinion you should learn to stay afloat in the deep end as soon as possible. Once you understand how a complex C++ application works down to the most fundamental level, you’ll have no trouble learning any domain-specific language should you need it, without getting distracted by the paradigms it enforces.

Opinions vary wildly on this subject though. So perhaps there is no right answer and you have to figure out for yourself which learning approach works best for you. Personally I’ve started with C and assembly, and then learned C++. I’ve never regretted starting at a very low level, because it taught me the skills to deal with complicated issues. I know lots of people who are very comfortable writing C# code, but totally panic when something unexpected happens because they are clueless how to handle it.

The thing is, you will encounter unexpected issues during the development of something like a game engine. Lots of them. The time spent actually writing code is only a very small part of the total development cycle. So while for instance a language with a garbage collector like C# allows you to write code a little faster by not having to worry about memory management all the time, it doesn’t actually save you from all memory related issues. You might end up having to learn how the garbage collector works to get the behavior you expected.

I’m not saying this means you should write everything in C++ instead. On the contrary. You should learn C++, and then you’ll be able to determine which language is best for the job (could be C++ itself). By understanding memory management you’ll be able to fully appreciate the benefits of garbage collection, while also understanding the limitations. Knowing C++ gives you the insight necessary to make the right design choices.

It’s like manual versus automatic transmissions in a car. If you plan to become a rally pilot, you’re better off learning to drive a stick shift in your very first driver’s lesson. It’s a little harder at first, but will give you a much better insight into how things work at the mechanical level so it will be easier to become an advanced driver. If you learn to drive in a car with an automatic transmission, manual transmission will seem very awkward (since you learned there’s an ‘easier’ way first) and to become a rally pilot you won’t only have to learn normal driving with a stick, but also advanced driving. I hope you can see in this analogy that C# is more advanced in the sense that it takes work out of your hands, but if you actually want to do advanced things, you’re better off with C++ which allows more manual control of all aspects.

Just my two cents.

99f6aeec9715bb034bba93ba2a7eb360
0
Nick 102 May 20, 2011 at 08:57

@roel

C#, it will save you time, tears and pain. You don’t need max time performance of the cpu-side code, that would otherwise be the only reason to use C++.

That might be a major reason (certainly not the only reason) to use C++, but there are plenty of other reasons to learn C++.

A8ad6ed2ccabff274cfa91dbbe500c96
0
Grandmaster_B 101 May 20, 2011 at 09:10

@Kekke88

I’d say it depends on what you want to do.

Do you want to build game engines? go C++.
Do you want to build easy smart cool games? go C#.

Do you want to work at a game company (you will probably need lots of education as well though)? go C++.
Do you want to program for fun and as a hobby? go C#.

Do you want to spend much time, more code but eventually (maybe) get a cooler and more powerful game? go C++.

I don’t think the statements above are 100% accurate but maybe they will help you decide.

That’s a very good simplification, hits the nail. I second that.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 May 20, 2011 at 09:11

I dont know what you guys are talking about, c# does everything c does better, you can make a game engine in c# no skin off your nose.

8563f7b73aeb34bb8604f1dd8f546c88
0
Mattias_Gustavsson 101 May 20, 2011 at 14:42

Nick sums up my thought on this perfectly. +1

Ceee4d1295c32a0c1c08a9eae8c9459d
0
v71 105 May 20, 2011 at 21:30

What is becoming a common attitude is to switch from c/c++ to java also c# at university courses, professors loves java.I remember that my theses professor adviced me to forget about pointer becasue evertyhing is java now.
I felt really sick that day and it took several days to recover from that horrible feeling of ‘now is everything java’.
I agree with the car analogy.
So i’d go for c++ since the start

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 May 20, 2011 at 22:21

@Nick

in my opinion you should learn to stay afloat in the deep end as soon as possible

If it’s good enough for swimming lesson… wait, funny how nobody really teaches swimming itself that way, huh? :dry:

99f6aeec9715bb034bba93ba2a7eb360
0
Nick 102 May 23, 2011 at 00:27

@alphadog

If it’s good enough for swimming lesson… wait, funny how nobody really teaches swimming itself that way, huh? :dry:

I didn’t say swimming. I said staying afloat.

I’m not suggesting that people should learn the hard stuff before they learn the easier stuff. That’s just plain impossible. My point is that if one wants to become an expert at something, he/she should aim high and not skip any steps.

For instance learning manual memory management is actually not hard at all. It only becomes complicated once projects reach a certain size, at which point garbage collection becomes quite valuable. But knowing the basics of memory management gives you valuable insights into how software works and how to fix nasty bugs.

Likewise, object-oriented development is supposed to make programming simpler, but for newbies it’s actually very confusing because in small projects it has little use. So in my opinion people should first learn C, so that once they move to C++ they fully realize the benefits of object-oriented programming. I also find it incredibly useful to know how inheritance works at the vtable level. It’s hard to understand those kind of things if you haven’t learned basic C function pointers first.

I’m even convinced that starting your first programming lesson in assembly makes sense. It’s no harder than using a pocket calculator. But it helps tremendously in understanding how complex expressions and statements get executed by the actual processor, and makes you appreciate high-level languages even more. It’s also invaluable for advanced debugging.

So really, starting with the bare basics doesn’t have to be harder per se. It allows to learn things incrementally, instead of having to go back and forth between high-level and low-level to make sense of it all. But that’s just my opinion…

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 May 23, 2011 at 13:59

An alternative is to start very high. A scripting language that allows you to start procedurally just to get a ten-liner going, and then layer in algorithms like sorts, tress and other well-known algos to get a handle on computation, then on to “code modularity management” paradigms like OO and such.

And, voila: Python! ;)

Once you master that space, if you want to or need to know how the innards work, then try assembler. The race car analogy is apt. To race a car, you don’t also have to be a mechanic.

As always, you can take a bottom-up approach or top-down, or a mix of both. At my school way, way back, they kinda did both, with an emphasis on bottom-up. Myself, from experience, find a top-down approach much easier, peeling the layers of a complex onion one layer at a time. IMO, the bare basics of assembler/C is too bare. It’s like walking through a flat desert. Sure, there are no visible obstacles, but man is it hot and you gotta carry all that water, food and other basic necessities… :) IOW, to me, exposing a noob to C first, thinking that bit-pushing and other close-to-metal stuff is hard therefore good for them, is a case of “premature optimization”.

Of course, ultimately, it really comes down to the source: the teachers that you get in life.

8563f7b73aeb34bb8604f1dd8f546c88
0
Mattias_Gustavsson 101 May 23, 2011 at 14:15

I’ve found that more often than not, people who started out high level will struggle when trying to get to grips with low level concepts. While people who started low level, will often be fine with high level concepts. At least, that’s my experience based on people I’ve worked with.

I fully agree with Nick on this one - it’s way, way better to *learn* low level first - even if you end up *using* high level when working.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Aug 01, 2011 at 12:04

woah! is that a real girl on the forum?!?!?

Ceee4d1295c32a0c1c08a9eae8c9459d
0
v71 105 Aug 01, 2011 at 12:26

Girl ?? what kind of strange animal is that ?
I remember my old university teacher who was used to say ‘engeneering is not for girls, its for boys’ after that he flunked every girl at the exams.

6aa952514ff4e5439df1e9e6d337b864
0
roel 101 Aug 01, 2011 at 14:18
A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Aug 01, 2011 at 16:25

Just a spammer, guys. Calm down. :P

Ad6bc85d83da164af78707d2ef6c2196
0
nosoul 101 Aug 04, 2011 at 10:09

C# is Java plus C++
Depends on what you want to do :

Games C# and XNA to quickly do something
Application development go with C#

Parallel computing using CUDA OpenMP OpenCL C++ (C# can be used but don’t!!!)
OpenGL C++

Something more on the concept of algorithm level go with C++
Applications with database etc C#

58f167e03cd71a8d45301e2ef4a6d48c
0
jcurtis 101 Sep 05, 2011 at 02:24

C++ seems to be a low level programming language yet you have a lot of power in your hands should you decide to take that route. But if you are just new to programming, I would suggest that you go for C# first as it is easier to learn bordering using it with drag and drop. And with it being almost native to implement with XNA, you are assured that you can complete even a complex game using a single language such as C#.