Programming Languages

Machine Language

Programs, like data, are encoded in binary in the form of machine instructions.

Example:

InstructionsComments
0000 X Store accumulator val in memory loc X
0001 X Load contents of memory loc X into acc.
0010 X Set accumulator value to X
0011Halt execution
0100 X Add contents of memory loc X to acc.

Every computer has its own set of machine instructions.


Assembly Language

An "assembly language" is a set of mnemonic names for the instructions in a particular computer's machine language.

Example:

InstructionsComments
STORE X Store accumulator val in memory loc X
LOAD X Load contents of memory loc X into acc.
SET X Set accumulator value to X
HALT Halt execution
ADD X Add contents of memory loc X to acc.

An assembler program translates source code in assembly language into object code in machine language. In general, one line of assembly language translates into one instruction code.

Load x
Add y
Store x
Halt
 ==> 
Assembler
 ==> 
0001000000001100
100100000001101
0000000000001100
0111
 ==> 
Computer
Assembly
language program
  Machine code program 

High-level Languages

Programming Languages can be classified by their programming paradigm.

Programming Languages
Numeric
FORTRAN
 Symbolic
LISP
Scheme
 
 Procedural
Algol
Pascal
C
 Business
COBOL
Object-Oriented
Smalltalk
Objective C
C++
Java
  Object-Based (or Event Driven)
HyperTalk
JavaScript
 
Translator
- a program that takes a source code file in the high-level language and produces as its output object code in machine language, which the computer can then run.
Interpreter
- A translator which 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.
Compiler
- a translator which translates the source code once and for all, producing a complete machine language program.
if (x==3)
total=2+x;
 ==> 
Compiler
 ==> 
010011
001110
111000
 ==> 
Computer
High-level code  Machine code 

Examples