应该选择 C# 还是 C++ 来学习游戏编程(控制台)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2203093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:22:43  来源:igfitidea点击:

Should C# or C++ be chosen for learning Games Programming (consoles)?

c#c++

提问by understack

I've basic game programming knowledge in c and c++. I'm learning c# nowadays. If I want to make a career in console games programming, which one I should use to proceed? I've noticed that a lot of game companies are using C++/C (probably because of legacy reasons). Also probably C++ enjoys more number of supported libraries?
In which languages modern game engines(unreal/crysis etc) are written in?
Which language is a better bet? and why?

我有 C 和 C++ 的基本游戏编程知识。我现在正在学习 c#。如果我想从事主机游戏编程的职业,我应该使用哪一个来继续?我注意到很多游戏公司都在使用 C++/C(可能是因为遗留问题)。也可能 C++ 享有更多受支持的库?
现代游戏引擎(虚幻/孤岛危机等)是用哪些语言编写的?
哪种语言更好?为什么?

采纳答案by Will

C++, for two reasons.

C++,有两个原因。

1) a lot of games are programmed in C++. No mainstream game is, as yet, programmed in a managed language.

1)很多游戏都是用C++编写的。目前还没有主流游戏是用托管语言编程的。

2) C++ is as hard as it gets. You have to master manual memory management and generally no bounds checking (beyond the excellent Valgrind!). If you master C++, you will find this transferable to managed procedural languages. Less so the other way around.

2) C++ 是最难的。您必须掌握手动内存管理,并且通常没有边界检查(除了出色的 Valgrind!)。如果您掌握了 C++,您会发现这可以转移到托管过程语言。反之亦然。

C++ has a level of complexity close to APL! You'll never get better by playing weaker opponents.

C++ 的复杂程度接近APL!与较弱的对手比赛,你永远不会变得更好。

Joel makes a very strong point about this. People who understand how the machine works make better programmers, because all abstractions are leaky.

乔尔对此提出了一个非常强的观点。了解机器如何工作的人会成为更好的程序员,因为所有的抽象都是有漏洞的

回答by understack

There is no one language that is a "better bet." Use the language most appropriate for what you need to do, whether it is game programming or any other domain. C++ isn't going away anytime soon.

没有一种语言是“更好的选择”。使用最适合您需要做的事情的语言,无论是游戏编程还是任何其他领域。C++ 不会很快消失。

If you're not developing for a Microsoft platform, I doubt you'll use C#.

如果您不是为 Microsoft 平台开发,我怀疑您会使用 C#。

回答by oneat

I think that C++.

我认为是 C++。

Because c# needs additional instalation for C# runtime which only absorbs space on a disk. And C# is of course a bit slower.

因为 c# 需要额外的 C# 运行时安装,它只占用磁盘空间。而C#当然要慢一点。

回答by Jason Williams

You won't find C# running on any consoles, so it's useless in that regard.

你不会发现 C# 在任何控制台上运行,所以在这方面它是无用的。

If you are learning programming, C# offers a softer learning curve than C++, but you can write C++ without getting into the more scary and complex areas of the language, so it's not really much more difficult.

如果您正在学习编程,C# 提供了比 C++ 更柔和的学习曲线,但是您可以编写 C++,而无需涉足该语言的更可怕和更复杂的领域,因此它并不是真正困难得多。

If you want to program with graphics or other "gamesey" things, then C# is a pretty poor choice - go for C++ with OpenGL or DirectX.

如果您想使用图形或其他“游戏”事物进行编程,那么 C# 是一个非常糟糕的选择 - 使用带有 OpenGL 或 DirectX 的 C++。

edit

编辑

Ultimately, if you want a career in games, go for C++. You may be able to write game code in C#, but realistically you won't find nearly as many career opportunities using C# as you do with C++. Unless you want to become a game tools programmer, in which case C# is much better than C++ because you can get a lot more functionality working in a lot less time. A lot of games companies are switching to C# for as much tools dev as possible.

最后,如果您想从事游戏行业,请选择 C++。您也许可以用 C# 编写游戏代码,但实际上,您使用 C# 找不到与使用 C++ 一样多的职业机会。除非你想成为一名游戏工具程序员,在这种情况下,C# 比 C++ 好得多,因为你可以在更短的时间内获得更多的功能。许多游戏公司正在转向 C# 以获得尽可能多的工具开发。

Of course, if you can handle the workload, the best way is to learn both languages, and apply "the best tool for the job". As they're so similar, it's really not difficult to learn one when you've learned the other. (Really most of the learning curve moving from C++ to C# is .net and LINQ etc rather than the core C# language per se - an awful lot of it is nearly identical, with just a few bits of syntactical sugar here and there)

当然,如果你能应付工作量,最好的方法是学习两种语言,并应用“工作的最佳工具”。因为它们非常相似,所以当你学习了另一个时,学习一个真的不难。(实际上,从 C++ 到 C# 的大部分学习曲线是 .net 和 LINQ 等,而不是核心 C# 语言本身 - 很多几乎相同,只是在这里和那里有一些语法糖)

回答by Woot4Moo

Its always a hard one to say because they were using assembly up until 1993, NBA Jam if anyone remembers that bad boy. Technology is constantly trending so its very difficult to say where it will go, I would recommend learning C and getting a very firm grasp on that then move onto C++. I will say this as a caution if you enjoy playing games you will not enjoy coding games.

这总是很难说,因为他们在 1993 年之前都在使用组装,如果有人记得那个坏男孩的话,那就是 NBA Jam。技术在不断发展,所以很难说它会走向何方,我建议学习 C 并牢牢掌握它,然后转向 C++。如果你喜欢玩游戏,你就不会喜欢编码游戏,我会说这是警告。

回答by mr-sk

C++ with win32/GDI is relatively easy to get going, but far more difficult than say Flash or Python (pygame) - however, by using C++ you'll learn a lot in the process and be well poised to continue advancing your career as a game developer. You can also look into XNA if you want to program to the xbox360.

带有 win32/GDI 的 C++ 相对容易上手,但比 Flash 或 Python (pygame) 难得多——但是,通过使用 C++,你会在这个过程中学到很多东西,并准备好继续推进你的职业生涯游戏开发者。如果您想对 xbox360 进行编程,您也可以查看 XNA。

I took some classes at Game Institute (GI)and learned a lot about C++, win32 API and DirectX.

我在游戏学院 (GI) 上过一些课程,学到了很多关于 C++、win32 API 和 DirectX 的知识。

回答by Paul Nathan

C++.

C++。

It is the gold standard for AAA game programming. If you need to do something interesting, you will need to do C++ or delve into unmanaged C#(not always nice).

它是 AAA 游戏编程的黄金标准。如果您需要做一些有趣的事情,您将需要使用 C++ 或深入研究非托管 C#(并不总是很好)。

C++ is also arguably faster(usual caveats apply).

C++ 也可以说更快(通常的警告适用)。

As a learning experience, C# is not worth it. C++ is unquestionably better, especially in the quasi-embedded world of consoles. To get the object-oriented experience, go towards Java.

作为学习经验,C#不值得。C++ 无疑更好,尤其是在控制台的准嵌入式世界中。要获得面向对象的体验,请转向 Java。

回答by IAbstract

To tell the truth...you have to make the decision as to which is the better language. I know what I can do with C#. I know what can be done in C++. C# isn't made to do what C++ was made to do...write code at the most basic level and still be somewhat meaningful when read by human eyes.

说实话……你必须决定哪种语言更好。我知道我可以用 C# 做什么。我知道在 C++ 中可以做什么。C# 不是用来做 C++ 要做的事情......在最基本的级别编写代码并且在人眼阅读时仍然有些意义。

We are developing a game engine with C#, DirectX...is it a challenge? hell yeah...but it's something we chose to do. We are looking at some performance levels that are very close to what C++ can give. So, I see no problems with this effort.

我们正在用 C#、DirectX 开发游戏引擎……这是一个挑战吗?地狱是的...但这是我们选择做的事情。我们正在研究一些非常接近 C++ 所能提供的性能水平。所以,我认为这项努力没有问题。

To cross-platform development, if it weren't for .Net, we might not have the Mono platform. The Mono platform has broadened our platform base.

对于跨平台开发,如果没有.Net,我们可能没有Mono平台。Mono 平台扩大了我们的平台基础。

Here is some support to my arguments...

这是对我的论点的一些支持......

回答by Jeff Hornby

It really depends on what type of game you're planning on building: many games could be done in a language like C#. That being said, the majority of game development is done in C++ just becasue the majority of game development needs to eke out every last bit of performance that the platform can provide and that means either C, C++ or (shudder) assembler.

这实际上取决于您计划构建什么类型的游戏:许多游戏都可以用 C# 之类的语言来完成。话虽如此,大部分游戏开发都是用 C++ 完成的,因为大多数游戏开发需要勉强维持平台可以提供的每一点性能,这意味着 C、C++ 或(不寒而栗)汇编程序。

回答by alchemical

If you knew C# and XNA, you could make some sample games in a pretty straight forward manner, which might help to break into the field.

如果您了解 C# 和 XNA,您可以以非常直接的方式制作一些示例游戏,这可能有助于进入该领域。

My guess is, the core gaming engines are written in C++, but some of the other code around the core could be in C#.

我的猜测是,核心游戏引擎是用 C++ 编写的,但核心周围的一些其他代码可能是用 C# 编写的。