Search this site

 Home  Howto index  Getting started with Java  Java for C programmers  Java for BASIC programmers

From BASIC to Java: an introduction to Java for BASIC programmers (4)

(Continued from the Java for BASIC programmers introduction.)


Most versions of BASIC are interpreted. Your computer's CPU doesn't 'natively' understand BASIC, and the BASIC interpreter thus reads the BASIC program line by line and in effect "translates" each command into machine code as it goes along. (This view is a little bit simplistic– good interpreters actually do a tiny a bit of the "translation" job beforehand, such as converting numbers into a machine-readable format.)

Java is essentially a compiled language, although the process of compilation is a little bit more complex than in other compiled languages such as C. Before running your Java program, it is compiled into a form called bytecode. In simple terms, this is a form that is kind of half-way between the program that you write (the source code) and machine code. Another way of putting it is that the bytecode compilation does all the parts of the translation job that are common to all machines. Then when you actually run your program, the Java Virtual Machine (JVM) does the final part of the translation. It may actually start by interpreting the bytecode, in a similar way to a BASIC interpreter. But a key difference is that most JVM's actually compile key parts of your program (bytecode) directly into machine code. This makes Java programs pretty much as fast as other compiled languages in many cases. The notion that "Java is a slow, interpreted language" is basically only true in a few limited cases such as bottom-of-the-range cellphones.

On the next page, we'll look at the Java development process and how it differs from the (very simple) development process of BASIC.

comments powered by Disqus

Written by Neil Coffey. Copyright © Javamex UK 2012. All rights reserved.