1/25
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What will computers only understand?
Computers only understand data and instructions in machine-code form.
How do we solve the issue(computers only understand machine code)?
Any high-level language or low-level language needs to be translated into machine code for the computer to be able to process it and carry out instructions.
What are the three types of translators?
A compiler; an interpreter; and an assembler.
What does a compiler do?
takes code written in high-level language and translates it into machine code
translates the whole of the source code in one go
runs through a program and produces a report of errors it detects(error handling) - won’t compile with errors
outputs machine code in an executable file - can be stored for future use
takes time to initially run the program - but will run it much more quickly once compiled
uses more meomry to generate the executable file
What is source code?
Source code is the code produced when we write a program in a high-level language
High-level languages
written in formal, structured English
made it easier to read, maintain and debug code
one line of this code translates to dozens of code lines in assembly language and machine code
Assembly language
makes opcodes easier to read
used a mnemonic and an operand to form an instruction
each line of assembly language = one line of machine code
Operation code
also known as opcode
written in tables to help programmers enter instructions by hand for programs
still time consuming
Grace Hopper
An important person in computing who conceived the idea of a compiler to translate plain English into machine code. Also, introduced the idea of high-level languages.
What is machine code?
A binary representation of instruction - format that the CPU can decode and execute. Has opcode instructions and addresses to use(operand).
Low-level languages
written in assembly language
translated by an assembler into machine code
used for embedded systems and device drivers - need to instruct hardware directly
What does an interpreter do?
takes source code and translates it into machine code
translates the source code one line at a time
errors are detected when the line of source code is reached - allows us to fix error and run code through interpreter again
takes up less memory than a compiler
Advantages of writing in low-level languages
faster execution - machine code doesn’t need to be trabslated
direct control of hardware and memory
usually means shorter code - less memory and storage
fast translation - assembly language is 1:1 to machine code
allows you to program for a specific type of processor
Disadvantages of writing in low-level languages
requires deeper understanding of computer’s hardware
code is specific to one processor - hard to transport code to other platforms
harder to write and understand
more error prone - more hardware management and debugging
Advantages of writing in high-level languages
easier to understand and faster to program and debug - it’s closer to stadard English
high level of abstraction from underlying hardware
usually doesn’t require us to deal with emmory management
not specific to one type of processor - portable between different platforms
Disadvantages of writing in high-level languages
slower to execute - computer needs extra time to translate source code into machine code
programmers have less control over emmory and hardware
unsuitable for embedded systems
slower translation - higher line ratio to machine code than assembly language
What is an IDE?
It is an integrated development environment; these programming environments have additional features that help and guide us while we’re writing programs.
What does a code editor in an IDE do?
A code editor allows us to write and edit code for our program. They have helpful aids like: automatic line numbers, colour coding for different commands; autocorrect for commands we mistype; and auto-indent for any iteration or selection.
What does a run-time environment in an IDE do?
A run-time environment is a window in the IDE where we can see the output of the code. It allows us to create and edit our code more quickly and efficiently.
What do error diagnostics in an IDE do?
In a compiler, this is an error report and in a translator, this is a error message. They help us identify where we have made a mistake so we can fix it.
What does a translator in an IDE do?
Each IDE either has a built-in complier or a built-in interpreter. They allow the source code that we write in a high-level language to be translated into machine code that can be understood and ran by the computer.
What do usability functions in an IDE do?
Usability functions allow us to change font types and sizes in the IDE. It also allows us to customise how the code is highlighted.
What are the three main programming constructs?
Sequence, selection and iteration.
What are the five main data types?
An integer; a string; a float or real; a Boolean; and a character.
What is a sub-program?
A sub-program is a program where we can store sections of instructions that we may want to use in our main program. There are two main types: a function and a procedure.
What are the two main types of errors?
The two main errors that can occur when writing programs are: syntax errors and logical errors