Under-the-hood: Java

Under-the-hood: Java

Demystifying everything you've been wondering how the heck your code executes from start to finish in Java. Hold tight it's gonna be a huge ride :)

Β·

2 min read

Table of contents

Before we go onto each component of the above diagram we must know the basics. So, first thing first -

tl;dr

Zoom out a bit from complex compiler designs termonologies and whatever scratches the part of your mind at night. We have tons of programming languages, they all are in some form of textual format that is readable by us humans. At the end of the day, all we want is to execute that piece of code inside a processor. Thus all we need to worry about is converting that sugar-coated code into machine code cause our cute little processor only understands that.

The computation in the middle is the real work here. Whatever components a programming language includes all work towards one goal, the goal to spit machine code at the end. Let's bring in some colors. Interpreters, compilers, assemblers, loaders, linkers, and parsers are a few of them that can fit into computation land. Programming languages can utilize the compilation of computation tools like in here Java. It is both compiled and Interpreted. Now let's learn the components involved in executing your Java code, end-to-end.

Components:

Source code is what we refer to as pure language code. It is nothing far from just a text which always gets converted into another text format. It could be compiled, interpreted, or transpiled.

Java uses Javac to compile source code into Bytecode (.class) files.

It is an intermediate representation code with a .class file extension.

It reads Bytecode and converts it into machine code line by line cause it's an interpreter.

Machine code is the most basic form of instruction that a computer's central processing unit (CPU) can execute directly.


FAQs

Is Java an interpreted or compiled language?
It's both.
Where can I learn more about JVM?
Are machine code and object files different?
Yes.
Where can I reach out if my question is unanswered in this blog?
This blog is not the final version thus it keeps evolving. I seek feedback and update my blog on demand to keep it updated. Just comment down below and I'll be checking them periodically.
Β