Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are JVM implemented languages like Jython using Java underneath or are they using the JVM native?

In a language that uses the JVM, say Jython, JRuby or any language that isn't Java specifically, is Java the language being used "underneath" somewhere?

Does the implementation mean:

Language Ported to use the JVM + Java somewhere + JVM?

For example, was Jython written in Java or does it using something else to utilize the JVM?

like image 414
johnny Avatar asked Feb 09 '23 17:02

johnny


1 Answers

It depends.

Part of language's standard library may be implemented in java. Ditto for the compiler/interpreter. Other parts that are not essential for bootstrapping may even be written in the language itself.

The user code itself initially may be run through an interpreter but later compiled to bytecode. Additionally the generated bytecode may be optimized further based on type profiles gathered during runtime. And the bytecode may bail out back to the interpreter if some of its assumptions are invalidated. This is analogous - albeit at a higher abstraction level - to hotspot's interpreter/c1/c2 tiers and many other JIT environments.

But interpreter+JIT is just one possible approach. Scala for example is AOT-compiled to bytecode.

And they may also use C bindings to implement functions of the respective language's standard library that have no 1:1 mapping to the JDK standard library.

like image 115
the8472 Avatar answered Feb 11 '23 06:02

the8472