Java Reference
In-Depth Information
languages (such as Smalltalk and Ruby) allow the type system itself to
change dynamically. Since the user program is continuously reexamined
as execution proceeds, symbols need not have a fixed meaning. For
example, a symbol may denote an integer scalar at one point and a
Boolean array at a later point. Such fluid bindings are more problematic
for compilers, since dynamic changes in the meaning of a symbol make
direct translation into machine code more di
cult.
Interpreters provide a significant degree of machine independence, since
no machine code is generated. All operations are performed within the
interpreter. Porting an interpreter can be as simple as recompiling the
interpreter on a new machine, if the interpreter is written in a language
already supported on that machine.
However, direct interpretation of source programs can involve significant over-
head. As execution proceeds, program text must be continuously reexamined.
Identifier bindings, types, and operations may have to be recomputed at each
reference. For languages where such bindings can change arbitrarily, interpre-
tation can be 100 times slower than compiled code. For more static languages
such as C and Java, the cost di
ff
erence is closer to 10.
, and Java) have both interpreters (for debug-
ging and program development) and compilers (for production work).
Some languages (C, C
++
JIT
compilers o
ff
er a combination of interpretation and compilation
/
execution.
In summary, all language processing involves interpretation at some level.
Interpreters directly interpret source programs or some syntactically trans-
formed versions of them. They may exploit the availability of a source repre-
sentation to allow program text to be changed as it is executed and debugged.
While a compiler has distinct translation and execution phases, some form of
“interpretation” is still involved. The translation phase may generate a virtual
machine language that is interpreted by software or a real machine language
that is interpreted by a particular computer, either in firmware or hardware.
1.4 Syntax and Semantics
A complete definition of a programming language must include the specifica-
tion of its syntax (structure) and its semantics (meaning).
Syntax typicallymeans context-free syntax because of the almost universal
use of context-free grammars (CFGs) as a syntactic specification mechanism.
Syntax defines the sequences of symbols that are legal; syntactic legality is
independent of any notion of what the symbols mean. For example, a context-
free syntax might specify that a=b+c is syntactically legal, while b+c=a is not.
 
 
Search WWH ::




Custom Search