What does "Run on the JVM" mean?

Asked

Viewed 265 times

13

Languages such as Scala, Kotlin, Clojure and others "run on JVM".

  • What does that mean?

  • What the JVM provides for them?

  • The extent to which they are "dependent" on the JVM?

  • They only run on the JVM?

  • These languages generate a .class same as Java to run on JVM?

1 answer

13


What does that mean?

It means that these languages generate a JVM-compatible "binary," which it is able to understand, which follows all protocols specified by that platform. It’s like saying an application is capable of running on Windows, or even ARM.

What the JVM provides for them?

An execution environment that "interprets" the bytecode, generates native codes for the platform below (Jitter), memory management (GC) and security, all infrastructure to interoperate with other applications and components external to the JVM, and also a large library, although technically not part of the JVM, but of something that is always close to it, forming the JRE (Java Runtime Enviroment). Anyway, it’s a virtual machine simulating a processor and an operating system within a specific standard where applications can focus, leaving this machine to deal with the real platforms where they will run.

The extent to which they are "dependent" on the JVM?

The language itself should not be, but it is common that even language needs specific platform features that run. Actually it’s not quite the JVM that is the problem, it’s the library available for the platform that is usually adopted by the language that practically makes the language dependent on that platform. Not that it has no solution, but it becomes complicated to compatibilize in another platform.

They only run on the JVM?

Nothing prevents them from running where they want unless you have specification to the contrary or have something that only the JVM can provide, which is usually unlikely. Behold Relationship between Hotspot and JVM, JDK/Openjdk?.

These languages generate a .class same as Java to run on JVM?

Usually yes, but it is possible that some language creates an infrastructure that makes access different.

  • Cool! Thank you so much for the reply! I received a -1.. Do you know what pq? I did something wrong?

  • 2

    Not that I know of, there are people who negative because it is possible to get the answer in another place, but not here.

  • Clojure is an example of language that can run in the JVM and browser (javascript). It’s as if one language is hosted in another. The hosted language allows calling methods, creating classes, and instantiating language objects "host".

  • The advantage is that generally the languages that run on JVM have a simpler and less bureaucratic syntax than Java.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.