作为业余爱好的游戏编程,我应该使用 Java 还是 C++
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/974454/
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
Game Programming as Hobby, should I use Java or C++
提问by Ibn Saeed
Presently, i am learning Java from the book The Art and Science of Java and following Standford's Programming Methodology Course.
目前,我正在从《Java 的艺术与科学》一书中学习 Java,并遵循斯坦福的编程方法论课程。
I would like to do game programming, but only as a hobby.
我想做游戏编程,但只是作为一种爱好。
I was thinking, would Java be a good choice or is C++ the defacto in game programming.
我在想,Java 是一个不错的选择,还是 C++ 是游戏编程中的事实。
回答by Silfverstrom
Since you are learning Java i would recommend that you stick to it.
由于您正在学习 Java,我建议您坚持使用它。
If you are only developing games for fun, it won't really matter what language you use.
如果您只是为了好玩而开发游戏,那么您使用什么语言并不重要。
回答by Kezzer
That depends, do you want to learn more about C++? Do you need to know? There's still OpenGL libraries in Java that are available, and the concepts would essentially be the same regardless of what language you work in. If it's just for a hobby then I can't see anything wrong with working in Java. In terms of speed however, lower-level languages are prefered.
这取决于,您想了解更多有关 C++ 的信息吗?你需要知道吗?Java 中仍然有可用的 OpenGL 库,无论您使用哪种语言,概念本质上都是相同的。如果这只是一种爱好,那么我看不出使用 Java 工作有什么问题。然而,就速度而言,更喜欢低级语言。
回答by workmad3
Either would be fine. For a hobby, they both have pretty good low-level support for graphics etc, and both also have pretty good higher-level libraries for games (jMonkey engine, SDL, SFML, Ogre and many more).
要么就好。对于业余爱好,它们都对图形等有很好的低级支持,而且都有很好的高级游戏库(jMonkey 引擎、SDL、SFML、Ogre 等等)。
You could also consider other languages too. Python has SDL bindings called PyGame. C# has the XNA framework which has several books published for it now to help learning the framework. SFML has bindings for C++, C, D, Ruby and I think Python. All of these are then suitable for creating games in. Just pick a language and off you go.
您也可以考虑其他语言。Python 具有称为 PyGame 的 SDL 绑定。C# 有 XNA 框架,现在已经出版了几本书来帮助学习这个框架。SFML 绑定了 C++、C、D、Ruby 和 Python。所有这些都适用于创建游戏。只需选择一种语言即可。
回答by Tamas Czinege
If you ask me, neither Java or C++ are fun languages. Both of them have a number of advantages but if you're doing it for fun and don't have deadlines, I would seek out a language that's more fun. Like Python, or something similar.
如果你问我,Java 或 C++ 都不是有趣的语言。它们都有很多优点,但如果你是为了好玩而做它并且没有截止日期,我会寻找一种更有趣的语言。像 Python 或类似的东西。
回答by Iain
If you want to make games you really need a game platform as well as a language, otherwise you will spend all your time solving basic problems like how to draw a sprite to the screen, rather than concentrating on building a fun game.
如果你想制作游戏,你真的需要一个游戏平台和一种语言,否则你将把所有的时间都花在解决基本问题上,比如如何在屏幕上绘制一个精灵,而不是专注于构建一个有趣的游戏。
Great choices for hobby games development are:
业余爱好游戏开发的绝佳选择是:
- Microft's XNA platform with C# language
- Adobe's Flash with ActionScript language
- Sun's JavaFX platform with JavaFX script language
- Unity3D with C# language
- Ogre with C++ language
- Microft 的 XNA 平台与 C# 语言
- Adobe Flash with ActionScript 语言
- Sun 的 JavaFX 平台与 JavaFX 脚本语言
- Unity3D 与 C# 语言
- 使用 C++ 语言的 Ogre
回答by Stefan
You can write games using both languages but I think you should really try C++. There are far more high-level libraries and game engines written in C++ than Java so it would be easier to find one that suits your needs. Not to mention that a lot of older games have been open sourced and you can freely download them and study the code. You can guess what language they're using ;)
您可以使用两种语言编写游戏,但我认为您真的应该尝试 C++。用 C++ 编写的高级库和游戏引擎比 Java 多得多,因此更容易找到适合您需求的库和游戏引擎。更何况很多老游戏都开源了,你可以免费下载,研究代码。你可以猜出他们使用的是什么语言;)
Also you'll find a lot more tutorials and books that teach game programming using C/C++.
此外,您还会找到更多使用 C/C++ 教授游戏编程的教程和书籍。
No matter what you choose in the end, have fun writing your games :)
无论您最终选择什么,请尽情享受编写游戏的乐趣 :)
回答by finnw
If you go with Java, I recommend Computer Graphics for Java Programmers, by Leen Ammeraal.
如果您使用 Java,我推荐Leen Ammeraal 的《Java 程序员计算机图形学》。
If you were developing commercial games you would be using libraries rather than implementing these algorithms yourself, but it's easier once you know the fundamentals, which you can learn from a book like this one.
如果您正在开发商业游戏,您将使用库而不是自己实现这些算法,但是一旦您了解了基础知识就会更容易,您可以从这样的书中学习。
I once wrote a software renderer for a DOOM clone in Java, and having this book for reference helped a lot.
我曾经用 Java 为 DOOM 克隆写了一个软件渲染器,有这本书作为参考很有帮助。
回答by OldJim
C++ is THE defacto language not only for game development but for pretty much everything else, including the browser you are using along with the OS it runs on.
C++ 是事实上的语言,不仅适用于游戏开发,而且适用于几乎所有其他事物,包括您正在使用的浏览器及其运行的操作系统。
So if you are considering ever getting serious with programming C/C++ should be top at your list.
因此,如果您正在考虑认真对待编程,C/C++ 应该是您的首选。
As for speed C++ IS generallyfast than Java. Why generally?Well, the truth is that C++ is faster than Java, is faster than pretty much everything else actually, but sometimes C++ code can be poorly written and Java may prevent beginners to make some mistakes resulting in many of the claims that Java is as fast as C++, there are even claims that Python/Psyco are as fast as C++ and faster than Java.
至于速度,C++通常比 Java 快。为什么一般?嗯,事实是 C++ 比 Java 快,实际上比几乎所有其他东西都快,但有时 C++ 代码可能写得不好,Java 可能会阻止初学者犯一些错误,导致许多声称 Java 是和 C++ 一样快,甚至有人声称 Python/Psyco 和 C++ 一样快,而且比 Java 快。
Keep in mind that no program written for a framework (Java, .NET, VB, etc) will ever run faster than a program that runs on a lower level (direct on the OS or even the hardware) like C/C++, ASM, Pascal and so on.
请记住,为框架(Java、.NET、VB 等)编写的任何程序都不会比在较低级别(直接在操作系统甚至硬件上)(如 C/C++、ASM、帕斯卡等。
Take a look at this:
看看这个:
Poorly written C++ half the speed of Java, properly written is much faster
At the end of the day you should go with the language that you feel more comfortable with, remember that python is enterprise ready, commercial, stable, great for beginners, awesome to use on "Web 2.0" projects not to mention that is a lot of fun too.
归根结底,你应该使用你觉得更舒服的语言,记住 Python 是企业级的,商业的,稳定的,非常适合初学者,在“Web 2.0”项目上使用很棒,更不用说很多了也很有趣。
回答by mduvall
Java - I'd recommend sticking to one and getting good at it. The ideas remain the same, and as you learn more about a single language, you'll begin to learn about the drawbacks and advantages that are prevalent in many of the programming methodologies and languages today.
Java - 我建议坚持使用一个并擅长它。想法保持不变,随着您对单一语言的了解越来越多,您将开始了解当今许多编程方法和语言中普遍存在的缺点和优点。
回答by Michael
I would suggest to try Haaf's Game Enginefor C. It is very very simple 2D engine with good documentation, tutorials and examples, runs on Windows 98 and above and it is ABSOLUTELY free even for commercial usage!
我建议尝试使用Haaf 的C游戏引擎。它是非常简单的 2D 引擎,具有良好的文档、教程和示例,可在 Windows 98 及更高版本上运行,即使用于商业用途也是绝对免费的!
If you're completely new to game development, it's right for you IMHO.
如果您对游戏开发完全陌生,恕我直言,它适合您。

