Why is almost every 3d game engine written in C++ and not Java?

Why is almost every 3d game engine written in C++ and not Java?

Sure there are Java game libraries which port C++, but that's not the same thing.

Other urls found in this thread:

github.com/mirror/reactos/tree/master/reactos/dll/directx/d3d9
en.wikipedia.org/wiki/Markus_Persson
hero.handmade.network/episodes
jslinux.org/
youtube.com/watch?v=WZ_alfF5Zt4
twitter.com/AnonBabble

Game devs are fucking retards, they're not skilled enough to write their own engines, and their naivete leads them to write hundreds of layers of garbage abstractions, but hey, at least they end up with a game at the end, the skilled programmer who enjoys programming never finishes a game.

I've actually tried reading up on how to even begin writing my own game engine and there is next to zero information that is visible online

Yeah I really wonder why they're using an unmanaged language instead of a managed language that runs significantly slower

The reason C++ is used for real time systems is because it will perform reliably for every run of the program. The reason that minecraft would drop to 3 FPS for a second is because the GC was cleaning up.

Download a book

Lol Java is faster than C++

>I want a programming language that doesn't use garbage collection and takes up a bunch of system space in the background because it's not manageable
>I like downloading IDEs that are 7gb in size

You're also running through JVM, which is going to be slower than c in all instances
For Java you have to compile it into Java bytecode, which is then interpreted and dispatched to some handler somewhere that knows the translation of that bytecode into assembly
It just adds layers to every call you make

So you literally don't understand how computers work
Nice posts

C++ is only faster on Windows

C++ doesn't exist on other OSes, everything is written in Python and Perl
You know that the Linux kernel was written in nodejs?

epic troll

Both languages are terrible to write for

That being said C++ has better libraries as a general rule that have about 20+ years of development time behind them
I mean just use DirectX or OpenGL once and you'll learn the headache but also the reasons for the headache and why you would choose that headache instead of something else

I've written a game engine from scratch in Java
I'm going to exaggerate only a little when I say that there was almost 500 lines of code before we had a black box on the screen
Let alone the actual game

It comes down to the libraries
The industry adopting these libraries and sticking with them for so long
The speed of C++ vs Java is a lot less of an issue now days and Minecraft was poorly written, but it wasn't always like that...
Even ten years ago I remember it was a worlds difference

Java is an interpreted language that runs on the JVM, making it an order of magnitude slower than a compiled C++ program. Aside from the JVM, the fact that C++ programs are compiled natively for each specific platform you want to run them on means you can do platform-specific optimization in C++.

auto

>there was almost 500 lines of code before we had a black box on the screen

I'm honestly surprised it was that few.

C

Are you implying there are other languages outside of C++ and Java that could be used to create a game engine that would be a better alternative?

So much misinformation about Java. Actually read a book. The JVM is really good and can be faster than C in certain scenarios. The thing that Java has against it is that at some point, the JVM is going to stop everything and collect garbage, which is not predictable. Which makes it useless for medical equipment, low latency trading engines, planes, cars etc.

t. former C++ High Frequency Trading developer

C#

It literally cannot be faster
You are taking Java byte code, feeding it into the JVM, which is then interpreting one instructions worth, sending it to the processor, regaining execution, then sending the following instruction, etc as the process runs
These context switches are quick, but absolutely nowhere near the speed of actual assembly
It would be like running your code with eflags trap flag set, single stepping and giving an exception handler execution after every instruction

this 2bh

C#, honestly.

Allows you to directly manage your memory and avoid the GC, unlike Java.

Please describe a scenario where Java bytecode running in JVM is faster than it's C equivalent

That's kind of like asking how to make an operating system. There are so many layers of complexity that you can choose to put into your engine. That means there is going to be a pyramid of information available. Lots of stuff for basic stuff, but less and less for more complicated features.
In modern versions of the JVM it's going to be the same speed as a c++ program (keep in mind it will take a little bit longer to start and potentially warm up). The main concern about Java would be the large amount of memory it uses. If you are in 2017 you probably don't need to worry too much about ram.
Wouldn't low latency trading engines be bounded by the network connection to whatever trading terminal / whatever?
The JVM worked that way a long time ago. If I were you I would research what the JIT (just in time) compiler is.

there's a shitton of information available. what exactly are you looking for ?

Did you intentionally make a post that was completely non sequitur in relation to the current context?

like basic shit

every fucking thing wants me to install hundreds of things and know the entire language, everything about the OS, and a bunch of math

I want to know how to make my own rendering engine, the whole deal. I don't want to use any libraries like opengl or unity.

unless you have a minimum of a bachelor of cs/software eng/math or something, you probably cant anyway

Well... Yeah. That's what making an OS entails

not him, but if you'd add all shit java does(checks,garbage collection, type checking, OOP shit like dynamic binding, dispatching, etc) in C the JVM would probably be faster by default default unless you spend years optimizing your C code

nice try, elitist

I'm not falling for that rich man college abraham trickery that says because I didn't spend the school years doing the school, that I can't programming a fucking gaming engine

>going to school to learn programming
>racking up 50k in uncancellable debt to be a codemonkey

For the JIT to execute at the same speed as assembly, it would require every conditional branch to be pathed, then begin execution at the start
Then it's going to execute at the same speed as c compiled assembly, and the only differences are from compiler optimization when generating the assembly

Just use opengl. What do you want to create your own operating system with its own graphics driver with its own audio driver with your own game engine. As a developer you don't need to make everything from scratch.

1: learn a programming language
2: look into SDL
3: think about how retarded your question is
4: come back and ask a less retarded question

what have you already done/learned/used ?

>1: learn a programming language
All of it? Fuck off.

>2: look into SDL
Why? How much? Which parts?

>All of it?
no, just stop after "Hello World!"
learning a programming language isn't hard and doesn't take much time.
maybe you mistake external libraries as part of the language ? they aren't

>Why? How much? Which parts?
because it's the simplest and most basic library to start with but offers everything you'll need until you actually know what you want/need
you'll notice when you've learned enough of it.

because I want to know how it works from top to bottom

fair point.
do you already know opengl ? how's your math knowledge ? have you done any graphics programming ? how is your C and linux knowledge ?

what does Linux have to do with making a game engine?

I've done 2D opengl before and a little bit of opengl 3D. I just don't like how they do things. There is too much bloat and too much restrictiveness to their code. I mostly have done C, C++ and Java.

I suck at math but so long as I'm not having to do differential equations, I think I should be fine..

jesus fucking christ, you're either 13 or retarded

This is such a complex topic it's hard to type up on my phone, but it's likely not possible for you to know without nvidia/amd hardware documentation
Writing an engine ontop of dxgi/opengl isn't too insane, it's definitely difficult, but creating your own dxgi/opengl requires you to understand how the hardware abstraction layer works, and proprietary info about the devices that you likely don't have

nothing, it just makes things easier because if you want to look into how something is done, you'll have the source available and you can do pretty much everything you want while windows makes it unnecessary hard

Just quick sanity check. You were doing modern opengl (like above 3.0) and not legacy stuff from back in version 1.0. The legacy stuff is easy to spot because it uses stuff like glbegin and glend. Modern opengl focuses more on using shaders.

ok, how low do you want to go ? is libdrm low enough ? or the kernels drm module ? or do you want to do _everything_ yourself ?

Yes, legacy stuff

I don't know what that other shit is, desu

github.com/mirror/reactos/tree/master/reactos/dll/directx/d3d9
Have fun

read Game Engine Architecture - Jason Gregory

>I don't know what that other shit is, desu
ok then i'd suggest start with mesa and work your way down from there / take it apart
or go the other way round: get some microcontroller (the more memory the better) and a display, and start programming whatever you need ?

>Java

Useless for games due to Java by design will not ever let you see hardware, thus shit perf for games.

>C++

Like C, deprecated by Rustlang. Unless you need to build on engines which has not yet been ported to Rust as of yet (unfortunately most of them). Expect C and C++ to be dead in the gaming industry within 5 years.

Because Java is god awful.

>nless you have a minimum of a bachelor of cs/software eng/math or something, you probably cant anyway

I disagree
en.wikipedia.org/wiki/Markus_Persson

Grab the Quake3 sources and learn from the Master.

C

>2017
>Not getting a job that offers paid tuition benefits

>muh rust

it's 2017 gramps, nobody pays you to learn anymore, and nobody wants to pay for your schooling.

Tell that to my employer you poorfag

>All of it? Fuck off.
C can be learned in a week.

yea but keep in mind
>"He began programming on his father's Commodore 128 home computer at the age of seven."
>And had a job in porgramming for several years before Minecraft

I don't think OP has had even a year of programming experience

i wanna have whatever you just smoked boy.

>All of the speed and precision of C an C++, but safe, secure and updated to the 21st century.
>All of this at the small price of people on Sup Forums calling you a cuck

It's the deal of a lifetime

>libraries
>opengl or unity

you clearly have no idea what you are talking about

hero.handmade.network/episodes
good luck

oh boy rusttroll is so funny, let me die

>I suck at math but so long as I'm not having to do differential equations, I think I should be fine..
Not like you'd want physics in your game, anyway.

>Linux kernel was written in nodejs?
I'm certain someone has tried porting it using Emscripten.

>people genuinely recommending this scam

jslinux.org/

3D game engines are all about optimization, especially at a lower level. These kind of optimizations can't be made in Java, because you have not an access to hardware.

An god damn, rustfag, you really think that Rust is made for games ? An engine must be optimized, quick. Rust make your code secure. It's a totally different problem.

all the episodes are free to watch. where's the scam?

when bytecode has been JITted to instruction sets that the C++ code was not already precompiled for. That is just one instance.

Swift and Rust

What the fuck is this thread

Memory safe compiled languages without a GC.
What you don't like?

>GC pauses
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode

You're better off reading books and articles from active professionals on specific topics instead of sifting through hundreds of hours of someone's hobby project

Handmade Hero is written by an 90s game tool ex-programmer, and the guy is just milking his tiny retarded audience for patreon shekkels while writing 90s-style code in his own C++ "dialect" and filming it

Memory safeness obviously make your engine slower.

Why use memory safeness in game engine when you can use C++ which is a lot more optimized than Swift or Rust ? It's a nonsense.

>You're better off reading books and articles from active professionals on specific topics instead of sifting through hundreds of hours of someone's hobby project

he is an active professional. he worked on the witness

>Memory safeness obviously make your engine slower.
>obviously
Explain.

even if he explains that he still needs to prove that the performance loss from memory safety isn't negligible

>Lol Java is faster than C++
In certain handpicked trivial numeric benchmarks that don't represent reality. If you're lucky and the JIT compiler is warmed up and you're not in a collection cycle.

Did he work on anything else in past 15-20 years? Fact that blow hired him doesn't really mean much since blow isn't afraid to burn his own money

This, throughput matters less than latency in games.
/thread

I think you guys missed a point I made. Those languages handle memory without garbage collector. Especially Rust does it compile-time. There is no perfomance loss because of that.

The biggest problem with java is the garbage collection, if it takes more that a few milliseconds, you will notice it as stutter or frame drops. Therefore, GC makes it quite impossible to achieve a stable and smooth framerate.

You can't assure memory safeness with static analysis only. Rust is very efficient for a memory safe programming language. But C++ is more efficient, period.

In the game industry, and especially for game engines, latency matters a lot, optimization too. But they have enough money to pay bugshunters and shit. They don't need memory safe language, it's not the right tool.

he worked on a game released last year that has 500k owners on steam. it doesn't matter what else he has done or what was the reason blow hired him. ironically, Blow writes the same "90s-style code in his own C++ 'dialect'" as Muratori

seconding this
he may be a good programmer but his method of making games is so ridiculously obtuse it would be stupid to recommend a beginner start by watching casey's videos
he's put out hundreds of videos without making a simple, playable 2D game

meant to reply to this post

but I wasn't recommending his videos as a "how to make a game tutorial". the guy asked
>I want to know how to make my own rendering engine, the whole deal. I don't want to use any libraries like opengl or unity.

>he worked on a game released last year that has 500k owners on steam
How is this related to his programming skills? Undertale has 2.5 mil owners on Steam, does it mean that Toby Fox is 5 times better programmer than Casey?

The Witness didn't even have menu for tweaking graphical settings, not sure if they've added that post release

and the point wasn't even for the guy to watch all the videos and learn, but just to show him that he needs to reevaluate his objectives and rephrase his question

one is made in gamemaker and the other is done from scratch

>why are game engines in C++ and not Java
>not Java
>fucking ENGINE IN JAVA
WELCOME TO Sup Forums TECHNOLOGY THIS MUST BE YOUR FIRST DAY HERE SORRY WE RAN OUT OF ORIENTATION GOODIE PACKS PLEASE HAVE THIS METAL ROD AND SHOVE IT UP YOUR ASS.

if someone wnats to make a game engine and doesnt want to use opengl/directx I recommend they buy a brain first

youtube.com/watch?v=WZ_alfF5Zt4

no, they just need to use the internet to learn why they're wrong

>youtube.com/watch?v=WZ_alfF5Zt4
Out of curiosity: Any samples that involve more entities?