| Basic Terms
| Machine Language (code) |
Like all other information (number and characters) - the computer
only can work with binary - ones and zeros. The actual instructions
that the computer understands is machine language - it looks like
this 010101101100100100110011001 (this could be 2 different commands
that the computer understands and can execute) |
| Loader |
See above: Object Code. This is a piece of software that places
the machine code (object file) into memory. |
| High-level Language |
These are commands that are easily understood by programmers (but
never understood by machines). They look like this "IF (X>34)
THEN..." There are hundreds of languages used by programmers
- however the most popular languages today are C++ and Java. |
| Translator |
A program that translates the "high-level code" to machine
language. This process is necessary - because computers can only read
binary numbers - they can't read high-level "english-like"
statements. |
| Interpreter |
A type of translator - that translates the "high-level
coded program " to machine language. This program translates
a line of source code into one or more lines of object code and then
instructs the computer to perform those instructions until another
line has to be translated. These programs execute slower - however
they are much easier to "debug" because the interpreter
will stop on the line that is causing execution errors. Example languages:
Javascript, BASIC, LISP (other scripting languages like Perl, TCL/TK,
PHP, ASP) |
| Scripting Language |
There is a brand of interpreted languages known as scripting languages
(programs)- essentially these are programs which interpreted by
the machine...however they are designed using interpretation so
that they will not have total control over a person's machine -
essentially the interpreter has the last word over whether a particular
statement may be executed. This is extremely important for the success
of the internet - javascript is a scripting language which allows
a program to be transferred and then executed by the client's browser
(which has a built-in interpreter). Examples: Javascript, Java,
Tcl/TK, Perl, PHP, ASP, and so forth. |
| Compiler |
A type of translator - that translates the "high-level
coded program " to machine language. This program translates
the high-level source code once and for all, producing a complete
machine language program. These are executable files (extension EXE).
These programs execute faster - but they tend to b more difficult
to debug. Example languages: C, C++, Fortran, COBOL |
| Virtual Machine (VM) |
A programmer can write programmer - as if the high-level language
is a computer's machine language. That computer is referred to as
a Virtual Machine - again not a real machine, but a "make believe
machine". This allows the programmer to forget about the internal
workings of the computer (binary coded instructions) and concentrate
on the high-level language. The most famous virtual machine is the
Java Virtual Machine (JVM). |
| |
4 Major Language Groups Programming
Language Examples |
| Imperative |
fundamental unit of abstraction is a procedure (C, Pascal, Fortran,
Ada) |
| Functional |
everything is defined as a function which has certain parameters
and returns a value. (LISP) |
| Declarative |
emphasis is on describing the information being processed by a program
(COBOL, Prolog) |
| Object-Oriented |
organized in terms of "objects" which have certain properties
and abilities. (C++, Java, Smalltalk) |
Language Creation Decisions
| Data Types |
Integer, Real Numbers (what types - how large), Boolean (True
and False), Character, Structured data types (array and records) |
| Structured data types |
A structured data type is a logically grouped collection of simple
data types.This gives a language a great capability and flexibility
when it comes to being able to solve whatever programming problem
efficiently. In other words - if the programmer wants to create
another data type - this gives them the power to do it.
Array - a collection of data of a single type (except
in the case of some scripting languages like Javascript) [A string
is usually a subset of this type of data]
Record - a special data type found mostly in imperative
languages. This data type allows a programmer to create a type that
can be deeply organization. Typically the "dot" operator
is used to access the fields in a record. |
| Operations |
Syntax - the form that the statements will be
written. (different languages use different syntax - assignment:
Pascal :=, C =, APL ->, etc.)
Semantics - how the resulting statements will work.
|
| Control |
How the general program flow will be controlled - every language
has the ability to change the program counter (PC) so that the code
will change direction in the middle of sequential statement execution. |
| Subrountines |
At a higher-level of control - most and if not all programming
languages have a "unit level" type of control. This allows
for compartmentalization of the program development. In other words,
it takes much less time to develop something if you break it up
into sub-steps. Subroutines, Functions,
and Objects are the mechanism in programming languages
to allow code to be separated off into their own little unit. |
Translation Steps
| Scanning |
The process of breaking the code file into "chunks"
known as tokens. The program that carries out the
scanning is refered to as a lexical analyzer. |
|
tokens |
A token is the smallest element in a language - like for example
in the English language that would be words, punctuation, and perhaps
special symbols. In a high-level langauge the tokens would be reserved
words, operators, numbers, variables, etc.
For Example:
IF (X > 3) Y = Y + 1;
What are the tokens? |
| Parsing |
In this step, the string of tokens is transformed into a syntactic
structure which represents the logical sense of the program. Typically,
the list of tokens is converted into a parse tree
in memory. When the parser constructs the parse tree it considers
the order that parts of statement must be evaluated in - in other
words consider this statement: x = y + 2 * z. Before the addition
can take place - the multiplication must first take place and so
forth. |
| Code Generation |
In this step, the syntactic structure produced in the previous
step is used to produce the machine code. |
|