Saturday, October 12, 2019

High-Level-Languages-Low-Level-Languages

High and Low Level Languages

A computer program is a list of instructions that enable a computer to perform a specific task.
Computer programs can be written in high and low level languages, depending on the task and the hardware being used.
So, what’s the difference between high level language and low level language?

High Level Languages

When we think about computer programmers, we are probably thinking about people who write in high-level programming languages.

High level languages are written in a form that is close to our human language, enabling to programmer to just focus on the problem being solved.
No particular knowledge of the hardware is needed as high level languages create programs that are portable and not tied to a particular computer or microchip.

These programmer friendly languages are called ‘high level’ as they are far removed from the machine code instructions understood by the computer.
Examples include: C++, Java, Pascal, Python, Visual Basic.

Advantages
  • Easier to modify as it uses English like statements
  • Easier/faster to write code as it uses English like statements
  • Easier to debug during development due to English like statements
  • Portable code – not designed to run on just one type of machine

Low Level Languages

Low level languages are used to write programs that relate to the specific architecture and hardware of a particular type of computer.
They are closer to the native language of a computer (binary), making them harder for programmers to understand.
Examples of low level language:
  • Assembly Language
  • Machine Code

Assembly Language

Few programmers write programs in low level assembly language, but it is still used for developing code for specialist hardware, such as device drivers.
It is easy distinguishable from a high level language as it contains few recognisable human words but plenty of mnemonic code.

Advantages
  • Can make use of special hardware or special machine-dependent instructions (e.g. on the specific chip)
  • Translated program requires less memory
  • Write code that can be executed faster
  • Total control over the code
  • Can work directly on memory locations

Machine Code

Programmers rarely write in machine code (binary) as it is difficult to understand.


Compiler-Interpreter-Assembler

Translators

The program that converts source program into object program is called translator program. A program written in high-level language is called as source program and a program written in machine language is called as object program
A translator takes a program written in source language as input and converts it into a program in target language as output. It also detects and reports the error during translation by providing diagnostic messages wherever the programmer violates specification of the high-level language program.
The different types of translator are as follows:
  • 1. Assembler
  • 2. Compiler
  • 3. Interpreter

Computers only understand machine code (binary), this is an issue because programmers prefer to use a variety of high and low-level programming languages instead.

To get around the issue, the high-level and low-level program code (source code) needs to pass through a translator.

A translator will convert the source code into machine code (object code).
There are several types of translator programs, each able to perform different tasks.

Compiler in C

Compiler is a translator program (system software) which is used to convert programs in high-level language to low-level language (code into binary format in single steps). 
It translates the entire program and also reports the errors in source program encountered during the translation. 
In other words, Compiler is a system software which can take input from other any programming language and convert it into lower level machine dependent language.



How it works-

  • 1.It analyses all of the language statements for its correctness. If incorrect, throws an error.
  • 2.If no error, the compiler will convert source code to machine code.
  • 3.It links different code files into a runnable program(know as exe). 
  • 4.Run the Program
 A compiler is likely to perform many or all of the following operations: pre-processing, lexical analysis, parsing, semantic analysis, conversion of input programs to an intermediate representation, code optimization and code generation. 
Advantages of Compiler:
  • 1. It takes large amount of time to analyze the source code but the overall execution time is comparatively faster.
  • 2.Generates output program which can be run independently from the original program.
Disadvantages of Compiler:
  • 1.Compiler displays all errors and warning at the compilation time. Therefore, you can’t run the program without fixing errors. 
  • 2.It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. 
  • 3. Generates intermediate object code which further requires linking, hence requires more memory.

Interpreter



Interpreter is a translator program which is used to convert programs in high-level language to low-level language. Interpreter translates line by line and reports the error once it encountered during the translation process. It directly executes the operations specified in the source program when the input is given by the user. It gives better error diagnostics than a compiler.
Advantages of Interpreter:
  • 1.Interpreters are easier to use, especially for beginners.
  • 2.No intermediate object code is generated, hence are memory efficient.
  • 3.Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy.
Disadvantages of Interpreter:
  • 1.It takes less amount of time to analyze the source code but the overall execution time is slower.
  • 2. Do not generate output program. So they evaluate the source program at every time during execution. 

Assembler

Assemblers are used to translate a program written in a low-level assembly language into a machine code (object code) file so it can be used and executed by the computer.

Once assembled, the program file can be used again and again without re-assembly.

Functions of assembler:
  • 1. Convert mnemonic operation codes to machine language equivalents. 
  • 2. Convert symbolic operands to machine addresses. 
  • 3. Build machine instructions.
  • 4. Convert data constants to internal representations.
  • 5. If there is any error in program, notify with error message.  

Summary of translators

CompilerInterpreterAssembler
Translates high-level languages into machine codeTemporarily executes high-level languages, one statement at a timeTranslates low-level assembly code into machine code
An executable file of machine code is produced (object code)No executable file of machine code is produced (no object code)An executable file of machine code is produced (object code)
Compiled programs no longer need the compilerInterpreted programs cannot be used without the interpreterAssembled programs no longer need the assembler
Error report produced once entire program is compiled.  These errors may cause your program to crashError message produced immediately (and program stops at that point)One low-level language statement is usually translated into one machine code instruction
Compiling may be slow, but the resulting program code will run quick (directly on the processor)Interpreted code is run through the interpreter (IDE), so it may be slow, e.g. to execute program loops
One high-level language statement may be several lines of machine code when compiled
The difference between an interpreter and a compiler is given below:
CompilerInterpreter
Scans the entire program and translates it as a whole into machine code.Translates program one statement at a time.
It takes large amount of time to analyze the source code but the overall execution time is comparatively faster.It takes less amount of time to analyze the source code but the overall execution time is slower.
Generates intermediate object code which further requires linking, hence requires more memory.No intermediate object code is generated, hence are memory efficient.
Compiler displays all errors and warning at the compilation time. Therefore, you can’t run the program without fixing errors. The interpreter reads a single statement and shows the error if any. You must correct the error to interpret next line.
It generates the error message only after scanning the whole program. Hence debugging is comparatively hard.Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy.
Store machine language as machine code on the disk.Not saving machine code at all. 
Generates output program which can be run independently from the original program.Do not generate output program. So they evaluate the source program at every time during execution. 
Programming language like C, C++ use compilers.Programming language like Python, Ruby use interpreters.

Compiler Vs Interpreter

NoCompilerInterpreter
1Compiler takes Entire program as input at a time.Interpreter takes Single instruction as input at a time.
2Intermediate Object code is generatedNo Intermediate Object code is generated
3It execute conditional control statements fastly.It execute conditional control statements slower than Compiler
4More memory is required.Less memory is required.
5Program need not to be compiled every timeEvery time higher level program is converted into lower level program
6It display error after entire program is checkedIt display error after each instruction interpreted (if any)
7Example: CExample: BASIC

Applications-software-and-programming-languages

Software – Applications software and programming languages

1 Software – Applications software and programming languages



2 Applications software

Applications software is designed to perform specific tasks.There are three main types of application software:
  1. Applications packages
  2. Tailor-made software
  3. General purpose packages


3 Applications packages

Examples of applications packages include:
Word processing software – MS Word, WordPerfect
Spreadsheet software – MS Excel, Lotus 1-2-3
Database software – MS Access

4 Integrated software
A common type of applications software found on home personal computers is integrated software.This is a software package that includes a collection of application software that shares a common set of commands.

5 Integrated software

A typical integrated software package will include:
  • A word processor program
  • A spreadsheet program
  • A database program
  • A graphics manipulation program

Integrated software packages have advantages and disadvantages.

6 Integrated software Advantages: Easier to use

Moving data between programs within the package is easy Cheaper than separate programs Disadvantages:
Tend to have weak areas (e.g. better at word processing than spreadsheets) Data is not easily moved to programs that are not part of the package Cheap is not always best!

7 Tailor-made software
Tailor-made software is very expensive because it is designed for a specific purpose.
It is software that is not available ‘off the shelf’ and is usually written or developed for large organisations (e.g. government, banks, insurance companies, manufacturers).

8 General purpose software

General purpose software is not specific to a particular user (e.g. MS Word), and may be capable of development into tailor-made software (e.g. MS Access).
It is very popular because it is usually relatively cheap, well tested, and has wide support (e.g. easy to use manuals and tutorials).

9 General purpose software

General purpose software is also known as ‘content free software’.

10 Programming languages

A program is a set of instructions that the computer can understand.
Programs are written in programming languages, and there are several different languages that can be used.
The choice of programming language depends upon who is writing the program and what they want it to do.

11 Programming languages

There are two levels of programming language. These are:
  • Low-level languages (including machine language/machine code and assembly language)
  • High-level languages


12 Low-level languages
Low-level languages are easy for the computer to understand but are more difficult for the programmer to write.

13 Low-level languages
The lowest-level is machine language or machine code.This consists of series of 1s and 0s and is often machine specific (i.e. it will only work on one type of computer).
All other programming languages have to be translated into machine code in order to work.

14 Low-level languages
Assembly language is not as low-level a programming language as machine code.
It uses simple instructions such as ADD, SUB, and LDA.
Assembly language needs an assembler to translate it into machine code.

15 High-level languages
High-level languages are easier to use because they are designed with the programmer in mind.
They are not machine-dependent and allow a program to be written so that it can be used on many different computers.
Many of the instructions in high-level languages are in American English.

16 High-level languages Examples of high-level languages are:

COBOL – is used mainly for business data processing.
BASIC – is mainly used as an introductory programming language in schools.

17 High-level languages Examples of high-level languages are:

C++ - is a popular language for developing commercial software.
LOGO – is mainly used in schools to teach pupils how to write simple control programs.

18 High-level languages Examples of high-level languages are:

JAVA – is particularly suited to writing programs that will search the Internet.
HTML – Hyper Text Mark up Language is used to develop websites.

19 Translation languages

Translation languages convert program commands into machine code.
There are two main types of translation languages.
These are:
  • Interpreters
  • Compilers


20 Translation languages

Interpreters convert each instruction into machine code, and then carry them out.
Compilers convert the whole program into machine code before carrying the instructions out.

21 Translation languages

  • Assembly language
  • High-level language
  • High-level language
  • Assembler
  • Compiler
  • Interpreter
  • Machine code