High Level & Low Level Languages
High Level & Low Level Languages
Lesson Objectives
High-level and low-level languages
Languages that interact directly with hardware
How programs are converted to binary form
Different types of programming errors
Integrated development environment
How a program written on one platform is run on a different platform
Programs

- A computer program can be defined as a set of instructions that enables a computer to perform a specific task.
- Programs can be written in high-level or low-level languages, according to the requirements of the user.
High-level languages
- High-level languages enable a programmer to write programs for a computer without the knowledge of the hardware and instruction sets of that computer.
- Portable programs: can be used in different systems
- For example: Java, C++, and Python
- The same programming concept can be applied to different high-level languages.
Low-level languages
- Low-level languages are specific to hardware and include assembly language and machine code.
- Each hardware has a different instruction set.
- The instruction set is the list of instructions such as ADD, SUB, INC, DEC, etc.
- Low-level languages are related to the hardware architecture and its instruction set.
- There are two types of low-level languages:
* Machine code, binary instructions that are understandable by the computer.
* Assembly language that needs to be converted to machine code.
Instruction

- An instruction consists of two parts: Operator and Operand.
- An operator is a part of an instruction that tells the CPU about the operation to be performed.
- The operand is that part of instruction that represents the data or memory location where the operation is required to be carried out.
Assembly languages

- Assembly language is used by programmers to make use of special hardware.
- Instructions used are dependent upon the type of machine.
- The code does not take up much space of primary memory and performs its task quickly.
- Code to add two numbers is given.
- In instruction, ADD AX, [15]. ADD is an example of instruction.
- The numbers in registers AX and 15 are examples of operand.
Machine Code

- Machine code is written in hexadecimal or binary form.
- It is hard to understand and complicated to manage the storage and manipulation of data.
- Code to add two numbers is given.
- It can be noticed that the code is not understandable.
- The opcode is a part of an instruction that tells the CPU about the operation to be performed.
Translators

- A utility program that translates the program written by programmers and codes in assembly language into binary form, which is understandable by the computer, is called a translator.
Assembler

- A computer program that translates a program written in an assembly language into machine code.
- Sometimes, assembly language programs are converted to an intermediate code called bytecode.
- Once assembled, the same code can be used again multiple times without re-assembly.
- Processors based on different architectures have different assembly language instructions.
- The input to the assembler is called source code.
Compiler

- A computer program that translates a program written in a high-level language into machine code that can be directly used by a computer to perform required tasks.
- Once compiled, the same code can be used again multiple times without recompilation.
- A compiler optimizes the code, and errors are picked up only after the complete compilation of a program.
- Once a code is compiled, it is hard to convert it back to its source code.
- Hence, it is hard to modify compiled codes.
- The program in a high-level language is source code.
- Hardware-specific object code is produced.
- Different platforms will require different compilers.
- Windows OS + intel processors → platform.
- Apple’s operating system + PowerPC → platform.

Interpreter

- A computer program reads a statement from a program written in a high-level language, converts it into intermediate code, and then proceeds to the next statement and so on.
- Intermediate code: assembly language
- This intermediate code is then converted to machine code and then, executed.
- In case an error is found, the interpreter prompts the user to correct the error.
- Code does not get optimised.

- The interpreter finds out errors before the execution of the program.
- Syntax error in Python IDE for missing semicolon.




Programming errors: Syntax errors

- Programing language has a set of rules. If these rules are not followed, the program cannot be translated. This leads to syntax errors.
- When a program is compiled, if syntax errors are found, the user is notified about the line numbers of the error.
- When a program is interpreted, if a syntax error is found, the interpreter stops, and the user is notified about the line number of the error. After correction, the interpreter resumes.
Programming errors: Logic errors

- When a program runs, if it produces incorrect or unexpected results, it is said to contain logic errors.
- To identify the correct position of the error, test data is used.
- Tracing is done at each and every statement and compared with the expected results.
Integrated Development Environment (IDE)

- An integrated development environment consists of an editor with an interpreter and/or compiler and debugging tools.
IDE: debugging tools
- The tools provided by an IDE to check and correct errors are called debugging tools.
- The interpreter or compiler runs error diagnostics on the program, when the programmer tries to saves it.
- Syntax errors are identified and the IDE allows the user to correct the errors. Then the user saves the program, IDE runs error diagnosis again. This process repeats until all syntax errors are corrected and the program is converted to machine code. When it is run again, IDE identifies any runtime error present.
IDE: editor
- The Editor is a tool used by the programmer to write, edit and save codes.
- The editor looks like a word processor, but formatting options are not provided because formatting could contaminate the embedded codes.
- Editors also make the process of writing codes simpler. The codes written using s are more readable.
- Conditional and iterative statements are identified, and the statements to be executed for a condition or in a loop are indented.
- Variables are presented in different colors too.

- IDE is used for Python programming called IDLE.
- The colored statements and indentations help us to understand the program.
Run time environment
- A run-time environment allows the user to run a program on a platform that is different from the one in which it was created.
- This environment only runs the program but does not allow the user to edit the program.
- Due to this facility, a developer can write code that can be executed on many platforms.
- For example: A website has a feature that is written in another programming language such as Java.
- Plug-ins are installed in some platforms for specific codes to be executed.
- These plugins create a virtual machine that is a simulation of a particular computer system and allows the program to run in an environment that is different from the one in which it was created.
Related Worksheets: