Languages Flashcards
Programming languages
A program is a set of instructions that the computer can understand and enables a computer to perform a specific task
Since the computer can only understand binary code (series of 1s and 0s), all computer languages must be eventually reduced to binary code and the way this is done depends on the type of language used
There is a variety of computer languages and the one that is chosen for a specific job depends on the job being done
Programming language cateogories
Low-level languages
high-level languages
Low level languages
Closely related to the design of the machine
Available instructions reflect on the way the machine is built
These are related to the specific architecture and hardware of a particular type of computer
These are easy for the computer to understand but more difficult for the programmer to understand
Machine code and Assembly language are examples of low level languages
Programs are very small and executes very fast
Can write programs to control hardware directly
Machine language (machine code)
This is the language directly understood by the machine and it consists of a series of 1s and 0s
Due to this it is difficult to understand
All other programs written in high-level or assembly language must be translated into machine code before the instructions can be carried out
Machine code is often machine specific, which means that one computer’s machine code will not be understood by a different type of computer (depending on the manufacturer)
Due to this machine code is non portable
A program written in machine code needs no translation and therefor very fast
A lot of games and simulation programs are written in machine code for this reason
Translator
Computer program used to convert a program from one language to another
This is a general name for three types of translation programs, assembler, compilers and interpreters
Source code
High level language or assembly code as written by the programmer, that a compiler or assembler, respectively, can convert to object code
Object code
Machine code that a complier or assembler produces from higher level source code.
This is the translated source code
Often this will be machine code, but might also be an intermediate code, which has to further translated before it can be executed
Assembler
A program that translates (assembles) a program written in assembly language into machine code
Compiler
A software that translates a program written in high level language (source code) in one go (source code translated all at once) which can then be saved and executed later without the presence of a compiler
Usually had the .exe extension
Interpreter
Translates high level source code, but at one line at a time and then executes it
No object code is produced, so the program has to be interpreted each time it is run
Interpreter program must be present for the program to run
Advantages of a compiler over an interpreter
The object code can be saved on the disk and run whenever required without the need to recompile, however if an error is discovered the whole program needs to be recompiled
The object code executed faster than interpreted code
The object code produced by the compiler cannot be distributed or executed without having to have the compiler present
The object code is more secure, as it cannot be read without a great deal of ‘reverse engineering’
Disadvantages of compiler
A compiler cannot produce any object code unless the whole program is correct- they tend to report a lot of errors initially, making it harder to debug a program
Need the whole program to recompile cannot run partially created programs
Advantages of a interpreter over a compiler
Useful for program development as there is no need for lengthy recompilation each time an error is discovered
Interpreters find errors when it happens and tells the user what has gone wrong
It is easier to partially test and debug programs
Disadvantages of Interpreter
Programs tend to run slower using an interpreter because the interpreter has to translate the source code while the program is running and each time the program is running
Will a programmer use a interpreter or compiler
Typically, a programmer might use an interpreter during program development
A program that is tested and ready for distribution would then be compiled and saved object code would be distributed