为什么只有几个用Java编写的视频游戏? [英] Why are only a few video games written in Java?

查看:147
本文介绍了为什么只有几个用Java编写的视频游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么没有很多用Java编写的商业3D视频游戏(不是随机开源2D游戏)?从理论上讲,它很有意义:几乎免费提供生产力提升和跨平台应用程序,其中包括大量的Java库和内置的垃圾收集(尽管我承认我'我不确定后者是不是一件好事。那为什么很少使用?我只能想到为Java平台编写的一些流行的商业游戏。

Why aren't many commercial, 3D video games (not random open source 2D ones) written in Java? In theory, it makes a lot of sense: you get a productivity boost and a cross-platform application almost for free, among other things, such as the vast amount of Java libraries, and built-in garbage collection (although I admit I'm not sure if the latter is a good thing). So why is it rarely used? I can only think of a couple popular commercial games written for the Java platform.

这是因为性能?如果是这样的话,大多数重担都不会由GPU完成吗?

Is it because of performance? If so, wouldn't most of the heavy lifting be done by the GPU anyway?

推荐答案

游戏开发世界很有趣一:一方面,他们经常很快接受新的想法,另一方面,他们仍处于石器时代。

The game development world is a funny one: On one hand, they're often quick to accept new ideas, on the other hand, they're still in the stone age.

事实是,有转换到.NET / Java / C / C ++以外的任何东西,很少有这么大的动力。

The truth is, there's rarely that much incentive in switching to .NET/Java/anything other than C/C++.

大多数游戏公司都会从其他公司获得游戏引擎的部分许可。这些部分是用C ++编写的,尽管您可以访问源代码以便移植它,但这需要花费很多精力(当然,许可证需要允许它)。

Most game companies license parts of the game engine from other companies. These parts are written in C++, and although you might have access to the source so you could port it, that takes a lot of effort (and of course, the license needs to allow it).

此外,C ++中已存在许多遗留代码。如果之前项目的代码可以重复使用(比如说,如果你正在写续集),那么更重要的是支持使用相同的语言,而不是用新语言重写它(更多是因为你可能会重新引入大量的错误,你需要花时间熨平。

Also, a lot of legacy code already exists in C++. If code from previous projects can be reused (say, if you're writing a sequel), that counts even more in favor of sticking with the same language, instead of rewriting it in a new language (more so since you'll likely reintroduce a ton of bugs which you'll need to spend time ironing out.

最后,用100%C ++编写的游戏很少见 - 很多都是使用脚本语言,无论是自定义语言还是仅仅集成现有语言(Lua是目前比较流行的语言之一)。

Finally, it's rare for games to be written in 100% C++ anyway - a lot is done using scripting languages, whether they're custom or just integrating an existing languages (Lua being one of the more popular ones these days).

就垃圾收集而言,这可能是一个问题。问题不在于它存在,更多的是它如何工作 - 垃圾收集器必须是非阻塞的(或至少保证只是非常短暂地阻塞),因为它是完全不可接受的让游戏冻结10秒,同时扫描所有已分配的内存以查看可以释放的内容。我知道Java在GC中会有相当多的窒息接近内存耗尽(对于某些游戏,它会)。

As far as garbage collection is concerned, that can be a bit of a problem. The problem is not so much that it exists, it's more how it works - the garbage collector MUST be non-blocking (or at least be guaranteed to only block very briefly), since it's simply unacceptable to have the game freeze for 10 seconds while it scans all the allocated memory to see what can be freed. I know Java tends to choke quite a bit in GC'ing when it's close to running out of memory (and for some games out there, it will).

你可以做的事情也受到一些限制:你可以由于运行时的开销,不能完全利用硬件。想象一下Crysis是用Java编写的......即使这是唯一可见的区别,它也不会是一样的(我也很确定你需要一个Core i7来运行它。)。

You're also a bit more restricted in what you can do: you can't fully exploit the hardware due to the overhead of the runtime. Imagine Crysis being written in Java... even if that's the only visible difference, it just wouldn't be the same (I'm also pretty sure you'd need a Core i7 to run it.).

这并不意味着这些语言在游戏开发中没有自己的位置 - 不,我不只是指工具编程。对于大多数游戏来说,你不需要从C ++中获得额外的性能,包括3D游戏,如果你是从头开始编写它,那么使用像XNA这样的东西是完全合理的 - 事实上,有一个很有可能。

This doesn't mean these languages don't have their place in game development - and no, I'm not just referring to tool programming. For most games, you don't need that extra bit of performance you get from C++, including 3D games, and if you're writing it all from scratch, it can make perfect sense to use something like XNA - in fact, there's a good chance it will.

就商业游戏而言 - RuneScape 数?这可能是那场最成功的Java游戏。

As far as commercial games are concerned - does RuneScape count? That may well be the most succesful Java game out there.

这篇关于为什么只有几个用Java编写的视频游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆