Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
PROGRAMMING 1.doc
Скачиваний:
37
Добавлен:
12.11.2018
Размер:
1.99 Mб
Скачать

PROGRAMMING

KEY INFORMATION SECTION 1

Programming is the process of preparing a set of coded in­structions which enables the computer to solve specific prob­lems or to perform specific functions. The essence of computer programming is the encoding of the program for the computer by means of algorithms. The thing is that any problem is ex­pressed in mathematical terms, it contains formulae, equations and calculations. But the computer cannot manipulate formu­lae, equations and calculations. Any problem must be specially processed for the computer to understand it, that is - coded or programmed.

The programs are lists of instructions that will be followed by the control unit of the central processing unit (CPU). The instructions of the program must be complete and in the appropriate sequence, or else the wrong answers will result. The purpose of programming is to create a program that demonstrates a certain desired behaviour (customization). Said another way, programming is the work of transforming requirements into something that a computer can execute.

Steps in writing a program

The phase in which the computer programs are written is called the development phase. To write a program, software developers usually follow these steps.

  • First they try to understand the problem and define the purpose of the program.

  • Then they design a logical plan of the program. There are two common techniques for planning the logic of a program.

A flowchart to calculate

income tax

The first technique is flowcharting. A flowchart is a plan in the form of a graphic or pictorial representation that uses predefined symbols to illustrate the program logic. It is, there­fore, a "picture" of the successive logical steps to be performed by the computer. Each of the predefined symbol shapes stands for a general operation. The symbol shape communicates the nature of the general operation, and the specifics are written within the symbol. A plastic or metal guide called a template is used to make drawing the symbols easier.

The second technique for planning program logic is called pseudocode - an imitation of actual program in­structions. It allows a program-like structure without the bur­den of programming rules to follow. Pseudocode is less time-consuming for the professional programmer than is flowcharting. It also emphasizes a top-down approach to program structure.

Pseudocode has three basic structures: sequence, decision, and looping logic. With these three structures, any required logic can be expressed.

  • Next they write the program instructions. This is called coding. The instructions will be written on a form called a coding form. The instructions we write will be recorded in a machine-readable form. The instructions must be written according to а set of rules that are the foundation of a programming language.

  • When the program is written, they test it: they run the program to see if it works and use special tools to detect bugs, or errors. Any errors are corrected until it runs smoothly. This is called debugging, or bug fixing. Debugging is a very important task in the software development process, because an incorrect program can have significant consequences for its users. Some languages are more prone to some kinds of faults because their specification does not require compilers to perform as much checking as other languages.

There are two kinds of errors or bugs with which programmers must deal.

The first type is the coding error. Such errors are syntax errors that prevent the language processor from successfully translating the source program to object program code. The language processor identifies the nature and the location of the error on the source program listing, so these errors are relatively easy to find and correct.

The second type of bug is the logic error. The computer program can be successfully translat­ed, but the program does not produce the desired results. These errors are generally much more difficult to find and to correct than are coding errors. Logic errors can be avoided through careful planning of the program logic.

  • Finally, software companies write a detailed description of how the program works, called program documentation. They also have a maintenance program. They get reports from users about any errors found in the program. After it has been improved, it is published as an updated version.

Vocabulary practice section 1

1. Complete the following definitions with the words and phrases in the box.

the various parts of the program may occur in programs language binary numbers a given problem instruction

1. algorithm

The step-by-step specification of how to reach the solution to …….

2. flowchart

A diagram representing the logical sequence between …….

3. coding

The translation of the logical steps into a programming …….

4. machine code

The basic instructions understood by computers. The processor operates on codes which consist of …….

5. debugging

The techniques of detecting, diagnosing and correcting errors (or "bugs') which ……..

2. Complete these steps in the writing of a program using the words from the box.

debug documentation flowchart problem compile instructions

1. Understand the ……. and plan a solution.

2. Make a ……., which shows the steps of the program.

3. Write ……. in a programming language.

4. ……. the program – that is, turn it into machine code.

5. Test for errors and ……. the program.

6. Prepare ……. , for example the instruction manual.

3. Put these programming steps into the correct order. Explain what each step means.

KEY INFORMATION SECTION 2

Programming languages

Computers cannot understand ordinary spoken English or any other natural language. The only language they can understand and execute directly is called machine code. This consists of the 1s and Os (binary codes) that are processed by the CPU.

Machine code as a means of communication is very difficult to write, so we use symbolic languages that are easier to understand. The translation of symbolic instructions to machine code is accomplished through the use of a special program called a language processor. There are three types of language processors: assemblers, compilers, and interpret­ers. Each translates symbolic instructions to machine code, but each does it differently.

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that specify the behavior of a machine, to implement algorithms precisely. A programming language must convey the logical steps of the program plan so that the control unit or the CPU can interpret and follow the instructions. A programming language's surface form is known as its syntax. Most programming languages are purely textual; they use sequences of text including words, numbers, and punctuation, much like written natural languages. On the other hand, there are some programming languages which are more graphical in nature, using visual relationships between symbols to specify a program. Programming languages have improved throughout the years, just as computer hardware has improved. They have progressed from machine-oriented languages that use strings of binary 1s and 0s to prob­lem-oriented languages that use common mathematical and/or English terms.

The so-called assembly languages use abbreviations such as ADD, SUB, MPY to represent instructions. These mnemonic codes are like labels easily associated with the items to which they refer. Basic languages, where the program is similar to the machine code version, are known as low-level languages. In these languages, each instruction is equivalent to a single machine code instruction, and the program is converted into machine code by an assembler. A low-level language does not need a compiler or interpreter to run; the processor for which the language was written is able to run the code without using either of these. These languages are still quite complex and restricted to particular machines. Machine code and assembly languages are called low-level languages because they are close to the hardware and provide little or no abstraction from a computer's instruction set architecture.

To make the programs easier to write and to overcome the problem of intercommunication between different types of machines, high-level languages were designed such as BASIC, COBOL, FORTRAN or Pascal. These are all problem-oriented rather than machine-oriented. High-level languages are closer to human languages; they

use forms resembling English, which makes

programming easier; they provide strong

abstraction from the details of the computer and hide the details of CPU operations, they are more portable across platforms. Programs written in one of these languages (known as source programs) are converted into a lower-level language by means of a compiler (generating the object program). On compilation, each statement in a high-level language is generally translated into many machine code instructions. Some languages are interpreted by an interpreter program, which converts the program into machine code one line at a time as each line is required by the processor. A compiled program only needs to be compiled once, but an interpreted program needs to be interpreted every time it is used. Compiled programs are faster than interpreted programs.

Different programming languages support different styles of programming (called programming paradigms).

The details look different in different languages, but a few basic instructions appear in just about every language:

  • input: Get data from the keyboard, a file, or some other device.

  • output: Display data on the screen or send data to a file or other device.

  • math: Perform basic mathematical operations like addition and multiplication.

  • conditional execution: Check for certain conditions and execute the appropriate sequence of statements.

  • repetition: Perform some action repeatedly, usually with some variation.

The languages used to create Web documents are called markup languages; they use instructions (markups) to format and link text files. Examples are:

HTML (Hyper Text Markup Language) - the code used to create Web pages. It is a page description language used for creating webpages.HTML uses a system of tags to mark page links and formatting. For example, the tag <u> tells the program to start underlining a text. Although programs cannot be created using HTML, small programs can be embedded in HTML code using a scripting language like JavaScript.

VoiceXML - it makes Internet content accessible via speech recognition and phone.

Instead of using a web browser on a PC, you use a telephone to access voice-equipped websites via a VoiceXML interpreter (a voice browser). For input, VoiceXML uses voice recognition. For output, it uses pre-recorded audio content and speech synthesis (text-to-speech). You just dial the phone number of the website and then give spoken instructions, commands, and get the required information. A typical VoiceXML page could be ‘sports. vxml’

People communicate instructions to the computer in symbolic languages and the easier this communication can be made, the wider the application of computers will be. Scientists are already working on Artificial Intelligence and the next generation of computers may be able to understand human languages.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]