Why does Java only allow dynamic binding?

I followed the YouTube compiler tutorial when I came across the fact that the C programming language is faster because it allows both static linking and dynamic linking, but Java only allows dynamic linking, so C is much faster than Java.

My question is: if static binding makes the program work faster, why wasn’t it included in Java? I know there must be some real reason why the Java developers decided this solution so as not to include static links, I just want to know what are the reasons.

Note. I do not know if this question has an answer to SO, but since I could not find it, so I posted it. If the answer already exists, provide a link to it.

Note. The tutorial link is in Hindi. Sorry.

+4
source share
3 answers

Java does not include the linker stage at compile time. With Java 9, a tool (jlink: JEP 275 , JavaOne Talk on Project Jigsaw ) will appear that will create an image on which the dependencies will be linked.

One of the main goals of Java when it was created was "Code once, run at". Static linking of libraries depending on the environment or parts of the code will negate this function.

+6
source

Java JRE- , , Java.

+2

C - . .

Java , , , .

, , dlopen() , , ( ).

In this context, in general, one significant difference in performance is memory, in particular the ability to control the memory layout to some extent on C. This can bring significant benefits, because with less fragmentation and reduction to cache cache CPU caching and speculative hardware optimizations (like prefetching) work much better.

+1
source

Source: https://habr.com/ru/post/1618555/


All Articles