A
A
Artemy2018-04-01 02:00:52
C++ / C#
Artemy, 2018-04-01 02:00:52

Why are game engines written in C++?

  • Dagor Engine 5.0 (C/C++)
  • CryEngine V (С++/C#/Lua)
  • ID Tech 6
  • RenderWare
  • Source 2
  • Unity 2017 (C/C++/C#)
  • Unreal Engine 4

Why are none of these engines written in Java or Python?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Maxim Moseychuk, 2018-04-01
@Artemonim

1) Java and even more so python (even pypy) suck in performance, because they have a lot of overhead. And this is not even about a virtual machine or an interpreter, but about the explicit ability to place objects on the stack. To allocate memory on the stack is one machine instruction in one cycle, and on the heap it is a large chain of calls, in the worst case, reaching the kernel space.
Unfortunately, java and python do not have a manual memory management facility. Although there is an offheap project for scala, it's a bit of a dead end.
One of the most popular libraries for Python is NumPy. And it's written in C.
But there is a middle ground: the engine is written in C++, but has an API for another language. An example of this is Unity, which itself is written in C ++, but the logic is implemented in C #.
And almost all the engines you listed live on the cutting edge of graphics technology. Often, even the most powerful processors and video cards are not enough for them. Remember the Crysis jokes.
2) Garbage collection can block all application threads. Because of this, you will have constant friezes.

D
devalone, 2018-04-01
@devalone

Why are none of these engines written in Java or Python?

Java and even more so Python give a very big overhead, yes, you can certainly write an engine on them, but it will not be as productive. Also, unlike most languages ​​(including Java and Python), C ++ allows you to squeeze the maximum performance, in Java there is a garbage collector, you can’t place objects on the stack there, there the size of the variable is tied to the virtual environment, and not to the machine on which the program is running, a lot of checks like going beyond the boundaries of the array, which give an overhead and in the end, Java uses a virtual machine. AFAIR, in Java there is not even an analogue of a vector, where elements (and not references to them) will be stored sequentially in memory, and it is also impossible to include one object in another not by reference, but in C ++ you can.

E
Evgeny Ivanovich, 2018-04-01
@Pauk_Code

Mainly for performance reasons, look at dlang for comparison.

S
Saboteur, 2018-05-01
@saboteur_kiev

The minecraft engine is written in java, you can see the difference in terms of features.
The main problem is working with memory, which in lower-level languages ​​like c/c++ is under the programmer's control, hence the performance is predictable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question