Y
Y
yourisus2016-12-07 09:57:57
Python
yourisus, 2016-12-07 09:57:57

Noob thoughts about interpreted Java\python\c# and compiled c++\c etc?

Interpreted language - goes through 2 stages instead of one (interpretation into byte code and compilation), compiled language - 1 stage (compilation).
The interpreter (example jvm) still compiles the bytecode and gets the same as if we wrote in C.
That is, if you write a code that will simply add two numbers and display the result in java and in c.
The compilation algorithm is:
prog.java -> prog.bytejava -> prog_byte.asmbl
prog.c -> --------------------- ->
prog.asmbl is that if you run prog_byte.asmbl and prog.asmbl, their execution time will be the same?
After all, 90+% of the game is textures, which means that this should be done by the video card, not the processor.
Does that mean that a compiled game in Java can not be inferior in performance to a game written in C ++?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Saboteur, 2016-12-07
@saboteur_kiev

What makes you think that 90% of the game is textures?
What does "make textures" mean? The video card will stamp textures for you, but what to do with them? Who will calculate what to output, in what order, why?
How exactly does java communicate with the graphics card? It cannot send to it directly, at least your program must communicate with the video card driver.
And before the video card driver, you can use a graphics framework, otherwise you need to study optics, 3D modeling, geometry at such a level that you will start writing a game in 10-15 years.
And for C ++ for Windows, there is a ready-made DirectX that will do 90% of the work for you. And under java there is no DirectX ...
In general, you are not quite trying to calculate.

D
Daniil Kolesnichenko, 2016-12-28
@KolesnichenkoDS

Interpreted language - goes through 2 stages instead of one (interpretation into byte code and compilation), compiled language - 1 stage (compilation).

Oh. First, there are no interpreted or compiled languages. For any language, you can write an implementation both in the form of an interpreter and in the form of a compiler. Secondly, there is no “interpretation into bytecode”, interpretation cannot be “into something” at all. Interpretation is the direct execution of the program code by another program.
In fact, the implementation of the PL can be divided approximately as follows:
So, for example, GCC is a static compiler, OpenJDK is a translator to bytecode + JIT bytecode compiler, CPython is a translator to bytecode + bytecode interpreter.
For languages ​​with static typing and manual memory management (C, C++, Rust etc), static (AOT) compilers are the most efficient. For dynamic languages ​​with a garbage collector, just-in-time compilation is often more efficient, because it allows the compiler to use run statistics for complex optimizations. "Real" interpreters (i.e., not actually JIT compilers) tend to be slower than compilers.
Maybe if the C++ implementation is of poor quality. In general, Java code will be slower than C++ code due to the garbage collector and type erasure.

R
Rafael™, 2016-12-07
@maxminimus

https://habrahabr.ru/post/105199/
- here the performance of the interpreted languages ​​java and js is tested
one and a half times lower than si

D
Dmitry Kovalsky, 2016-12-07
@dmitryKovalskiy

Before you look for performance improvements in the compiler, you need to make sure that your code itself already uses the most efficient solutions. And when everything in your algorithms and data storage methods is IDEAL, then we start thinking about compiling the project. The C# JIT compiler, for example, slows you down only on the first launch of the project (when the actual compilation into assembler takes place). Then all the brakes are already caused by the speed of the CLR (JVM in the case of Java) and the libraries themselves.

T
theurs, 2016-12-07
@theurs

byte code is essentially an assembler for another processor, not x86-64, it needs special virtualization or interpretation to execute it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question