Programing

Java로 작성된 비디오 게임이 왜 소수입니까?

lottogame 2020. 5. 25. 08:05
반응형

Java로 작성된 비디오 게임이 왜 소수입니까? [닫은]


Java로 작성된 상업용 3D 비디오 게임 (랜덤 오픈 소스 2D가 아닌)이 많지 않은 이유는 무엇입니까? 이론적으로는 많은 의미가 있습니다. 거의 많은 Java 라이브러리 및 내장 가비지 수집과 같은 것 중에서 생산성 향상과 크로스 플랫폼 응용 프로그램이 거의 무료로 제공됩니다. 후자가 좋은 것인지 확실하지 않습니다). 왜 거의 사용되지 않습니까? Java 플랫폼 용으로 작성된 몇 가지 인기있는 상용 게임 만 생각할 수 있습니다.

성능 때문입니까? 그렇다면 GPU가 대부분의 무거운 작업을 수행하지 않습니까?


게임 개발 세계는 재밌습니다. 한편으로는 종종 새로운 아이디어를 빨리 받아들이고 다른 한편으로는 여전히 석기 시대입니다.

사실, .NET / Java / C / C ++ 이외의 것으로 전환하는 데 많은 인센티브는 거의 없습니다.

대부분의 게임 회사는 다른 회사로부터 게임 엔진의 일부를 라이센스합니다. 이러한 부분은 C ++로 작성되었으며 소스에 액세스하여 이식 할 수 있지만 많은 노력이 필요합니다 (물론 라이센스가 허용해야 함).

또한 C ++에는 많은 레거시 코드가 이미 존재합니다. 이전 프로젝트의 코드를 재사용 할 수 있다면 (예를 들어, 속편을 쓰는 경우), 새로운 언어로 코드를 다시 쓰지 않고 같은 언어를 고수하는 것을 선호합니다 (더 많은 내용은 다시 소개 할 것이므로) 다림질하는 데 시간이 걸리는 수많은 버그.

마지막으로, 게임이 100 % C ++로 작성되는 경우는 거의 없습니다. 스크립트 언어를 사용하여 맞춤 언어를 사용하든 기존 언어를 통합하든 (루아는 요즘 가장 인기있는 언어 중 하나임) 많은 작업이 이루어집니다.

가비지 수집과 관련해서는 약간의 문제가 될 수 있습니다. 문제는 그다지 많지 않고 작동 방식이 더 큽니다. 가비지 수집기는 반드시 10 초 동안 게임을 정지시킬 수 없기 때문에 가비지 컬렉터는 반드시 비 차단이어야합니다. 할당 된 모든 메모리를 스캔하여 사용 가능한 메모리를 확인합니다. Java가 메모리 부족에 가까워지면 GC에서 상당히 질식하는 경향이 있다는 것을 알고 있습니다.

또한 수행 할 수있는 작업에 약간 제한이 있습니다. 런타임 오버 헤드로 인해 하드웨어를 완전히 이용할 수 없습니다. 크라이시스가 자바로 작성되었다고 상상해보십시오 ... 유일한 눈에 띄는 차이점이더라도 동일하지는 않습니다 (또한 실행하려면 Core i7이 필요하다고 확신합니다).

그렇다고해서 이러한 언어가 게임 개발에 자리를 차지하지 않는다는 것은 아닙니다. 아니요, 저는 단지 도구 프로그래밍을 말하는 것이 아닙니다. 대부분의 게임의 경우 3D 게임을 포함하여 C ++에서 얻는 추가 성능이 필요하지 않으며 처음부터 모두 작성하는 경우 XNA와 같은 것을 사용하는 것이 좋습니다. 좋은 기회입니다.

상용 게임에 관한 한 RuneScape는 중요합니까? 그것은 가장 성공적인 Java 게임 일 것입니다.


John Carmack이 다음과 같이 가장 잘했다고 생각합니다.

가장 큰 문제는 Java가 실제로 느리다는 것입니다. 순수한 CPU / 메모리 / 디스플레이 / 통신 수준에서 대부분의 최신 휴대 전화는 Game Boy Advanced보다 훨씬 더 나은 게임 플랫폼이어야합니다. Java를 사용하면 대부분의 전화에서 원래 4.77mhz IBM PC의 CPU 성능과 모든 것을 완벽하게 제어 할 수 있습니다. [... snip ...] 언제 어디서나 쓸 수 있습니다. 하아. 하 하하하 우리는 현재 4 개의 플랫폼에서만 테스트 중이며, 한 쌍이 정확히 같은 특징을 가지고 있지는 않습니다. 모든 상용 게임은 각 플랫폼 (종종 100 개 이상)에 대해 개별적으로 조정 및 컴파일됩니다. 이식성은 끔찍한 성능에 대한 정당화가 아닙니다.

( 소스 )

물론 그는 모바일 플랫폼에 대해 이야기하고 있었지만 C ++ 배경에서 온 Java와 비슷한 문제를 발견했습니다. 내 자신의 말로 스택 / 힙에 메모리를 할당 할 수 없다는 것을 잊어 버렸습니다.


우선, Java의 연산자 오버로드가 없기 때문에 작동하는 그래픽 파이프 라인을 매우 성 가시고 읽기 어려워지기 위해 처리해야 할 모든 수학이 만들어집니다.

처리해야하는 모든 행렬 곱셈 및 아핀 벡터는 객체 지향 표현식이 아닌 올바른 형식의 수학 표현식 인 경우 따라 가기가 훨씬 쉽습니다.

product = vector.multiply(projectionMatrix).dotProduct(otherVector);

그건 끔찍 해요 수학은 그렇게 보이지 않아야합니다.


.NET은 Java와 동일한 인식 문제를 가지고 있다고 생각합니다. Microsoft는 XNA를 사용하여 개발자에게 마케팅에서 더 나은 작업을 수행했습니다.


사소한 점부터 :

  • Java의 생산성 향상은 가상적인 것입니다. 이 구문은 C ++과 거의 동일하므로 메모리 관리 및 표준 라이브러리를 통한 비용 절감에 도움이됩니다. 라이브러리는 게임 개발자를 거의 제공하지 않으며 메모리 관리는 가비지 수집으로 인해 논쟁의 여지가있는 문제입니다.

  • 크로스 플랫폼 "무료"는 생각하는 것만 큼 좋지 않습니다. OpenGL을 사용하려는 개발자는 거의 없으며 몇몇 주요 플랫폼에는 그래픽, 오디오, 네트워킹 등의 기본 라이브러리에 대한 Java 구현 또는 래퍼가 없을 것입니다.

그러나 주로 문제는 이전 버전과의 호환성입니다. 게임 개발자는 마이그레이션 경로가 매끄 럽기 때문에 C에서 C ++로, 어셈블리에서 C로 옮겼습니다. 각각은 이전과 밀접하게 연동되며 이전의 모든 코드는 종종 단일 컴파일러를 통해 새로운 언어로 사용할 수 있습니다. 따라서 마이그레이션은 원하는 속도만큼 느리거나 빠릅니다. 예를 들어 오늘날 사용중인 일부 기존 헤더에는 여전히 #ifdef WATCOMC가 있습니다.그리고 나는 10 년 이상에 아무도 Watcom 컴파일러를 사용하지 않았다고 생각합니다. 이전 코드에는 막대한 투자가 있으며 각 비트는 필요한 경우에만 교체됩니다. 기존 코드와 기본적으로 상호 운용되지 않는 언어로 변경 한 경우 한 게임에서 다음 게임으로 비트 및 조각을 교체하고 업그레이드하는 과정은 그다지 실용적이지 않습니다. 그렇습니다. C ++ / Java 상호 운용성은 가능하지만 단순히 "C를 약간의 C ++로 작성"하거나 C에 asm 블록을 포함시키는 것과 비교하면 비현실적입니다.

게임 개발자가 선택한 언어로 C ++을 올바르게 대체하려면 다음 두 가지 중 하나를 수행해야합니다.

  1. 기존 레거시 코드와 쉽게 상호 운용 가능하므로 투자를 유지하고 기존 라이브러리 및 도구에 대한 액세스를 유지하거나
  2. 모든 코드를 다시 작성하는 비용 (또는 해당 언어에서 사용할 수있는 재사용 가능한 구성 요소로 인터페이스를 재 작업하는 데 드는 비용)이 포함되어 있다는 점에서 생산성 향상을 충분히 보여줍니다.

주관적으로, 나는 Java가 그중 하나를 충족한다고 생각하지 않습니다. 누군가가 파이오니아가 될만큼 용감하다면, 더 높은 수준의 언어가 2 차 언어를 충족시킬 수 있습니다. (EVE Online은 아마도 우리가 파이썬을 사용할 수있는 가장 좋은 예일 것입니다. 그러나 이것은 주요 파이썬 언어의 포크, 많은 C ++ 구성 요소를 성능에 사용하며 심지어 현대적인 측면에서 상당히 요구되지 않는 게임을위한 것입니다.)


I'm playing the Sims 3, and I did some poking around. The graphics engine is C++, while the scripting and behavior engine is C#/Mono. So while C++ is there for time critical bits, other stuff like .interaction, game logic, AI is in an object oriented managed language.


  • Are there any good ports of gaming engines/libraries?
  • Many C/C++ developers, particularly the ones on Windows (where most commercial games are written) are familiar with Visual Studio. There is no comparison in IDEs.
  • In general, Java has been sold to businesses because of it's solid typing and it has a perception of not having memory management issues.
  • And yes, Java still suffers from a perception that it is slow, and it's memory management is poor, and for games, it probably is ill-suited to the task. As stated in some of the other answers, garbage collection just isn't going to cut it when you are dealing with real-time high-performance requirements. Video games push CPUs and GPUs to their limits.

One of the biggest reasons Java and other Virtual Machine languages are not used for games is due to Garbage Collection. The same thing goes for .NET. Garbage collection has come a long ways and works great in most types of applications. In order to do garbage collection though, you do need to pause and interrupt the application to collect the trash. This can cause periodic lag when collection happens.

Java has the same problem for realtime applications. When tasks must run at a specific time, it is hard to have an automated task such as garbage collection respect that.

It is not that Java is slow. It is that Java is not good at handling realtime tasks.


A large reason is that video games require direct knowledge of the hardware underneath, often times, and there really is no great implementation for many architectures. It's the knowledge of the underlying hardware architecture that allows developers to squeeze every ounce of performance out of a gaming system. Why would you take the time to port Java to a gaming platform, and then write a game on top of that port when you could just write the game?

edit: this is to say that it's more than a "speed" or "don't have the right libraries" issue. Those two things go hand-in-hand with this, but it's more a matter of "how do I make a system like the cell b.e. run my java code? there aren't really any good java compilers that can manage the pipelines and vectors like i need.."


Performance issue is the first reason. When you see the kind of hyper optimized C++ code that are in the Quake engines ( http://www.codemaestro.com/reviews/9 ), you know they're not gonna waste their time with a virtual machine.

Sure there may be some .NET games (which ones ? I'm interested. Are there some really CPU/GPU-intensive ones ?), but I guess it's more because lot of people are experts in MS technologies and followed Microsoft when they launched their new technology.

Oh and cross-platform just isn't in the mind of video games companies. Linux is just around 1% of market, Mac OS a few % more. They definitely think it's not worth dumping Windows-only technologies and librairies such as DirectX.


You can ask why web applications aren't written in C or C++, too. The power of Java lies in its network stack and object oriented design. Of course C and C++ have that, too. But on a lower abstraction. Thats nothing negative, but you don't want to reinvent the wheel every time, do you?

Java also has no direct hardware access, which means you are stuck with the API of any frameworks.


Misconceptions about performance and poor JVM optimizations would be my guess. I say misconceptions about performance because there are some Java ports of C++ games that perform faster than their C++ counterparts (see Jake 2). The real problem, IMHO, is that many Java programmers aren't focused so much on bleeding edge performance as they are with ease of use and understandability/maintainability of code. On the C/C++ side of things you're essentially coding in a slightly higher level assembly language and its about as close to the hardware as you can get without writing in assembly or straight machine code.


List of game engines on Wikipedia lists many game engines along with the programming language that they are written in.

There are several Java game engines listed.

Clicking some of the links will lead you to examples of games and demos written in Java. Here's a couple:

For certain games and situations, Java's trade-offs might be acceptable.


.NET definitely has some of the same issues that Java has when it comes to intense 3D performance. Microsoft has also invested a lot more time and money in the development of the libraries when it comes to working with 3D heavy operations.

(...personally, I also think they had a leg up when it comes to the magic between DirectX and .NET)


  1. Java is slow, most of the heavy lifting is not handled by the GPU. There's still animation, physics, and AI hitting the CPU, all of which are very time-consuming.

  2. Java doesn't exist on consoles, and consoles are a major target for commercial games. If you use Java on PC, you're eliminating your ability to port to consoles within reasonable time and budget.

  3. Many of the more experienced coders in the game industry have been using C and C++ long before Java became popular. The two points above may contribute to this, but I expect that many professional game coders just don't really know Java all that well.

  4. Someone else's point about middleware above was a good one, so I'm adding it to my answer. There's a lot of legacy code and middleware written specifically to link with C/C++, and last I checked Java doesn't have good interoperability. Using Java for most companies would involve throwing out a lot of code, much of which has been paid for in one way or another.


Actually, it is very possible for managed code to do 3d games, the problem is the back engines. With .Net, for a brief period, there was a Managed DirectX wrapper to DirectX 9 by Microsoft. This was before the abstraction that is now XNA.

Being given total access to DirectX api's, .Net games work a treat. The best example I know of is www.entombed.co.uk, which is written in VB.Net.

Unfortunately, on the Java side, it is seriously lacking - mainly for the reason that DirectX isn't available for Java, and games programmers know and understand the DirectX api - why learn yet another api when you will be returning to DirectX?


Game marketing is a commercial process; publishers want quantifiable low-risk returns on their investment. As a consequence, the focus is usually on technology gimmicks (with exceptions) that consumers will buy to produce reliable return - these tend to be superficial visual effects such as lens glare or higher resolution. These effects are reliable because they simply use increases in processing power - they exploit the hardware/Moore's law increases. this implies using C/C++ - java is usually too abstracted from the hardware to exploit these benefits.


I'd guess that speed is still the issue. Cross platform is going to be an issue isn't it since you don't know what 3d card is available when you write the code? Does java have anything to support auto discovery of 3d capabilities? And I'd guess that there are tools to ease porting a game between the wii, xbox, and ps3, but expensive I'll bet.

The ps3 has java, via the blue ray support. Check the bd-j site.


Even games written on the .Net platform are often highly optimized for speed like direct access to memory and bus. .Net allows to use C / C++ and mix it with higher level languages such as C#.

Game development studios often work close together with hardware vendors, which do provide access to low level interfaces of their products. This is a world, where you have to use ASM and C for device communication. A virtual environment would slow down these program parts.

Anyway, modern 3D games in fact do use higher level languages. Often, you'll find the game logic written in languages like Lua or Python. But the core (I/O, threads, task scheduling) of the typical 3D game will be written in low level languages for the next 25 years or as long devices do not allow abstraction and virtualization by themself (which will come).


I agree with the other posts about leveraging elements of a preexisting/licensed codebase, performance, etc.

One thing I'd like to add is it's hard to pull nasty DRM tricks through a virtual machine.

Also I think there's a hubris component where project managers think they can make stable/reliable code with C++ with all the perks like having absolute control over their tools and resources, BUT without all the negatives that complicate and bog down their competition because "we're smarter than they are".


Runescape by Jagex is written in Java, the "video game" tag might not specifically apply it being an on-line game, but it does have a decent following.


It was talked about it a lot already, u can find even on Wiki the reasons...

  • C/C++ for the game engine and all intensive stuff.
  • Lua or Python for scripting in the game.
  • Java - very-very bad performance, big memory usage + it's not available on Game Consoles(It is used for some very simple games(Yes, Runescape counts in here, it's not Battlefield or Crysis or what else is there) just because there are a lot of programmers that know this programming language).
  • C# - big memory usage(It is used for some very simple games just because there are pretty much programmers that know this programming language).

And I hear more and more Java programmers that try to convince people that Java is not slow, it is not slow for drawing a widget on the screen and drawing some ASCII characters on the widget, to receive and send data through network(And it is recommended to use it in this cases(network data manipulation) instead of C/C++)... But it is damn slow when it comes to serious stuff like math calculations, memory allocation/manipulation and a lot of this good stuff.

I remember an article on MIT site where they show what C/C++ can do if u use the language and compiler features: A matrix multiplier(2 matrices), 1 implementation in Java and 1 implementation in C/C++, with C/C++ features and appropriate compiler optimisations activated, the C/C++ implementation was ~296 260 times faster than the Java implementation.

I hope you understand now why people use C/C++ instead of Java in games, imagine Crysis in Java, there would not be any computer in this world which could handle that... + Garbage collection works ok for Widgets which just destroyed an image but it's still cached in there and needs to be cleaned but not for games, for sure, u will have even more lags on every garbage collection activation.

Edit: Because somebody asked for the article, here, I searched in the web archive to get that, I hope you are satisfied...MIT Case Study

And to add, no, Java for gaming is still an awful idea. Just a few days ago a big company that I will not name started rewriting their game client from Java to C++ because a very simple game(In terms of Graphics) was lagging and heating i7 Laptops with powerful nVidia GT 5xx and 6xx generation video cards(not only nVidia, the point here is that this powerful cards that can handle on Max settings most of the new games and can't handle this game) and the memory consumption was ~2.5 - 2.6 GB Ram. For such simple graphics it needs a beast of a machine.

참고URL : https://stackoverflow.com/questions/1034458/why-are-only-a-few-video-games-written-in-java

반응형