jvmjvm-languages

Why it is possible to build custom language for JVM, like Groovy, Scala, Clojure, Kotlin?


These languages differ from Java in significant ways, like OO system, type system (most notable).

The actual question is whether JVM keeps track of objects under the hood? Is there an object inside JVM? Is it responsibility of creators of such languages that they may interoperate with Java world, or it is achieved "by default"?


Solution

  • The actual question is whether JVM keeps track of objects under the hood?

    Yes, it does. Garbage collection is the responsibility of the JVM.

    Is there an object inside JVM?

    Yes, there are byte codes to create class instances. Also, dynamic dispatch of instance methods is done by the JVM.

    Is it responsibility of creators of such languages that they may interoperate with Java world, or it is achieved "by default"?

    It is low hanging fruit, and it would be foolish not to do it. Moreover, not all JVM languages reinvent the wheel and just use JRE classes when it is appropriate. This includes most probably String, the primitive types and their boxed forms and arrays.