laron walker - java compilers vs. interpreters
DESCRIPTION
Java Compilers vs. InterpretersTRANSCRIPT
Running Head: Java Compilers vs. Interpreters 1
Java Compilers vs. Interpreters
LaRon Walker
Master of Information Technology and Internet Security
January, 2010
Running Head: Java Compilers vs. Interpreters 2
Abstract
There are many differences between compilers and interpreters. The main difference is
compilers translate code written for specific platforms and converts them to machine language
which can then be executed by the computer directly, whereas interpreters takes the code, and
executes it directly on the target OS. This document will discuss some benefits of compilers and
interpreters, scenarios in which both are appropriate, as well as a problematic situation that a
Java problem may solve or make easier.
Running Head: Java Compilers vs. Interpreters 3
Java Compilers vs. Interpreters
LaRon Walker
Master of Information Technology and Internet Security
January, 2010
Compilers are very different than interpreters, however within a Java environment they
may be used in conjunction with each other. In general, a compiler is a tool in which translates
high-level code to machine language so it can be executed by the host computer’s hardware
itself, and an interpreter will take the same type of code, and execute it as is, without any
conversion or translation. Each of these tools have their own specific uses, but are used in
conjunction with one another.
Per John Wiley & Sons, Ltd (2003), “A compiler is a program that translates programs
expressed in a source language into equivalent programs expressed in a target language.” In
other words, it converts the original code to machine language to be executed by the
computer’s hardware itself. In a Java environment when using a compiler, the original code is
converted to bytecode, which are the types of instructions executed by Java. These bytecodes
are then executed within a Java Virtual Machine (JVM) environment, which allows for greater
portability of Java applications across multiple hardware platforms, as JVM is the most
commonly used virtual machine in today’s industry. With this said, most precompiled
applications run faster and are more portable when using this method.
Running Head: Java Compilers vs. Interpreters 4
The JVM can be considered both as an interpreter and a compiler. Early versions of the
JVM were considered more as interpreters, as each bytecode was processed one at a time.
Using this technique made Java applications slow, which forced the evolution of Just in Time
(JIT) compilation. Per Deitel (2010), in the JIT compilation process, “The JVM analyzes the
bytecodes as they are interpreted, searching for hot spots, which are parts of the bytecodes
that are executed frequently”. One of the most commonly used compilers used for this are
called Java HotSpot Compilers. According to Wiley (2003) these types of compilers “convert OS-
independent Java bytecode and optimizes it for execution on the target OS”. Bytecodes differ
from machine language, as they are not platform specific, whereas machine language is bound
to specific hardware. In more current Java practices, technically using a JIT compiler performs 2
different translations. This first is converting the original code to bytecodes which maintains
portability, and the second is converting bytecodes to machine language to be processed by the
computer. This leads me to believe that when referring to Java environments, this is where the
border between Interpreters and Compilers meet. In essence, a compiler is an interpreter that
has enhanced features that help improve performance. Based on this theory, the JVM is the
initial component, and the JIT is the add-in. The JVM has made it possible for Java to become
one of the most portable coding environments used today.
Although in Java environments, interpreters and compilers can seem the same, their
functions are used in different ways. For instance, if you were in an environment where
granular security was essential, one may want to have code written specifically for hardware
within that environment, as long as all of equipment was consistent (e.g. All IBM, etc.). Using
this strategy, an interpreter would be ideal, as it would execute the information as is, and
Running Head: Java Compilers vs. Interpreters 5
would require specific hardware to process that information. Using a compiler technique in this
type of environment would compromise the security requirement for this environment by
introducing cross platform portability.
On the other side of this spectrum, if you were in an environment in which housed
various hardware from different manufacturers, using a compiler method would be ideal, as
long as the same compiler was used on these different hardware platforms. An example of this
type of scenario would be an environment using MACs, Windows, Unix platforms. In this type
of environment, it may be difficult to transfer information between the different operating
systems. It is possible to connect these platforms, but they all require different configuration
settings to do so. Using JVM and JIT together can help this. A small Java application can be
written that can configure these settings automatically for users. This application can be
distributed via a web browser that can be accessed from any operating system. This would help
reduce the time it takes for IT departments to manually configure these systems.
Running Head: Java Compilers vs. Interpreters 6
References
"compiler" A Dictionary of the Internet. Darrel Ince. Oxford University Press, 2009. Oxford
Reference Online. Oxford University Press. Career Education Corporation (Greenspoint).
15 January 2010 <http://www.oxfordreference.com/views/ENTRY.html?
subview=Main&entry=t12.e656>
COMPILER. (2003). In Encyclopedia of Computer Science. Retrieved January 15, 2010 from
http://www.credoreference.com/entry/encyccs/compiler
Deitel, H., Deitel, P. (2010). JAVA HOW TO PROGRAM (7th ed.). Upper Saddle River, NJ: Prentice
Hall.
"interpreter" A Dictionary of the Internet. Darrel Ince. Oxford University Press, 2009. Oxford
Reference Online. Oxford University Press. Career Education Corporation (Greenspoint).
15 January 2010 <http://www.oxfordreference.com/views/ENTRY.html?
subview=Main&entry=t12.e1740>
JIT compiler for Java (Just in time compiler for Java). (2003). In Dictionary of E-Business.
Retrieved January 15, 2010 from
http://www.credoreference.com/entry/dictebusiness/jit_compiler_for_java_just_in_tim
e_compiler_for_java
Running Head: Java Compilers vs. Interpreters 7
Joch, A. (2001, January 22). Compilers, Interpreters, and Bytecode. Computer World; January
2001, 68 (4), 1. Retrieved January 15, 2010, from EBSCOHOST MasterFile Premier
database.