Why is Java not used much in video games if it's apparently very fast?

Why is Java not used much in video games if it's apparently very fast?

Attached: java_logo2.jpg (660x406, 28K)

Other urls found in this thread:

graalvm.org/
techempower.com/benchmarks/#section=test&runid=60fab9eb-a5ad-49cb-aefe-24ad0f377122&hw=ph&test=db
sites.google.com/a/athaydes.com/renato-athaydes/posts/a7mbnative-imagejavaappthatrunsin30msandusesonly4mbofram
twitter.com/NSFWRedditImage

It isn't fast.

does java even have anything like unity?
ur wrong

because people who want to make games dont dedicate their lives to java

It isn't fast. It has to go through another language before it gets to you.

>what is minecraft
It is used in best game ever
>trivial to modify
>open and infinite world
>do whatever you want in it
>you can even make a fucking computer inside a game!
You don't need any other game

Can consoles run java code?

From my understanding games are usually done in C or C++ because that's what most engines are made of, these lower level languages allow you to access the hardware which is very important in video game development. There aren't virtual machines in consoles either so even if you made a game in Java for Mac, Linux and PC, if you were thinking about eventually porting it to consoles you'd need to rewrite it, might as well just use C or C++ from the get-go. There's also little to no support for Java in DirectX.

Attached: Ftfy+_140e3ac1f6ee7b8f514704ccd53b649c.png (510x763, 100K)

Minecraft loads like ass in the (((current year))). It used to render pretty well, what the hell happened?

Because one mark-and-sweep of a garbage collector can take a long time, to the point where you're notice while playing the game. You need deterministic memory management for games because memory allocation is computationally expansive. And Java JIT optimizations require time to realize their full potential, that's why it's best suited for servers running for a long time.

Microsoft rewrote Minecraft in C++ to fix the issue of Java.
That's what Minecraft: Windows 10 Edition is.

it's very memory heavy for what it offers which isn't great for games but the bigger issue is that there's no solid fast 3d libraries for java unlike c++ where people fall over themselves trying to offer you fast and fully fledged game engines
it's also not helped that the only major java games have been complete amateur hour dumpster fires

Quality rebuttal. I especially like how you backed up your claim with facts and evidence.

Attached: Fast Java.png (661x1703, 225K)

Isn't that just the mobile version?

and now its shit for modding which was the best part of minecraft

Because using the JNI is worse than Chinese water torture.

Nope.

That isn't C++'s fault, it's Microsoft's.
Those fuckers formatted everything with the intention of lack of modding in mind, I can feel it.

All the fast is lost the moment anything that has to to with graphics comes into play.

>MS bought product for 2500 millions
>MS rewrites everything in C++
Doubt that. Probably only their mobile version.

except it kind of is because in java we have the launch wrapper which allows us to have class transformers that modify the code at runtime and multiple mods that modify the same method can play well with each other

Not the guy your replying to but the performance of Java is mostly noticable in long running programs where the JIT can C2 optimize to tier 3.

Making these types of comparisions is pointless cause its not where Java shines.

nobody cares about that java-specific implementation of code modification, there are a plethora of ways to allow modding/extension

it's true, they rewrote it with c++

I'm not the guy he originally replied to, I was just making a point that he replied to an unsubstantiated claim with another unsubstantiated claim. Java's biggest problem, for me at least, is the fucking memory usage.

>they don't mind shelling out 2.5b for the ip
>the couple of milions that would be needed to make the game run faster and simplify porting (which they needed to do anyways) is somehow a huge sum

C# uses a virtual machine and it can easily be ran on a variety of devices including consoles (xbox), there just isn't a push for Java to be used for games, because Java was designed with security and reliability in mind, not necessarily speed. Java has more uses in creating enterprise software, and use in embedded systems.

There just aren't that many game engines in Java.

I mean, C# is used a lot because of XNA and later Unity.

You can make games with Java just fine, just use Object pools to avoid the overuse of the Garbage Collector. Games are mostly GPU dependent anyway.

Anyone here try Heaps/Haxe for games?

it is fast.but because of the garbage collector AAA games would have micro stutters all the time and believe me it gets fucking unplayable.

>b-but unity is using c#

yeah and your c# scripts are compiled to native binaries when you deploy.

10-20 years ago people had mostly really shitty computers, jvm wasn't as optimized. So making 3D game in java back then might not have been feasible.
People have now way more processing power and memory to use and jvm is more optimized and graphical APIs have generally improved.
Using java for games is fine but people still spout the old belivieing that you have to use c++ (right after that they will try to shill some c# engine for some reason).
Lot of the games now days are mostly in some scripting language like Lua on top of some engine.

There is jmonkeyengine which is pretty impressive or you could use some C++ engine like Ogre3D, I'm pretty sure java has bindings for it.

This is fucking Microsoft man. They program exclusively in C++, C#, and Assembly.
They would do it purely for the ease of the language they are comfortable programming in alone, not to mention using "C++ executes faster" as an excuse to rewrite it.
Microsoft doesn't care.

I think managed languages are the future and did choose against java for gamedev, because .NET has more features eg
structs to better interact with C-Libraries like OpenGL., unsigned integers and many more. Java is just too conservative and forces you into a single paradigm business language style.

Java is fast. Very fast in fact. The JIT optimizations make it close to C in speed, making comparisons like stupid because they aren't run with "pre warming" of the JVM.

ALso Java can be used in games without problems, for example Minecraft and Slay the Spire are written in Java.
Why is it not popular? Because of memes. Java wasnt always fast, so making games in Java only really has been possible since ~10 years ago. By then every game dev was already writing stuff in unreal engine and c/c++. New game devs learn from old game devs, repeat ad finitum

Attached: c92.jpg (500x500, 98K)

they wrote like half of it, and left the rest as a buggy mess

agreed.
if java could add more modifiers to actually help make things not a bloated mess (ie, a class modifier to NOT add a lock to every object etc, a method modifier to say "don't bother with a stack, compile this in-line") shit like that should exist in languages today

java is fine for a lot of stuff but garbage collection causes a lot of headaches for games. you get similar issues when working with unity/c#

Unity is fine though, and so is Java. Just think of all the mobile games on android. GC being bad is again just an ancient meme

Shit gc
java 10's gc might fix this.

GC has its ups and downs.
If we could manually split up memory pools, and have their GCs run at different times, that'd stop the stuttering effect seen in large java applications

Didn't know slay the spire was made in it that's neat. Minecraft runs like shit but that's probably more to do with notch not knowing how to write good code

yeah i mean historically it is why there was never must growth for gamedev.

Surprised me too, but its true

Attached: explorer_2018-06-04_23-28-34.png (605x324, 24K)

GCs are not optimiced for soft real time applications but for business applications. If your game is not demanding you wont notice, otherwithe the stop-the world GC will shit on your perfectly planned 16ms frame all over, because it knows what's best for you.

to be fair, the c++ version does run much faster than the java version, but in practice this is not relevant for anybody that isn't running a low spec hardware configuration. It really made developing for the game quite a bit harder. Most devs had used java for quite some time for their projects, so they were pretty comfy in java and most of the other systems they were using were dependend on java as well(other plugins/mods). This push of the c++ version also divided the playerbase, leaving the devs with the hard decision for which system they should write their mods/plugins. What made the situation even worse is the fact that minecraft as a game is and was heavily depended on altering the game. Most people who actually play the game for noteworthy amounts of time will play on a multiplayer server which is most likely not running a vanilla version of the game. Mojang already didn't really care about these servers, but microsoft brought this systematic neglecting on a whole new level.

Java is considered a "fast" language since it's not that much slower than c++/c in most scenarios. In some special cases it's even faster(due to better automatic optimasation). But in general you could say it's roughly half as fast. That said the only way java can archieve this "good" performance is by having a better default optimisation (due to the jvm i.e.) which can reduce the disadvantage the jvm is performance wise. But once you start to properly optimise your code c/c++ will run much faster then java. Since most games are highly optimized and even a 20% increase in performance would be a considered a great improvement, something like java that might (generoursly) only deliver 25% of the c++ performance would basically never be used for anything that isn't a one person homebrew game.

Is there anything Microsoft doesn't ruin?

>Because of memes
definitely nothing to do with garbage collection, existing APIs, multi threading capabilities, etc etc, it all came down to memes like this genius said

until you start writing java programs built on native functions and then you have something going

woudn't that basically destroy the os portability of java?
also graalvm.org/

High throughput but also high jitter. Fine for servers, not videogames.

I don't need this boner right now

>It really made developing for the game quite a bit harder. Most devs had used java for quite some time
This is literally a moot point. Obviously people who are used to doing things one way are going to struggle doing things in a different way.

It's true though. Java not being used much for 3d games has mainly to do with momentum of C/C++ and not java not being able to do it.

>Obviously people who are used to doing things one way are going to struggle doing things in a different way
It might be obvious but it's still true and valid. When i've used c for 5 years straight i wouldn't want to start using javascript for basically the same project which i could continue to write in c.

nope, java is to slow. even 50% less performance are not acceptable in high optimized software like computer games. You can't sell a lagging game and if your game has terrible graphics it'll most likely not sell very good.

Java is only fast when you provide it like 5 times more memory than needed, otherwise GC will destroy everything. Java using more memory for literally everything isn't helping it either.

>implying I care about performance and framerate in my EROTIC GAMES

Name 5 3d erotic games.

I've read great things about LibGDX. I think it's good for 2d games

Except java doesnt do 50% less performance, also you can write games that sell that arent heavily graphics dependent.
Factorio, Slay the Spire, Starbound and any metroidvania aren't depending on graphics and sold a lot, and one em is even written in Java. That's not even accounting for the mobile game market on android which is also largely written in java

It is, slay the spire was written in it, Ingress too

>mobile gaming
Unity i.e. uses c#

Yes, we know that. Whats your point?

C# is used for more games now than C.

How does it compare to LWJGL?

minecraft is slow and inefficient as shit

It was also written by not the best of programmers. Still made billions.

libgdx is a framework, mainly focused on 2d games I think
LWJGL is a library, lower level, but also more powerful in the sense that it provides access to vulkan

sun badly mishandled java and killed on the desktop and browser

notch hasn't worked on the game for 7 years now. he isn't a bad programmer, but minecraft was pretty much a hacked together prototype that unexpectedly blew up. it's actually gotten quite a bit better as far as optimization goes in the past few years

Not everyone has JRE on their PC (also fuck JRE)

remind me the relevance of a good business idea, to the performance of the java platform

Attached: 1512734426741.png (645x729, 62K)

it's actually decently usable for gamedev if you aren't rewriting UE4 or some shit. design-wise it probably isn't the best approach and there are better tools out there, but speed is far from being its biggest issue.

runs fine if you aren't a speclet, my other pc, a stock optiplex from 2007, can run the game just fine. if you're using anything worse than that then you have other issues

if you want some more comparisons, look up videos of thebennybox's old game engine (not his recent one) where he compares the performance between the c++ version and the java version. the c++ version is faster, but the difference is very negligible. i've since moved on from java for gamedev but i wouldn't say it's unusable or anything, most brainlets writing 2d indie games don't really need anything better.

Garbage collector add latency make game get irregular FPS,no manual memory mananger avoid high level optimization, JNI isn’t good to full support zero overhead API like OpenGL,Java has bad support for Vectorized instruction.

A bag of peanuts could run java
They did that to bring it inline with the whole cross platform Minecraft.

it's fast in throughput but it sucks when you want to avoid pauses longer than 6.94ms.

Java isn't necessarily any faster or slower than a non-VM language, but it sure as shit uses more memory

>Java is fast. Very fast in fact. The JIT optimizations make it close to C in speed

Attached: 1527556003230.jpg (640x628, 114K)

C# can be run on Xbox because Xbox has msil support, because it is a Microsoft device. There's a reason why you don't see unity games on PlayStation and switch, like you would for unreal.

techempower.com/benchmarks/#section=test&runid=60fab9eb-a5ad-49cb-aefe-24ad0f377122&hw=ph&test=db

sites.google.com/a/athaydes.com/renato-athaydes/posts/a7mbnative-imagejavaappthatrunsin30msandusesonly4mbofram

>java is bad at this practical benchmark so it's not a valid metric

It is not a practical benchmark though. Unless they prewarmed the JVM those results are simply wrong. The JVM compiles often run code down to machine code, which makes it a lot faster If you run the program only once you won't see this speedup unless you are using GraalVM or something like Excelsior JET

It use a LOT of memory you don't have when doing a high profile game.
Minecraft can easily eat 3gb+, while the C counterpart (minetest) barely break the 500MB barrier.
That would not fare well at all for a triple A title trying to fit itself in the tiny console memory.

Look at this boomer, everyone.
He doesn't know Minecraft has been rewritten in C++ after Microsoft bought it.

And that somehow makes it not written originally in Java?

thats a different version that no one cares about

you mean that version that was slow as shit, because it was made in java?

OP said "without problems in java". It was literally rewritten to fix those problems. Therefore, user is correct, OP is fucking retarded.

True tbqh, his point still stands though.

>True tbqh, his point still stands though.
No it doesn't, because the main fork of MC is still running in Java.

yfw you learn that the JVM was written in C++

Attached: sleep.jpg (1603x1136, 94K)

I'm not very familiar with it but I'm assuming it's because the garbage collector's performance is not determinable enough.

It's extremely fast.
But it has poor support for native rendering (DirectX, SDL, OpenGL, etc.) which is why it's not used for video games.

Also, the GC used to be a problem for soft real-time applications like video games, because it would 'stop the world' (a bit of a problem when you are rendering things 60 times per second).

Nowadays you could probably write a decent game in Java, because most of the stuff happens on the GPU anyway. But you'd need a good interface between Java and the GPU, which does not really exist (there is some stuff in JavaFX, maybe).

They are rewriting it in Java. It's called the Graal VM.

It's true. In fact it can be faster than C/C++ because the JIT can infer more stuff at run-time than you can do at compile time (profile-guided optimization, more aggressive inlining, more aggressive use of specific CPU instructions that may not be available on all chips, etc.)

Minecraft is not a very good example because it's a software rendered app, where CPU speed is very important.
But most games are rendered on the GPU, where stuff is written in shader languages anyway (GLSL, etc.)

>Minecraft is not a very good example because it's a software rendered app
No it's not.
It is actually the main reason why companies like intel have to make a half decent Open GL support.

GraalVM still runs on top of JVM though.

See
LWJGL allows access to vulkan and opengl, making modern 3d graphics entirely possible. Reason why you dont see it in big games is because its not a beaten path to make a game this way.

Actually the JVM only uses as much memory as you give it. If you don't specify a maximum for heap memory it will take a % of your available ram, which can be a lot on modern computers.
Just no i started one of my heavy optimization programs, without -Xmx jvm flag it uses 1.6gb, but if I set -Xmx512m memory usage never goes above 400mb, execution time is the same

>doesnt understand why java is considered slow
>graphical APIs arent really the issue, java has had ogl API forever anyway
>c# engines being shilled are usually written in c++, eg Unity
>the fact most engines implement a scripting language for high level logic is irrelevant to what is being discussed
>ogre3d isn't a game engine, it's purely rendering