2.5 New Flashcards
(35 cards)
What is a low level language
A programming language that directly translate to machine code understood by the processor, allowing direct control over hardware components
Features of low level languages
-directly translates to machine code
-allows direct control over hardware
-written for specific processors to ensure they embed the correct machine architecture
-does not closely resemble a natural human language, making it harder for humans to understand and write in
-executes more quickly
Why are low level languages used
-when programmers need to write code that interacts directly with the hardware, such as device drivers
-when a program must be executed quickly
Machine code (first generation) features
-pure binary code that computers can directly process and execute
-tedious and difficult for humans for humans to understand and write this
-can be used when a programmer needs to perform a very specific command that cannot be done in high level language
-executed faster because it is in a format the CPU can execute and does not need to be translated
Features of assembly (second generation language)
-uses specialised command mnemonics to perform actions
-easier to understand and spot errors than machine code
-faster to execute than high level languages and can be used to directly control the CPU
-needs to be translates to machine code for the computer to execute it (one assembly instruction = one machine code instruction)
Advantages of high level languages
-complete control over the system components
-occupy less memory and execute faster
-direct manipulation of hardware
Disadvantages of low level languages
-difficult to write and understand
-machine dependent
-more prone to errors
-knowledge of computer architecture is key to program effectively
What are high level programming languages
Programming languages that use English like statements to allow users to program with easy to use code
Features of high level languages
-code that is similar to natural human language, easy to understand and use
-fewer errors and more powerful and complex commands than low level languages
-must be translated into machine code before it can run
-one instruction translates into many machine ode instruction
-clear debugging and programs are easier to maintain
(Needed due to development of processor speeds and increase in memory capacity
Advantages of high level programming languages
-Easier to read and write
-easier to debug
-portable(can run on different types of hardware) so can be used on any computer
-one line of code can perform multiple commands
Disadvantages of high level programming languages
-user is not able to directly manipulate the hardware
-needs to be translated to machine code before running
-program may be less efficient
What is a translator
A program that changes (translates) program source code into machine code so that it can be executed directly by a processor
what difference is there in the translation of high level languages and low level languages
-low level languages are translated using an assembler
-high level languages are translated using compilers or interpreters
interpreter
converts high level languages one line at a time into machine code and executes it
compiler
converts high level language into machine code for execution at a later time. The entire program is converted at once
how do interpreters translate and execute code
-an interpreter translate source code (high level code) into machine code one line at a time
-must be reinterpreted every time the program is run
-can run and be edited without translating the whole program
how do compilers translate and execute code
-a compiler translates all the source code into machine in one code
-produces an executable file that will run on other machines without the compiler needing to be installed
-only need to be translated once
-compiled programs have to recompiled after any changes are made
how do interpreters report errors
-the interpreter would encounter the errors and report it to the user immediately and stops the program from running
how do compilers report errors
the compiler analyses the entire program, taking note of where errors have occurred and records them in an error file, before it is run
difference in complexity of compiler programs and interpreter programs
-interpreters are smaller, simpler programs
-compilers are larger, complex programs
difference in execution speed of compilers and itnerpreters
-interpreters are slower as the code must be reinterpreted each time the program is run
-compilers produce more efficient code that interpreters making the compiled programs run faster, also do not have to be recompiled every time it is run
advantages of interpreters
-instructions are executed as soon as they are translated, requiring less RAM
-stops when a syntax error is found, errors spotted easily, easier to debug
disadvantages of interpreters
-slower execution
-must be translated every time it is run
-code is not optimised
-no executable file that can be distributed, source code must be supplied which can be modified without permission
advantages of compilers
-faster execution, code already translated
-optimises the code, less RAM and time
-executable file can be distributed, source code will not be seen