Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Why are there no "High Graphics 3D games" made with Java on the market? Isn't Java a good option? And why so? The only big game i've seen is basically Minecraft, and there can't be a large amount of polygons and lighting/physics-engines in that one. Still a relatively good pc is needed? There are games incredibly more graphics heavy than Minecraft and stills runs faster. I suppose Java "wastes" resources. Anyway, the question is: Is it possible to make good graphics application with Java, or why not.
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.
The truth is, there's rarely that much incentive in switching to
.NET/Java/anything other than 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).
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.
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).
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).
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.).
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.
As far as commercial games are concerned - does RuneScape count?
That may well be the most succesful Java game out there.
Source: Why are only a few video games written in Java?
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I've been testing with AndEngine for months, but still haven't produced any game prototypes. There are few reasons why I want to switch to libgdx:
- AndEngine is using libgdx's INI wrapper for Box2d, but updates reach Andengine slowly
- I'm primarily targeting Android, but having option for easy porting to other platforms could come handy
- Documentation! AndEngine has absolutely no documentation, except for examples.
- I would like to get as high performance as possible and that seems easier on libgdx.
Few things I am concerned about libgdx is that I will need to write lower level code and that development for full game will take longer? But then again, sometimes I lost few days to understand how some parts of AndEngine work, so is it possible that I'll even write code faster with libgdx since it's fully documented?
What should I be aware about libgdx before switching? What is main difference when coding game and designing code?
You should be aware of the following things:
It is more performant, thats a fact and widely known. Libgdx uses
native code for the more difficult tasks.
Development on it is very fast, I dont get why (some) people say it
takes a lot of lines to do simple tasks, thats simply not true. The
library is very high level with the possibility of programming as
low level as you would need. Especially the ability to test on
desktop immediately, instead of waiting for the app to deploy to an
android device or worse... the emulator. That makes the development
time way faster.
The library gives a lot of freedom, you can make the things as you
want it. For example I made a template that I use for every new
game, that makes things even faster for me.
You dont have to know opengl, androidsdk or lwjgl, actually you just
need to know the abstractions of the library. But you can make
platform specific code if needed. And thats well documented.
complementing P.T. point, libgdx has a wrapper for box2d physics and
bullet (3d) physics which are pretty easy to use (except bullet :S
nah kidding). And I would say, the new 3d api is almost complete,
not much will change for the next stable release, I even read on irc
that it is pretty much done. I use it and can tell you its very easy
to use.
In conclusion, Libgdx is a very fast library to develop on. Its very performant, and complete. Has a good and helping community, plus great documentation. I would recommend you to change :)
Both P.T. and Lestat make very good points in their answers. But for me, I think there is just one thing that you need to know about libgdx, which is simply that libgdx is a toolkit not an engine or framework. This one fact means that you are not locked in to a particular way of doing things. If you want a micro-framework, write one with libgdx. If you want to write "Unity 2D", write it with libgdx. If you want to put everything in one file, throwing object oriented principles to the wind, you can do that with libgdx.
It helps that it is well documented.
It helps that it is fast.
It helps that it has a strong, knowledgeable community.
It helps that the source code is available and is well-written.
It helps that it comes with examples.
It helps that it is a platform abstraction layer so the same code will run on multiple platforms.
It helps that it is actively developed.
But fundamentally it is a toolkit, albeit an excellent one. What you choose to do with that toolkit is up to you.
If you're having problems finishing prototypes, I would concentrate on the usability of your tools (over performance, for example) to produce prototypes. So, the speed of updates to Box2d shouldn't be important (its in a good enough state). The ability to do development on your desktop should be important (build/test time is much quicker) without an Android device in the loop. Documentation and examples should be very important. High performance does not matter on a prototype that is never completed. Worry about that later. (Goal #1 should be completing something.)
Libgdx has a broad set of libraries and wrappers, mostly around graphical APIs (e.g., Scene2d, or SpriteBatch or the TiledMap infrastructure). There is a 3d API, but it is still moving pretty quickly, and not yet a stable place to develop on. I want to say that it doesn't have a lot of "gamey" abstractions (though it does have some), but I really don't have enough experience with other higher-level libraries to compare.
Instead of trading your current tool's short comings and pitfalls for a new tool's shortcomings and pitfalls, you are probably better off sticking with the tool you know.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm thinking of writing a game. It's inspired by Minecraft/Terraria (but don't worry it will be different).
My main question is what language I should write it in -- it'll be relatively simple graphics, more like Terraria than Minecraft. I know Java relatively well and Minecraft is written in it, but C++ seems like the industry standard for game development. However, I know next to no C++. I'm willing to learn but am worried how it will turn out for my first real project in the language.
In addition to that, I'd also like suggestions on a good game engine for the language that you suggest. I'd like it to run on:
Windows for sure
Linux for sure
Mac for sure
Android would be really nice
iOS is optional
Thank you in advance!
C++ is the "industry standard" by heritage, by FUD, and (marginally now for 2D games) for performance reasons.
On the plus side for C++, you'd have more graphics, audio, and input library support. Java doesn't have a lack of these types of libraries, but C++ has a glut of them.
On the negative side C++ is one of the least beginner-friendly languages out there, and even though there are multiple cross-platform libraries for it (e.g. SDL), it is not a cross-platform friendly language.
If you are more interested in spending the majority of your time making a game rather than a game engine, then I'd recommend you either write your engine in a higher level langauge, or use a pre-existing game engine and just script on top of it.
If you are more interested in spending the majority of your time making a game engine rather than a game, then maybe you should focus on making graphics demos, physics demos, or game content creation tools instead of games. Those are all more directly applicable to learning what features a game engine would need to support and how they are implemented.
If you decide you must program both the engine and the game, you may want to look into embedding a scripting language into a C++ engine (such as Lua). This is a very popular approach, taken by most games that support modding. You don't have to support modding to use a scripting language, but most moddable games support modding through a scripting language.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Since Java supports OpenGL, what is the best option for developing a game?
Java + OpenGL
C++ + SDL + OpenGL
I always avoided Java (in game development, of course) because of it's speed. But, I discovered that Java supports OpenGL. So, I think speed can't be the problem anymore. What should you choose? Are there remarks?
Java would be a lot easier for me, because of my experiences in Java and the garbage collector.
In my opinion, if you have an idea for a game in your head it doesn't matter what you write it with (at first), C/C++, Java, pen & paper... Pick the language you're more comfortable with, prototype and test your game idea, once you have a rough sketch and know what you need to do, throw the prototype out, design the gameplay & architecture and then start coding the actual thing. Don't optimize until after you've got most or all of the functionality working (in general, there's always minor bugs to hunt) and you actually see where the bottlenecks are.
I've seen it happen over and over again, game programmers are among the worst premature optimizers ever, trying to squeeze out a few cycles from something trivial, while missing the biggest bottlenecks and then optimize some more (in the wrong place). I've also found myself guilty of this many times. I'd say don't pick C++ (or Java for that matter) because of the speed, you can get very good performance out from both, if done "right". If need be, you can always switch to another language, if the language itself is really the bottleneck or really preventing you from doing something. Java isn't automatically slow and C++ isn't automatically fast, you can go (very) wrong with both. I used to root for C and C++ in everything, but after having worked with Java for quite a while, I really don't miss all the hassle that much.
There are lots of (already optimized and fairly easy to use) game engines available for both languages, so there's no need to roll your own... unless you really want to. In my experience, most hobbyist "game programmers" tend to be more interested in the technical side of things than in the actual game (myself included) ;) Once all the technical hurdles are done and you get that nice model/bunch of sprites/particle effects running with some shader-effects, the enthusiasm seems to fade away... But don't let me discourage you, game programming is very fun, even if you never actually finish anything (I wouldn't call any of my own projects finished).
I haven't coded any games for a while, but for C++ 2D SDL is a good candidate, other option could be SFML, or if you want a lower level touch with OpenGL, you could try going with GLFW + SOIL + some audio library. For full-blown 3D, I'd say try either OGRE or Irrlicht + Irrklang (there are probably loads of others too).
In Java, there's at least Slick2D, Golden T Game Engine and for lower level access, LWJGL (although I think you can access LWJGL via Slick2D also). For 3D, someone recommended jMonkeyEngine to me, but I've never tried it.
I would vote for C++ for the simple fact that you have a dependable destructor in your objects. This lets you wrap many of the OpenGL components (buffers, textures, etc.). You can know that when the object is created, the asset is allocated, and when the object is destroyed (or goes out of scope), the asset is cleaned up.
It certainly can be done in Java. Minecraft was made in Java, and it has pulled in over $25 million.
Java has been proven to be just as fast if not faster than C++, though granted, you don't achieve such results without a little parameter tweaking and careful monitoring of the garbage collector. If you want to pursue game design with Java, I'd say that's a good choice to make, provided you study up on how to approach it first.
I'd go with C++, SDL, and OpenGL.. SDL is getting revamped with 1.3 at the moment, and it will be really good. In my opinion you should do it in C++ as you have stated you would feel more comfortable with Java, being comfortable after making a game in C++ would be very beneficial. You would not only make a game, but learn more at the same time.
If you go down the Java route you may need to ship the JVM along with your game. That's not to say don't do it but many people may not have Java installed or not have a recent enough version for the features and performance that you want. I haven't looked into the licensing requirements for shipping the JVM but that's probably something you'll want to investigate before making the decision.
You should also be aware that when highly tuning an app that although the Java API is the same across platforms that there are differences because the implementations of those often use the underlying OS. So I doubt that using Java would reduce the test burden at all for a game.
It really depends on what language your most used to. There's a steeper learning curve with c++ than with java. If you not into none of the languages, and is eager to get some development done I would recommend java.
And a little side note. If you totally new I would also recommend looking at XNA, but it's based on DirectX. And you have to know some C#.
Well I've programmed all my games in SDL and I would definitely recommend using c++. Though you may want to look at SFML!
http://www.sfml-dev.org/
SFML is already integrated with OpenGL, and it's fairly easy to get up and running with game programming.
It really depends on what kind of games you want to build and which programming language your more comfortable with.
If your planning to make big games in the future , C++ is best for overall experience. Most commercial games are written in C/C++. Microsoft also has XNA framework which uses C#
Id still go with the programming language your more convenient with, they are both great
However, if you dont mind learning a bit more then go with C++
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is it possible to do GPU programming in Java ?
I mean without using native libraries.
And how much of a performance improvement can one expect when we switch over to gpu's ?
Edit:
I am not looking at game programming, I want to do hard core number crunching.
Yes. Java3D, LWJGL and JOGL support GLSL (OpenGL Shading Language).
Edit:
You can use OpenCL if you want to do platform-neutral, general-purpose computation on GPUs. This framework lets you write code that treats all processing units identically, despite wildly varying feature sets and execution environments. Though, this is very low level programming compared with Java.
It seems your ideal would be a JVM written with OpenCL support. Searching online, I found a little bit of interest in the idea but no evidence of any major backing.
how much of a performance improvement can one expect
That depends on the system you're running on and what sort of data you're processing (Matrix and vector math is extremely efficient on GPUs). You'd likely get some major gains on a system like mine with two powerful GPUs and a modest single-core CPU. However on a computer with a modest GPU and a quad-core CPU, the performance gains might have a hard time overcoming the overhead.
Rootbeer1 has just been released on github: https://github.com/pcpratts/rootbeer1
With Rootbeer you can program using almost any Java except the following:
native methods and fields
reflection
dynamic method invocation
garbage collection
sleeping inside a monitor
This means you can use arbitrary object graphs with composite types.
If you are still considering hard core number crunching in Java on GPU without using native libraries, you might be interested by this blog article http://ateji.blogspot.com/2011/02/java-on-gpu-with-ateji-px.html
We (I am part of the Ateji team) have seen performance of up to 60x so far on Java applications that can be massively parallelized.
def check out rootbeer1, but you need to make sure you have a CUDA accepted GFX card first before you start on it and have done all of the NVIDIA setup etc
download Link:
google CUDA download
getting started guide
http://developer.download.nvidia.com/compute/DevZone/docs/html/C/doc/CUDA_C_Getting_Started_Windows.pdf
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I understand that C++ is generally considered better than Java for games (at least larger-scale games). Why is this?
What is keeping Java from being competitive in this field? Which reasons against using Java for game programming have the most basis, and which ones are myths?
EDIT: Am a bit unfamiliar with C/C++, and did not think to differentiate between the two at line 1 >.<
The reason Java (and C#/.NET) is not a viable option for AAA titles at this point is the established game engines and their toolchains are written in C++. Game development is all about getting a title on the market in the shortest amount of time, and budgets don't allow for piddling in things like a new language/engine when several are already available, work well, and have an extensive set of editors and tools backing them.
Moving to Java (or C#) would also require a new performance-driven JVM (or CLI) across the big-3 (PC, X360, PS3) or big-5 (add Wii, iPhone). It's technically doable, but not financially viable.
Edit: Anyone with low-level knowledge of both virtual machines and the current state of game engines can tell you that a JVM or CLI could unquestionably be implemented with a new game engine to beat the performance of current C++ engines. The preventing factor is time and money, nothing more and nothing less.
High performance and the inertia of C and C++ traditionally being used for games.
Choosing based on performance isn't that big a priority unless you are making a 3D extravaganza.
Because:
Java is not compiled to native code, meaning that there is a performance hit the first time the code is run.
Java does not give you a predictable memory model (console games need this)
Java does not give you deterministic object finalization.
Java is not as close to the hardware as C is, an essential for a lot of professional 3D game programming.
Console programmers likely don't have a JVM that runs on the PS3, X-Box, etc.
Runtime performance penalties.
You will never be able to squeeze as much performance out of a Java app as you can with a C++ app.
There are probably more reasons, like the fact that they are using pre-existing code that was written in C or C++.
EDIT: As an aside, I don't think that many modern games are written in C. OOP lends itself to game development, and C++ is the de facto language of choice.
Also, I won't add it to my list, but as others have mentioned there is a lot of pre-existing code that works very well that is used in the game industry. It would not be practical to rewrite all/most of your tools just to switch to a new language especially when that switch could cause you a lot of headaches.
I would say, despite the other answers pointing to a lack in speed caused mainly by the JVM, that the real reason people don't code games in Java is the lack of support for environments such as DirectX and OpenGL (which actually remove the need for your code to be close to he hardware as it was suggested by some answers). They are the base frameworks that people generally use to code games, especially nowadays with 3D games being everywhere - and lack of support for them is the reason why Java is not considered as a language for game development.
To emphasize my point, I would suggest you take a look at Microsoft's XNA which is currently optimized for coding in C# via the .NET framework (which like Java is Just-In-Time-Compiled and doesn't run natively per se). The XNA framework interfaces with DirectX which talks to the hardware and so it is very fast.
EDIT
#Ed Swangren's comment made me realize yet another distinction between .NET vs Java when considered for game development. I think another strong point to .NET is that if you do need to be able to squeeze out that last bit of performance and do some pointer math or implement a sophisticated high-performance algorithm it's a lot easier thanks to the unsafe mode. Of course you can even go beyond that and write native libraries to be used by your C# code which is made pretty simple thanks to P/Invoke.
Leaving C(++) aside for the moment... I am inclined to say much of the reason is that Java lacks anything like XNA. What advantages does Java actually have over a language such as C++ when it comes to game development? You have to consider that several of it's typical advantages disappear for the specific area of game development, while C++ gains several.
XNA is what made C# a highly popular language for amateur game development, and contrary to common belief, a quite viable option for commercial development too. C#/.NET being a parallel to Java in so many ways (and arguably a better framework nowadays), when people now have the option for game development with a higher-level language, C# would seem like the much more appealing one, unless cross-platform support is essential (then again, we have Mono and OpenGL for .NET).
C (or rather, C++) has long been the language of game development due to their low-level nature (thus performance benefits) and the host of graphics frameworks (DirectX, OpenGL) and engines that primarily target them. It's usage is embedded in game development and been used virtually since the inception of the industry - and won't disappear any time soon, I suspect.
Java doesn't have as controllable performance
Its highly reversable so harder to protect
Many Games employ scripting languages like lua or python to get "higher" level programming
the API of most systems is C oriented.
Java can be used for back end server systems that games connect to
Flash games seems to of taken the niche Java games could have had.
Java can be optimized to be very fast, as is evident by an interview I had recently with a high-frequency trading company, where they do use Java, as well as C++.
Java has OpenGL bindings, as others have pointed out, so getting to the hardware isn't such a problem, esp since not all games need that, some commercial games have been written for Java3D.
You can use Scala or F# if you want some more performance for multi-threaded or numerically intensive operations, and just tie those in with the GUI.
But, as others have mentioned, the tools that are used tend to be written for C++, and some companies feel more comfortable doing some optimizations in assembly, but, given the fact that the new cpus are very complicated, with multicores, it is unlikely you will get any performance increase over the optimizations from the compilers, but, as long as companies feel these optimizations are still needed, they will stay with C++.
If some developers wanted to write commercial-grade tools for Java or .NET, there could be a market opportunity there, but it will be a great deal of work to make it as good as what is already out there.
I think C or C++ is a better language for building many types of games because it is closer to the hardware and likely to be the first language implemented on any new hardware. Not only that the libraries for accessing many of the advanced features of today's hardware are likely to be implemented in C.
Your typically general purpose higher level language has no easy way to access features of the hardware unless it uses some type of binding layer to call the libraries which are written in C.
For instance how do you write code to access a GPU, or write a custom Shader, or write code that run well on a Cell chip, or run on an Iphone, or on a Blackberry in a high level language. Even when these things are supported, they come out well after other people are able to write games in C that use these features in games.
One compromise you can make is to use a higher level language like Java for most things and C where its needed. You will limit the types of platforms you support though.
Java might also be good for client/server games where the server is written in Java.
It's very hard to write a program that runs in constant memory without garbage collection in Java.
If you want to read statements from game studios who are happy to use java for serious game development then search on twitter for #javaforgames
https://twitter.com/search?q=javaforgames
By studying the Java developers tweets conclude that Java is good for game development if you use it in combination with a high level game engine API such as libgdx and jmonkeyengine that both ease development effort and makes the game tuned to take advantage of the OpenGL/ES hardware acceleration provided by modern GPU hardware.
Java do allow cross-platform goals using said engines on mobile, console and desktop.
Some game developers prefer java for the design phase of the game to engineer in-house tooling.
Java game studios and developers who seek the best performance can archive it by tightly controlling OpenGL by using JOGL or LWJGL directly. Also performance and flexibility archive this by writing their own engine, if time and money allows it.
I wouldn't say that it is always true that C is better than Java for game programming.
For example, if you want to write a game client which can be hosted in a web page, Java could be better.
When writing games which produce amazing 3-D graphics (e.g., Halo on the X-box), usually there is barely enough computing speed to generate all the pixels for each frame. In this kind of game, C would be preferable to Java because it allows the programmer to write faster programs -- at a large expense in terms of difficulty in extracting that speed.
I think it's mostly because c lets developers squeeze every last little bit of performance out of hardware, whereas Java doesn't, it's not low level enough for things like high end 3d video renderers. Basically c lets you squeeze out a couple more frames per second in your next gen shooter.
Inertia mainly... Although it's a bit old now, you can look at Jake2 (which is a pure Java port of Quake 2 with jogl as the openGL lib).
It can perform up to 85% as fast as the C++ original, which means it's fine for most games; especially modern ones which are more social and game play based rather than the limited "hard core" games.
I'd also suggest that most of the answers you get here are coming from a gaming geek/"I want the coolest hardware and games". For [these] hard core 3D games and gamers, that final 15% is hugely important, as that's what separates the $150 graphics card from the $500 one they just bought.
As John Carmack is reported to have said (something along the lines of): "If I were to enter games programming now, I'd program for the iPhone". e.g. it's not nearly as much fun to make the fastest game with the best 3d engine as it is to make the best game.
The console game market is about 10X larger (financially) than the PC game market. For current generation consoles, all the major programming is in C or C++ with some little bits of intrinsics or assembler. If you want to be a professional Game Programmer and work at any major game company, then learn C and C++.
More to the point, all the commercial cross platform engines that are that starting points for many commercial games are in C or C++ right now as well.
You may be able to work on small games in java and flash or even casual Windows games in C#. You can even code C# for XNA games but if you want to make REAL (pressed on DVD) XBOX 360 games you need to learn C++.
Speaking as a game developer at WBGames Chicago. We would not hire a programmer who didn't have strong C++ skills. The same is true at every other game studio that I know of.
The short answer is because almost no gaming platforms support Java, or if they do there is a much better alternative.
On the game consoles, seasoned game developers are using C because that's what they've been doing for 20 years. There's no compelling reason for Java games to exist there.
On the desktop, there are a few Java games, but they can't compete with the market leaders such as World of Warcraft.
On the web, Applets are long dead, and if you're going to make a casual game it's going to be in Flash.
In the mobile space, JME has had it's time in the sun but it's on its way to obsolescence in the face of far superior platforms such as the iPhone.
The perfect world scenario for Java to be a heavy hitter in the gaming world would be for Sun/Oracle to deliver a gaming platform like the Wii or the iPhone - a must-have device that everybody owns. Then, there is a good reason for developers to invest time into experimenting with new technology. But given Sun and Oracle's apparent lack of interest in the consumer market, the chances of them making a gaming rig are slim to none.
It's not a technical issue but purely a "client optics" issue for this.
Good Java code can run just as fast as good C++ code. It can access OpenGL just as fast as native C++ via projects like LWJGL and JMonkeyEngine.
The real reason is that Sun never put any effort into highlighting Java for games and they've never made any deployment particularly easy for Java games. It's a LOT of work and effort of the developer / team to create a seamless / smooth installation (and launch?) experience for the player.
Customers just don't "trust" Java games and bail during the install process when they see the logo.
Although old, no one here seems to point out
All the games and apps on Android are programmed in Java
Because not only is Android written in Java, so are most all of its apps/games/etc...
I will answer in a very different way.
If Java can nevre write a device driver like C, how can you Imagine that it would be faster than the language that the driver is already written in ?