Showing posts with label Computer Knowledge. Show all posts

Difference Between Compiler & Interpreter

0 comments
Compiler
A compiler is a piece of code that translates the high level language into machine language. When a user writes a code in a high level language such as Java and wants it to execute, a specific compiler which is designed for Java is used before it will be executed. The compiler scans the entire program first and then translates it into machine code which will be executed by the computer processor and the corresponding tasks will be performed.  
Compiler working
Shown in the figure is basic outline of the compilation process, here program written in higher level language is known as source program and the converted one is called object program.
Interpreter
Interpreters are not much different than compilers. They also convert the high level language into machine readable binary equivalents. Each time when an interpreter gets a high level language code to be executed, it converts the code into an intermediate code before converting it into the machine code. Each part of the code is interpreted and then execute separately in a sequence and an error is found in a part of the code it will stop the interpretation of the code without translating the next set of the codes.  
Interpreter working
Outlining the basic working of the interpreter the above figure shows that first a source code is converted to an intermediate form and then that is executed by the interpreter.

The main differences between compiler and interpreter are listed below:
·         The interpreter takes one statement then translates it and executes it and then takes another statement. While the compiler translates the entire program in one go and then executes it.
·         Compiler generates the error report after the translation of the entire page while an interpreter will stop the translation after it gets the first error.
·         Compiler takes a larger amount of time in analyzing and processing the high level language code comparatively interpreter takes lesser time in the same process.
·         Besides the processing and analyzing time the overall execution time of a code is faster for compiler relative to the interpreter.


Read More »

Programming Languages - LOW LEVEL & HIGH LEVEL

0 comments
There are two major types of programming languages. These are Low Level Languages and High Level Languages. Low Level languages are further divided in to Machine language and Assembly language.
LOW LEVEL LANGUAGES

The term low level means closeness to the way in which the machine has been built. Low level languages are machine oriented and require extensive knowledge of computer hardware and its configuration.

(a) Machine Language
Machine Language is the only language that is directly understood by the computer. It does not needs any translator program. We also call it machine code and it is written as strings of 1′s (one) and 0’s (zero). When this sequence of codes is fed to the computer, it recognizes the codes and converts it in to electrical signals needed to run it. For example, a program instruction may look like this:
1011000111101
It is not an easy language for you to learn because of its difficult to understand. It is efficient for the computer but very inefficient for programmers. It is considered to the first generation language. It is also difficult to debug the program written in this language.
Advantage
The only advantage is that program of machine language run very fast because no translation program is required for the CPU.
Disadvantages
1.It is very difficult to program in machine language. The programmer has to know details of hardware to write program.
2.The programmer has to remember a lot of codes to write a program which results in program errors.
3.It is difficult to debug the program.
(b) Assembly Language
It is the first step to improve the programming structure. You should know that computer can handle numbers and letter. Therefore some combination of letters can be used to substitute for number of machine codes.
The set of symbols and letters forms the Assembly Language and a translator program is required to translate the Assembly Language to machine language. This translator program is called `Assembler’. It is considered to be a second-generation language.
Advantages:
1.The symbolic programming of Assembly Language is easier to understand and saves a lot of time and effort of the programmer.
2.It is easier to correct errors and modify program instructions.
3.Assembly Language has the same efficiency of execution as the machine level language. Because this is one-to-one translator between assembly language program and its corresponding machine language program.
Disadvantages:
1.One of the major disadvantages is that assembly language is machine dependent. A program written for one computer might not run in other computers with different hardware configuration.

HIGH LEVEL LANGUAGES

You know that assembly language and machine level language require deep knowledge of computer hardware where as in higher language you have to know only the instructions in English words and logic of the problem irrespective of the type of computer you are using.
Higher level languages are simple languages that use English and mathematical symbols like +, -, %, / etc. for its program construction.
You should know that any higher level language has to be converted to machine language for the computer to understand.
Higher level languages are problem-oriented languages because the instructions are suitable for solving a particular problem. For example COBOL (Common Business Oriented Language) is mostly suitable for business oriented language where there is very little processing and huge output. There are mathematical oriented languages like FORTRAN (Formula Translation) and BASIC (Beginners All-purpose Symbolic Instruction Code) where very large processing is required.
Thus a problem oriented language designed in such a way that its instruction may be written more like the language of the problem. For example, businessmen use business term and scientists use scientific terms in their respective languages.
Advantages of High Level Languages
Higher level languages have a major advantage over machine and assembly languages that higher level languages are easy to learn and use. It is because that they are similar to the languages used by us in our day to day life.


Read More »