12 April 2021

Java

Ah, the second computer language. One thing is guaranteed: it's going to be different. Here is one difference right up front.

Python programs run until they complete execution or until some error or exception triggers program death and a traceback prints out.

In python you edit code then run it.

Java has an additional step, compilation. Just as with Python, you will edit source code. Once you edit and save, you run the compiler, javac. This can have two results.

Both languages can have errors when programs written in them run. These errors are called runtime errors.

What is the JVM? A virtual machine is a computer implemented in software. Java source code compiles to Java byte code, which is the machine language of the JVM.

This is why a given Java program can run on different platforms. The Mac JVM translates Java byte code to Mac machine code, which then runs. Thw Windoze JVM translates Java byte code into machine language for the Windoze system. This layer of abstraction is happily concealed from you.

Does Python have a virtual machine? Yes. Read about it here.

We will begin to learn about Java's type system using its REPL jshell.