DEV Community

Alexsandro Souza
Alexsandro Souza

Posted on

JVM execution dilemma - Interpret or compile?

I am always posting provoking post on my Linkedin, and I have decided to replicate those here. Let's socialize!

Alt Text

The JVM execution engine has a big dilemma: Interpret or compile the code?

The interpreter interprets the bytecode and executes the instructions one-by-one. Hence, it can interpret one bytecode line quickly, but executing the interpreted result is a slower task.

JIT compiler takes more time for compiling than for the interpreter to interpret. For a code segment that executes just once, it is better to interpret it instead of compiling, but when one method is called multiple times, each time a new interpretation and a slower execution are required.

To solve the dilemma, JIT compiler internally checks the frequency of each method call and decides to compile each only when the selected method has occurred more than a certain level of times.

This is known as adaptive compiling and it was brought by the introduction of Oracle Hotspot VMs.

Now you know what to answer when asked if Java is compiled or interpreted - it is both!

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

👋 Kindness is contagious

DEV shines when you're signed in, unlocking a customized experience with features like dark mode!

Okay