Translators and facilities of language Flashcards
How does an idea get from our brain to the CPU
Idea
Algorithm
Program language
Assembly language
Machine language
CPU
Machine code (Very Low Level Language)
. The CPU can only understand one type of code: Machine Code
. Made up of Coded Instructions and Data
. Each piece of machine code is stored as a binary number and then decoded and executed by the CPU’s logic circuits.
. This means that writing programs in ‘Machine Code’ is difficult for a human to do.
Assembly Language (Low Level Language)
This language has a small set of commands which represent certain pieces of machine code
This helped programmers as they didn’t have to remember sets of binary code, instead they learnt commands.
EG: Instead of memorizing what 1011 or 1001 meant, they just had to remember commands like ADD and SUB
These commands are known as Mnemonics (simple memory aids).
Assembly language is still quite difficult to learn and use and this is why High Level Languages were produced.
High Level Languages (Python, Java, C++)
High level code (aka ‘source code’) is far more easy to write and therefore for humans to understand.
Its purpose is to be easier to write AND STILL be easily translated into machine code so that it can be processed by the CPU.
To help it be translated, it makes use of:
KEY WORDS and SYNTAX
Translators
Translators are programs that convert high level language commands
into a set of machine code commands
so that the CPU can process the data
How do translators work
Take the whole code and convert it into machine code before running it (known as compiling).
Take the code one instruction at a time, translate and run the instruction, before translating the next instruction (known as interpreting).
What are the three types of translator
Complier
Interpreter
Assembler
Complier
Converts the whole code into one file (often a .exe file).
The file can then be run on any computer without the translator needing to be present.
Can take a long time to compile source code as the translator will often have to convert the instructions into various sets of machine code as different CPUs will understand instructions
Interpreter
Converts the source code into machine code 1 line at a time.
Program therefore runs very slowly.
Main reason why an interpreter is used is at the testing / development stage.
Programmers can quickly identify errors and fix them.
Assembler
This type of translator is used for Assembly Language (not High Level Languages).
It converts mnemonic assembly language instructions into machine code.
Integrated Development Environment (IDE)
An Integrated Development Environment (IDE) is a software package.
It provides the tools for a computer programmer to develop a software.
It allows programmers to write their high level code, test it and translate it.
What do IDE’s consist of
Source Code Editor – allowing the writing and editing of code
Interpreter – allows source code to be translated into machine code one line at a time for testing
Automation Tools – automate tasks such as finishing off key words and indenting on your behalf
Debugger – identifies logic and syntax errors and shows where they are.
Compiler – converts entire source code into machine code so it can be run as its own individual program file.
Auto-Documentation – stores lists of variables, modules, functions calls etc which are documented for other programmers.