What is SDL used for in c ++

Why do people use C when it is so dangerous?

This is a HUGE question with tons of answers, but the short version says that each programming language specializes in different situations. For example, JavaScript for the web, C for low-level content, C # for Windows, and so on. Once you are familiar with programming, it is helpful to know what you want to do in order to decide which programming language to choose.

To address your final point, why C / C ++ over Java / Python, speed often matters. I make games and Java / C # has only recently reached speeds good enough for games to run. If you want your game to run at 60 frames per second and you want your game to do a lot (it's especially expensive to render), the code needs to run as quickly as possible. Python / Java / C # / Many others run on "interpreters," an extra layer of software that does all the tedious things that C / C ++ doesn't do, like managing memory and garbage collection. That extra overhead slows down the work, so almost every major game you see (at least for the last 10 years) has been run in C or C ++. There are exceptions: the Unity game engine uses C # * and Minecraft Java, but they're the exception, not the rule. In general, large games played with interpreted languages ​​are reaching the limits of the speed at which that language can operate.

* Unity isn't all C # either, a lot of it is C ++ and you only use C # for your game code.

EDIT To respond to some of the comments that popped up after posting, maybe I've oversimplified, I've just given the general picture. In programming, the answer is never easy. There are interpreters for C, Javascript can be executed outside the browser and C # can be executed on almost anything thanks to Mono. Different programming languages ​​specialize in different domains, but some programmers have probably figured out somewhere how to run a language in any context. Since the OP didn't seem to know much about programming (assumption on my part, sorry if I'm wrong) I tried to keep my answer simple.

As for the comments that C # is almost as fast as C ++, the keyword is almost there. When I was in college we went to a lot of game companies, and my teacher (who had been encouraging us to move from C # to C ++ all year) asked programmers at every company we went to why C ++ over C # and in every single one said C # is too slow. Generally it runs fast, but the garbage collector can degrade performance as you have no control over when it runs and it has the right to ignore you if it doesn't want to run if you recommend it. When you need something to perform well, you don't want something to be so unpredictable.

To answer my "Just get speeds" comment, yes, a lot of the speed improvements in C # have come from better hardware, but as the .NET Framework and C # compiler have improved, there have been some accelerations there.

It depends on the comment "Games are written in the same language as the engine". Some are, but many are written in a mixture of languages. Unreal can use UnrealScript and C ++, Unity C # Javascript and Boo, many other engines written in C or C ++ use Python or Lua as scripting languages. There is no easy answer there.

And just because it bugged me to read "Who cares if your game runs at 200fps or 120fps" when your game runs faster than 60fps, you're probably wasting CPU time as the average monitor doesn't even update this quickly. Some higher and newer ones do this, but it's not standard (yet).

And for the "ignore decades of engineering" remark, I'm still in my early twenties. So when I extrapolate backwards, I mostly agree with what older and more experienced programmers have told me. Of course, this is contested on a site like this, but it's worth considering.