In your opionion which language is better?
Lots of people tell me c++ is better but lots of people tell me c# is better.
I do realise that Unity doesn’t have c++ in it so there may be more people voting for c# but I would still like to find out
In your opionion which language is better?
Lots of people tell me c++ is better but lots of people tell me c# is better.
I do realise that Unity doesn’t have c++ in it so there may be more people voting for c# but I would still like to find out
As with every “x or y” question, it depends entirely on the context.
Something like a game engine is far more likely to be written in C++ whereas C# makes more sense from a game code perspective, ie Unity.
If you’re going to make that statement, you should actually support it.
C# is much easier. A friend was teaching it to me. It is much like Unity’s UnityScript. Except, for the variables, you don’t put:
‘var object : transform;’ // You put this:
‘public transform object;’ // If it is private, you simply do not put public. You also use at the top 'using . . . . . . ’
Ii like it.
C# is basically Java; (in fact, it’s closer to Java than JavaScript, which is nothing like Java) it’s a really nice OOP languages with a lot of features that make your life easier.
C++ is more like a weapon than a tool: it’s really powerful, but if you don’t know what you’re doing you’re going to cause a lot of damage to yourself and others. It allows you to access memory directly, and it has a lot of other language features (like multiple inheritance) that will blow up in your face if you’re not extremely careful.
Lots of people will tell you that C++ is faster; that’s only partially true. If you write the same algorithm in C++ or C#, the difference will be only trivially in favor of C++. To really exploit C#'s speed, you have to take advantage of C++'s control over the low-level systems of the computer beyond what C# can do.
Overall, though, the programmer’s time is more valuable than the computer’s time, and you really should pick whichever language gives you least headaches.
c# is less feature rich compared to c++, secondly C++ performs way better compared to C#.
(why have most engines c++ under the hood, and not c#? indeed, performance, scalabilities etc.)
C# is fine for “simple” purposes, not for real powerhouse work (like realtime complex rendering, and other performance dependent things)
C# is interpreted language (not compiled to machine code, it needs a runtime engine (VES): mono or .net runtime ), whereas c++ is native (compiled to machine code).
C# is in nature cross platform, just as Java is. (since the code is not machine code compiled, the runtime executing the code needs to do the dirty job).
C++ compiled code is platform specific (thus highly optimized for that platform, see above).
It’s the other way around. C# is more feature rich compared to C++, which is relatively bare-bones.
In most cases C++ performs only somewhat better than C#.
C# isn’t interpreted, it’s compiled to intermediate code, which is JIT compiled. Except on mobile devices, where it’s AOT compiled and thus fully native code.
–Eric
c# is miles better, what are you even smoking? to code in. It’s a modern language.
c++ is freaking decades out of date, and not very much fun to code in.
Now lets phrase from better to most useful, then my replies change:
c# is very useful for game logic
c++ is very useful for game engines
As i’ve learned from professors in the programming field:
not really, with c# your are very much dependent on what functions etc are supported by the virtual machine (jit)(VES) in the framework (mono or .net).
With C++ you don’t have this limitation in general.
(heck even .net was made with c++)
Not true. C# is slower by miles compared to C++ (again why are 90% of all top game engines build in c++ and not C#? think about that for a second or 10, and then come back)
intermidiate code is not native. JIT is a form of interpreting, in the way it converts the code to an action on runtime. (thus it interprets the bytecode application to a machine code on runtime, simply explained)
C++ doesn’t need this conversion, it’s already converted.
Yeah it’s a modern language, but that doesn’t make it better by definition.
So? it’s a personal opinion what one likes more. Also (pre) knowlegde is key to your comment.
If a person learned one language all other language are strange in that persons eyes.
How old a language is is complete irrelevant, for it’s functionality/use.
Yep, i said that already (c# for “simple” code, c++ for heavy duty code)
This compares relative speeds of some routines. Notice that it says C++ is ~15% faster than .NET in the same routines and ~50% faster than Mono, but more importantly:
Obviously, this applies differently to Unity, but for the question then it should suffice.
use python, is a lot easier and is gaining every time more adepts… actually the systems are enough fast to handle high level programming language… i think if your are not going to do plugins, drivers or such things… go for high level languages…
Well, that’s a problem. You need to research real-world cases instead.
Yes really, by any standard at all, the C# language is more feature-rich than C++. C++ is more low-level. The point of high-level languages is that they have more features.
Nope, C++ is only significantly faster in certain specialized cases. See benchmarks.
In some cases, JIT code can actually be faster than native code, since it can take advantage of whatever runtime environment it’s on, instead of relying on lowest-common-denominator code. And as I mentioned, C# can be AOT compiled too, so it’s a moot point.
–Eric
Love the address for this page… C-Vs-C!
And has nothing to do with c++ being nearly 30 years old? I have news for you, most game engine’s base technology is very old, they didn’t have a choice to use c#, even if they understood it’s benefits.
I’ve coded engine tech in c++ for many, many years. From a competitive standpoint, it’d be great for me if C++ were still the best solution for game development, but it largely is not. C# is better if you’re interested in actually getting things done. C++ is better if you don’t know any better.
The performance benefit of c++ is there, for sure, but it’s silly to consider it as a pivotal factor. In the wild, vast majority of your code speed simply does not matter. Even if it resulted in a real-world speed increase of 50%, which it likely will not, your code will still not likely reach the 20% of overall CPU time spent, so getting a 10% speed increase (which will likely not be a true limiting factor, considering most platforms are multi-core) is sooooo not worth what you lose. I’ve yet to see a gamer say “I’d have liked the game if it were only 10% faster”, but I’ve heard countless times “I didn’t like it, it was buggy” or “…lacked features”, two things directly related to how fast the language is to develop in and how error prone it is, and C# is wildly superior to C++ in these regards.
Modern optomization is more a matter of knowing how to work APIs/hardware, generating smooth concurrency, avoiding cache hits, that sort of thing. Pure algorithm comparisons don’t take that into consideration, generally.
C#
Hands down
the first computer language I learned was C, then I came across C++, and I thought: ‘what is all this crap for?’ it makes C slower, cumbersome and multiplies errors in unbelievable ways… no thanks, i’ll stick to C… then I stopped programming and went and did some more social things with my life…
now I’m back to coding with unityscript… I think I might move to C# in the near future too… I can’t believe the ease of use, and I can only guess how much faster things could be if they were made in C, but to be honest… I can also see how large the code would be… trading some things for others I guess…
Objective-C!
(hides)
A lot of the performance of any language lies with the effectiveness of the programmer. I’d say my ability to keep track of what’s going on in some of the more complex logic routines is greatly enhanced by using C#, compared to C++. Thus, C# makes it easier for me to optimise, restructure and generally make better at least 85% of my code, if not more.
I don’t know? Is it because Unity is used by over 150 THOUSAND active developers representing 1 MN hours of dev each month, has over 60MN web plugin installs and runs in extremely performance limited situations (Integrated graphics, Pentium processor, iPhone, Android).
It doesn’t have to be ‘miles’ faster, just a ‘little bit’ faster.
the days that C++ was worlds faster were quite some time ago.
its still faster yeah, but the difference is not worlds and its not the reason why engiens are in C++
the reason why engines are in C++ is that c++ offers dirty lowlevel tricks that allow you to do things that are not needfully safe and naturally cause most middleware you implement in the engine exists for C++ only forcing you to be on C / C++ too to work performantly with it