[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
3.1.2 Language Translators
JerryDate: Sunday, 25/09/2011, 10:31 PM | Message # 1
Ford Everest
Group: Administrators
Messages: 137
Reputation: 0
Status: Offline
Basics of Programming languages

•There are two types of programming languages used : Low-Level Languages (LLL) and High-Level Languages (HLL)
•Low-Level Languages are a series of letters that come equivalent to the actual binary, eg: LAD 2309, ADD 2310◦Low-Level languages are hard to understand and are very basic

•High-Level Languages are easier to read for programmers and allow more functions, every High-Level language has its own struchure and allows much more freedom than Low-Level languages◦HLLs are easier to understand and follow a structure that is easier to understand for humans
◦Some of the most influential programming languages are:■BASIC (Beginners All-purpose Symbolic Instruction Code)
■C, C++
■FORTRAN (FORmula TRANslation)
■COBOL (Common Business Oriented Language)
■Java
■Perl
■Ruby
■Visual Basic

The reason why we use compilers and Interpreters is because we write programs in Low-level languages or High-level languages (used more frequently). Computers only run native machine code (Binary), in order to get the programs that we write into machine code we need to either compile them or interpret them by the computer


Compilers:

A Flowchard showing how a HLL compiler works (link)

•A compiler takes a program written in a high-level language and translates into an equivalent program in machine code
•Once this is done, the machine code version can be loaded into the machine and run without any further help as it is complete in itself
•The high-level language version of the program is usually called the source code and the resulting machine code program is called the object code.
•Code is written using either a text editor (eg. notepad++) or and IDE (Integrated Development Environment)
•Advantages◦You don't need an interpreter on each machine to read code. All machines of that type can read a complied code faster

•Disadvantages◦You need to write entirely new code to transfer between types of machines.
◦Using a compiler is that it uses a lot of computer resources
◦Another disadvantage is that when an error in a program occurs it is difficult to pin-point its source in the original program



Interpreters:

A flowchart showing how an interpreter works (link)

•Translates programming languages into machine code for that specific machine only.
•The code that you write can be given to any machine with an interpreter, it is then translator into code for that specific machine
•Advantages◦The code only has to be written once, and will run on any machine with an interpreter.

•Disadvantages◦Every machine needs an interpreter
◦since it has to compile the code line by line as it is running it is not that fast


Interpretation
•Is when a program directly executes the source code
•There are three main methods of Interpretation:1.They can directly execute the source code
2.They can translate the source code into some efficient intermediate representation (code) and immediately execute this
3.They can explicitly execute stored precompiled code made by a compiler which is part of the interpreter system
 
JerryDate: Monday, 26/09/2011, 11:13 AM | Message # 2
Ford Everest
Group: Administrators
Messages: 137
Reputation: 0
Status: Offline
Nature and Function of HLL's

One HLL statement usually translates into many machine code statements, you might see something like:

FOR X = 1 to 23 DO
Y = X * 2
PRINT (X, Y)
NEXT

Which, believe it or not, is easier to understand when you are trying to develop computer software (programs). Some features of HLL's are:

. They are portable, ie can be run on different machines rather than machine-specific like assembly language.
. They are English-like, more easy to understand.
. Different languages have been developed for different tasks.
Examples of HLL's

There are said to be 2000 different high level computer languages so these are just a few examples from the mainstream:

Early HLL's were FORTRAN (FORmula TRANslation language) which was intended for mathematical and scientific programming and COBOL (COmmon Business-Oriented Language) for developing business and data-processing applications.

ALGOL (ALGOrithmic Language) was an early (1950's) attempt to introduce the concept of structured programming and eventually led to the development of C and so on to Pascal which are highly-structured block languages. The structure is (supposed to be) used by programmers to make the workings of the program clear to other programmers who may have to work in the same team or do maintenance.

BASIC (Beginners All-purpose Symbolic Instruction Code) was introduced for microcomputers and, although poorly structured and often misused, gave many, many people an easy initial introduction to computer programming.

Some other notable languages are: FORTH , LISP and Prolog . All of these languages are available (or have been at some time) in versions for microcomputers.

More recently Object Orientated Languages , notably SMALLTALK , C++ and Java have taken the concepts of structured programming one stage further (but you'll learn about this in another part of the course).

Only Higher Level students need to know the concepts associated with Object Oriented programming.

The next wave may well be scripting languages such as PHP , Python and Javascript.

Comparison of Compilers and Interpreters

Compilers and interpreters are two types of program that translate High Level languages into binary machine code . Different programs operate in different ways - many compilers produce an assembly language stage.

With the advent of Java as a cross-platform language the following distinctions become a little blurred. Your Java source code files are compiled (by the javac program) not to machine code for a specific platform but to an intermediate stage known as bytecodes .

These bytecodes are then fed to an interpreter (the Java Virtual Machine) of which there are different versions for different types of computer.

In the simpler world, Compilers and Interpreters take High Level language source codes and produce binary machine code for a specific platform.

Compiler Interpreter

Produces a complete machine code program which Translates an HLL line by line without saving any object code
can be stored on disc, loaded and run.
Needs a complete HLL program Starts at the beginning and continues to end or first error
Gives an error listing of all errors in the program Stops at the first error.
More complex program Simpler, needs less memory, frequently used in older microcomputers.
Machine code product can be run on any machine Interpreter needs to be in memory when the program is run
without a compiler.
 
  • Page 1 of 1
  • 1
Search:

Statistics
Map
Login form