C and C++ execution environments
C and C++ are high-level programming languages; their purpose is to make it easier
for human beings to develop computer programs. Computers cannot understand
high-level languages -- they can only understand low-level machine languages. A
machine language consist of a sequence of binary instructions that can be directly
executed on a computer's processor. For this reason, programs written in high-level
languages must be translated into machine language programs, which are called
executables, before they can be run on a computer.
Two methods are available for translating a high-level programming language into
machine language executables: compilation and interpretation. Compilation involves
translating an entire high-level program into a whole machine language program,
which can then be executed in its entirety. Interpretation involves translating a
high-level program into machine instructions line-by-line; one line is translated and
executed before the next line is reached. Compilation and interpretation are logically
equivalent, but compiled programs tend to execute faster than interpreted programs.
C and C++ programs are compiled into machine language executables by a program
called a compiler. C compilers and C++ compilers are different. A C compiler can
compile C source code files but not C++ source code files. Since C is retained as a
subset of C++, a C++ compiler can compile both C and C++ programs.
Different computers use different machine languages. An executable that runs on
one machine will not run on another machine that uses a different machine
language. In order to run on different computers, a C or C++ source code file must
be recompiled on different compilers; one for each type of machine, or platform, on
which the executable will be run.
The Java execution environment
Like C and C++ programs, Java programs are compiled. Unlike C and C++
programs, Java programs are not compiled down to a platform-specific machine
language. Instead, Java programs are compiled down to a platform-independent
language called bytecode. Bytecode is similar to machine language, but bytecode is
not designed to run on any real, physical computer. Instead, bytecode is designed to
be run by a program, called a Java virtual machine (JVM), which simulates a real
machine.
Simply put, the JVM is an interpreter that translates Java bytecode into real machine
language instructions that are executed on the underlying, physical machine. More
specifically, the term Java virtual machine is used generically to refer to any program
that executes Java class files. The Java interpreter program, java.exe, is a
specific JVM implementation. The Java Runtime Environment (JRE) is another
ibm.com/developerWorks developerWorks®
Java programming for C/C++ developers Trademarks
© Copyright IBM Corporation 2002. All rights reserved. Page 9 of 45