Program- set of instructions written in the language that the computer understands, so as the computer can run.
They have to be installed into the computer for it to run Set of instructions written in the language a computer understands for the computer to perform a specific task. The computer interprets a program s instructions if the program is stored within the computer. System includes programs with associated documentation to control the way the computer operates and facilitates extending the general capabilities of the system. A system includes input, process and output. A computer system may therefore refer to the group of hardware and associated software designed and assembled 2gether to perform a specific task or a group of functions. A computer is a programmable machine that receives input, process and produces output in a useful format Software refers to all various programs together with their associated documentation that may be used on a computer system. Application software is the software designed to be put into specific practical use. Includes; A) Specialized application software:- Are programs with associated documentation designed to perform specific particular tasks e.g. business software, educational software.. B) Application packages:- R suites of programs with associated documentation used for a particular time of problem. Most packages can be used for a variety of similar problems e.g. ms office suite System software are programs and associated documentation that are designed to control the way the computer operates and provides facilities extending the general capabilities of a computer. e.g. operating systems, comp. utilities, compilers and interpreters.
Any errors that the compiler detects are called compile-time errors or syntax errors. it stops compiling and reports the error to you. In the case of Pascal programs. The compiler has another task apart from translating your program. C++ and Ada. If it finds so much as one syntax error. including Pascal. say.pas and the Pascal compiler would translate it into the file myProg.exe using. then hand it to the compiler which translates it. a text editor. but it does it at the moment the program is run. You write the program using a text editor or something similar. one line at a time. It takes the program. then it would just appear as gobbledy-gook. so if it comes across lines of the
. then translates the second line and runs it etc. It also checks it to make sure that it is grammatically correct. The interpreter has no "memory" for the translated lines. If you tried to examine the contents of myProg. and translates each line before running it: It translates the first line and runs it.Compilers were the first sort of translator program to be written. for instance. you might write a program called myProg. The idea is simple: You write the program. Interpreters An interpreter is also a program that translates a high-level language into a low-level one.exe which you could then run. Here is an example of the C++ compiler reporting a whole list of errors:
Most "serious" languages are compiled. Then you run the result. Only when it is sure that there are no grammatical errors does it do the translation. The compiler takes the file that you have written and produces another file from it. and then instruct the interpreter to run the program.
program within a loop. as we will see in a later section. and spotted any grammatical errors in the process. The interpreter must also translate that line 1000 times. interpreted languages do have their uses. for instance. They can spot syntax errors while the program is being compiled (i. Different versions of the
. as they run on different pieces of hardware. we programmed in Pascal on the old PDP/11 machines. They tend to be more "portable".e.e. For instance. we ran a compiler program (called pc) which compiled the program to a low-level version. for it to compile. you are informed of any grammatical errors before you try to run the program). So which is better? Well. the version of the BASIC interpreter for the PDP series computers is different from the QBasic program for personal computers. but programs written in BASIC are identical from the user's point of view. this does not mean that a program that compiles correctly is errorfree!
The main advantages of interpreters are as follows:
10 FOR COUNT = 1 TO 1000 20 PRINT COUNT * COUNT 30 NEXT COUNT
Line 20 of the program displays the square of the value stored in COUNT and this line has to be carried out 1000 times. i.
Some computer systems try to get the best of both worlds. As soon as you have written a program. that depends on how you want to write and run your program. The main advantages of compilers are as follows:
They produce programs which run quickly. This is because each machine can have its own interpreter for that language. which means that they will run on a greater variety of machines. Firstly. We then ran an interpreter program which took the output of pc and ran it.
so a variable "count" in a program would have the label corresponding to its name ("count") and the type "variable name". important words such as if. is syntactically correct. The tokens are keywords of the language i.). print or repeat). may be syntactically correct. and then moving on to the next line. it reports it to the next stage of the process.the order of the tokens is wrong. and they have no function. It involves turning the program from a series of characters into a series of tokens that represent the building blocks of a program.g. and as soon as it recognises a legitimate token. The tokeniser is also responsible for ignoring comments in the program . *. The process may be summarised in this diagram: Tokenising p Syntax analysis p Semantic analysis p Translation Tokenising This part of the process is also sometimes called Lexical Analysis. variable names and mathematical operators (+.e. each taking as its input the same output from pc How does a compiler work? Compiling a program takes several stages of processing. then it is semantically incorrect!
. with the exception that the interpreters translate each program one line at a time before running it. Each token has a label and a type. The principles which are explained below also apply to interpreters. This refers to aspects such as whether the variables have been declared. For instance. but if the variable xyz has not been declared. brackets etc.these are words and phrases inserted purely for the benefit of any human reading the program. Semantic Analysis The word "semantics" refers to meaning. the instruction xyz++. which I have outlined below.xyz+ is not . in C++. Syntax Analysis Syntax means "grammar" and the syntax analyser in a compiler checks that the right tokens appear in the right order to make grammatically correct instructions. but the instruction +.low-level interpreter could be written for different machines in the PDP range. and the semantic analyser checks the meaning of the program. xyz++. The tokeniser takes each of the characters in turn. e.
or subroutines. but whether the program has entered or left loops. Translation
. whether classes are accessed correctly etc.The semantic analyser checks not only variable declarations and scope.