Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Low-level (machine code & assembly language) High-level languages A program is always written in a specialized language.

There are a number of categories of language, each exhibiting different characteristics. Machine code Each CPU has its own particular basic set of instructions; a CPU can only 'understand' an instruction if it is taken from this set of instructions. These instructions, known as machine code, consist of strings of 1s and Os. A typical instruction might be 01101010 0110 1011. The first programs were written in machine code in the 1940s. Writing in machine code is extremely difficult. Not only must the programmer think in terms of 1s and Os when writing code, it is almost impossible to understand code once written. This leads to further difficulties if the program does not perform as intended - that is, has a bug. Programs are rarely written in machine code nowadays. Assembly language is used. Assembly language Assembly language overcomes some of the difficulties of programming in machine code. . The instructions use mnemonics such as 'ADD' or 'STO' (store) instead of binary. A typical instruction might be 'ADD Rl,R2,R4' - add the contents of registers 1 and 2 and put the result in register 4, References to memory locations are replaced by reference to named memory areas. The use of binary to represent numbers is replaced by decimal or hexadecimal (a number system having a base of 16). Groups of instructions that are to be repeated many times in a program can be defined and named. These are called macros. These differences mean that programming with assembly language is much easier than with machine code. Assembly languages were developed very early in the history of the electronic computer. Once written, an assembly language program needs to be translated into a machine code program. This is achieved by an assembler program. This,' straightforward program takes the original source program and translates it instruction by instruction to become the final machine code object program capable of being run on the computer. Assembly languages are an improvement on machine code in terms- of the ease of program production, but they do have some drawbacks: Each different type of processor has a different set of instructions and a different assembly language. Assembly language programs are therefore not portable from one type of machine to another . The assembly language is machine-oriented. Reference is made to registers in the ALIJ and memory locations. In writing an applications program, Cl programmer would prefer to concentrate on the task to be coded rather than physical aspects of the machine on which the program is to be finally run. . Because each task must be specified in detail, programming is very timeconsuming. Assembly languages are context free; they do not provide specific instructions for writing programs in particular problem domains such as business or scientific situations. The main advantage of programs written in assembly language, as distinct from programs written in high-level languages covered in the next section, is that operations

, I
.)

:.

can be specified in detail, making the most efficient use of the machine. This leads to the production of programs that run quickly on the computer. Assembly language programming is used for systems software, where high-speed program execution is required. High-level languages High-level languages were developed to increase the productivity of programmers. These languages are task- rather than machine-oriented. This means that instructions in them are more suited to the types of application on which the programme is employed than to the machines on which the programs will finally run. Different types of application have spawned different types of high-level language. Well-known languages include: COBOL (Common Business-Oriented Language): COBOL was developed in 1960/61 as a general-purpose business data-processing language. It is particularly suitable for processing large numbers of records. COBOL was a widely used commercial language. It conforms to standards set by ANSI (American National Standards Institute) and CODASYL (Conference of Data Systems Languages). Although versions do exist for desktop computers, COBOL is used most extensively for business applications running on minicomputers and mainframes. FORTRAN (Formula Translator): FORTRAN is a language developed in the 1950s specifically for the purposes of scientific and mathematical work. It is rich In its ability to handle formulae. BASIC (Beginners All-Purpose Instruction Code): BASIC was developed in 1963 and 1964 at Dartmouth College as a language that could be learned and understood very quickly by students. It is now embedded in Microsoft's Visual Basic programming environment. C and C++: The C programming language has always been popular with experienced programmers. It allows for the construction of very terse code that can, required, control the machine at a 'very low level. By accessing registers and memory locations directly, programs can be highly optimized for speed of execution. Code is arranged into functions, with each function performing a logically cohesive task. There is a clear specification of what data is allowed to flow' between functions. The aim is to ensure that programs once written are easily understandable, testable and amendable. C++ is a development of the C language. It provides additional programming constructs and structures that allow for the creation of objectoriented programs. Java: The growth in the Internet and developments in web page construction have Led to a sudden increase in interest in the Java programming language. Java has a similar set of instructions to C++ and a number of additional features that make it well suited to developing programs for web p8ges. Small blocks of code called Java applets can be stored on web servers. When a client requests a web page containing applets, the applet code is transferred to the client and run inside the client's web browser. Ada: The Ada programming language is named after Ada Augusta, daughter of Lord Byron. It is sponsored by the US Department of Defence for use in military application

PROLOG: PRO LOG is a language specifically designed for writing programs that require reasoning as distinct from record processing, text handling or number crunching. It is therefore used in artificial "intelligence applications. Unlike other languages previously covered, which are all based on writing code for procedures to carry Out tasks, PRO LOG is designed to be able to declare states from which implications are then derived. PROLOG and another popular artificial intelligence language, LISP, are playing a large role in the development of future intelligent business applications.

The languages discussed constitute a selection of some of the more important highlevel languages in current use. There are many more. There are several advantages to using high-level languages compared with low-level assembly languages: It should be clear from the descriptions that high-level languages are task-oriented, and there are different types of language for different types of programming requirement. This increases programmer productivity. High-level languages also increase programmer productivity because each high level instruction will eventually be relatively straightforward to learn, often using expressions that are near English. Some, such as BASIC, are so straightforward that simple programs may be written after an afternoon's study of the language. Training times for programmers are reduced and programming requires less qualified personnel. Programs written in high-level languages should be portable from one type of machine to another. In practice, this is unlikely because of differences in dialects. However, changes that are necessary are often minor.

In order for a source program in a high-level language to run on a computer it needs to be translated into a machine code object program. This translation may be by interpreting or compiling. In each case, the translation is carried out by software. When a program is interpreted, as each line is translated into object code it is immediately executed. In contrast, when a program is compiled a compiler program translates the entire source program into object code. The object program can then be executed. Once compiled object code is produced, it can be used again and again without the need for the source program. Applications software producers prefer to release their packages as compiled code. Compiled code is difficult to understand and so is difficult to alter. This prevents unauthorized tampering with programs. In contrast, no permanent object code is produced when a source program is interpreted. Moreover, the interpreted program will run less quickly than the compiled version. This is because of the necessity for the translation as well as the execution of instructions each time the program is run. Interpreting is popular in the writing of programs because there is no need to compile the entire program each time an alteration is made to it. Compared with assembly language programs, high-level language programs, whether interpreted or compiled, always run more slowly. This js partly because inefficiencies occur in the process of compiling or interpreting, even though optimization procedures are used. It is also partly beG1USe the machineindependent nature of high-level languages prevents programmers using their knowledge of the internal structure of the CPU to increase run-rime efficiency. These shortcomings are not enough to deter the use of high-level languages in business applications, where the increases in programmer productivity and the other advantages outweigh the runtime considerations.


A program is an organized list

TRANSLATORS

of instructions that, when executed, causes the computer to behave in a predetermined manner. Without programs, computers are useless. A program is like a recipe. It contains a list of ingredients (called variables)and a list of directions (called statements) that tell the computer what to do with the variables. The variables can represent numeric data, text, or graphical images. There are many programming languages -- C, C++, Pascal, BASIC, FORTRAN, COBOL, and LISP are just a few. These are all high-level languages. One can also write programs in low-level languages called assembly languages, although this is more difficult. Low-level languages are closer to the language used by a computer, while high-level languages are closer to human languages. Eventually, every program must be translated into a machine language that the computer can understand. This translation is performed by compilers, interpreters, and assemblers. When you buy software, you normally buy an executable version of a program. This means that the program is already in machine language -- it has already been compiled and assembled and is ready to execute.

Compiler

of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter. Every high-level programming language (except strictly interpretive languages) comes with a compiler. In effect, the compiler is the language, because it defines which instructions are acceptable. Because compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language. For example, there is a FORTRAN compiler for PCs and another for Apple Macintosh computers. In addition, the compiler industry is quite competitive, so there ~re actually many compilers for each language on each type of computer. More than a dozen companies develop and sell C compilers for the Pc.

INTERPRETER
A program that executes instructions written in a high-level language. There are two ways to run programs written in a high-level language. The most common is to compile the program; the other method is to pass the program through an interpreter. An interpreter translates high-level instructions into an intermediate form, which it then executes. In contrast, a compiler translates high-level instructions directly into machine language. Compiled programs generally run faster than interpreted programs. The advantage of an interpreter, however, is that it does not need to go through the compilation stage during which machine instructions are generated. This process can be time-consuming if the program is long. The interpreter, on the other hand, can immediately execute high-level programs. For this reason, interpreters are sometimes used during the development of a program, when a programmer wants A program that translates source code into object code. The compiler derives its name from The way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. Thus, 'a compiler differs from an interpreter, which analyzes and executes each line of source code in succession, without looking at the entire program. The advantage to add small sections at a time and test them quickly. In addition, interpreters are often used in education because they allow students to program interactively. Both interpreters and compilers are available for most high-level languages. However, BASIC and LISP are especially, designed to be executed by an interpreter. In addition, page description languages, such as Postscript, use an interpreter. Every PostScript printer, for example, has a built-in interpreter that executes PostScript instructions. ASSEMBLER (basically a program that translates assembly language into machine code) To get from source code to machine language, the programs must be transformed by a compiler. The compiler produces an intermediary form called object code. Object code is often the same as or similar to a computer's machine language. The [mal step in producing an executable program is to transform the object code into machine language, if it is not already in this form. This can be done by a number of different types of programs, called assemblers.

You might also like