ebook img

Computer Programming Languages in Practice. Made Simple Computerbooks PDF

254 Pages·1985·9.723 MB·
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Computer Programming Languages in Practice. Made Simple Computerbooks

IN THE SAME SERIES Basic Computer Programming Languages in Practice Hardware Design Systems Analysis Word Processing for the Professions Computer Programming Languages in Practice Made Simple Computerbooks C. A. Hofeditz Made Simple Books HEINEMANN : London Copyright © 1985 William Heinemann Ltd All rights reserved, including the right of reproduction in whole or in part in any form whatsoever Phototypeset by Wilmaset, Birkenhead Printed and bound in Great Britain by Richard Clay (The Chaucer Press), Ltd, Bungay, Suffolk for the publishers, William Heinemann Ltd, 10 Upper Grosvenor Street, London W1X 9PA This book is sold subject to the condition that it shall not, by way of trade or otherwise, be lent, re-sold, hired out, or otherwise circulated without the publisher's prior consent in any form of binding or cover other than that in which it is published and without a similar condition including this condition being imposed on the subsequent purchaser British Library Cataloguing in Publication Data Hofeditz, Calvin A. Computer programming languages in practice.—(Made simple computer books)—(Made simple books) 1. Programming languages (Electronic computers) 2. Electronic digital computers—Programming I. Title II. Series III. Series 001.64'24 QA76.7 ISBN 0 434 98400 0 Introduction WHY LEARN TO PROGRAM? Despite the simplification of computer systems in the past few years, they are still complex tools. And there is a great difference between operating a machine and programming one. A user often has a tutorial display shown on the screen to guide him through a task. Even if such instructions are not provided, there is always an operator's manual to rely on for assistance. On the other hand, the programmer has to create the displays on the screen, determine how the computer performs, and write the operating instructions. Quite a difference, indeed. Somewhat like the difference between using a lawn mower and building one. It's not difficult to write simple programs in BASIC. Within a week and using no more than ten of the instructions in either of these computer languages, the beginner can have his computer performing many calculations and other tasks. Unfortunately, these tasks alone do not justify the cost of a computer and its software for they could be done with a calculator and basic instructions. Thus, the beginner is not likely to be satisfied with having developed only a rudimentary programming skill. There are, of course, many reasons why people would want to develop the ability to use computers and the programming languages available with them. All are related to self-interest. The Competition Will Use the New Tools The computer is a new tool that is rapidly becoming available to millions of people who have never used sophisticated equipment before. With respect to small businesses, computers properly xii Computer Programming Languages in Practice applied can greatly reduce operating costs. Small machines can be purchased or leased, and time on larger machines can be rented. These new tools and methods are available, and are being used by a great many small businesses now. Use of computers will spread even more quickly as prices continue to come down. The small businessman has no choice. He must learn to use these new tools to his advantage because the competition will. To Organize Jobs for the Computer But why does the computer user need to know anything about programming and programming languages? To organize jobs for the computer to process is one answer. There is much more involved in processing a stack of bills to be paid than sitting in front of a display screen and typing the information at the keyboard. Actually, the data entry at the machine is the last step in the organizing process. Before the power switch is turned on for the first time, the user must have determined which records are to be maintained and in what form, how the bill-paying process is to affect other records, and what the outputs are to be. The organizing of inputs, processing, and outputs for each task will always be required. The more the computer user knows about programming, the better he will be able to organize his jobs. To Understand the Products Offered Another good reason is to understand what you're buying. Differences in programs and programming languages have a dramatic effect on the performance of a computer. The sales sheets available to the prospective computer user aren't much help unless he is able to understand the material listed. Many programs are often provided only as extra-cost options. Even the lowest-priced retailer is offering programming language packages at £50 to £100 each. A poor choice of machine and programs can thus be very expensive to the owner of a small computer; not only in terms of actual cost but also in disappointing performance. It pays off, therefore, to understand the products being offered before buying them. Introduction xiii Do-It-Yourself Projects The fourth reason for learning to program may be the most important. It is the need to do it yourself. Although there are hundreds of programs available for the most popular computers, it may be difficult to find one that fits your task perfectly. The alternatives in this case are to change your methods to match the capacity of the program, to hire a programmer to prepare a customized program, or finally to do it yourself. As a Hobby and for Entertainment We haven't said much about personal computers so far, having concentrated on business use. But let's assume that you are interested in a personal computer. It's hard to define exactly what a personal computer is. We can say, however, that it is a small desktop unit, and if it has supporting equipment it is likely to be limited to a small printer and a disk drive. What does it do? Generally anything that a big machine does, only in smaller volumes and more slowly. As of this writing, personal computers are offered for sale at prices as low as £25. These are incomplete machines, however. They rely on using a TV screen for display and a cassette tape recorder for storage, but they are unable to communicate with other machines without optional adapters. A complete personal computer with diskette storage and a display screen still costs £500 and up. At these prices, it is an expensive 'toy,' so we have to assume that the buyer uses it for tasks other than entertainment. A wide variety of programs are available for the most popular personal computers. Most are optional, and they're not cheap. Therefore, one good way to get the most use out of a personal computer is to program it yourself. It should be an interesting hobby for those liking mathematics and electronics. Most readers interested in programming their own machines are likely to prefer BASIC, particularly a modern version. This is a good selection because it is widely offered with personal compu- ters, and the new versions have been developed fully to handle graphics and provide other features the novice programmer should find attractive. xiv Computer Programming Languages in Practice And as a Profession Skilled programmers are in great demand in the job market, and this should remain so for the foreseeable future. Many people in the computer industry believe that equipment development has outpaced the programs and considerable time will elapse before the programmers catch up. In general, an applicant for a programmer's job should have a degree in a field of learning that provides considerable training in mathematics. A good deal of the work involved in pro- gramming is similar to that necessary to lay out and solve a complex equation. In fact, the word 'algorithm,' which is seen in mathematics, is also frequently used to mean 'the programming solution to a problem.' WHY ARE THERE SO MANY LANGUAGES? The answer to this question is fairly simple. Computers have been used in business for over thirty years, while some models were used in engineering and scientific applications even before that. A great many models were developed during this time. As one would expect, programming groups were also busy providing languages for the various models, always trying to make the languages more powerful and easy to use. Logically then, many languages were produced. Among the most commonly used high-level languages are BASIC, COBOL, FORTRAN, Pascal, and RPG. We cover all but Pascal in this book but devote less attention to RPG, a language with a limited purpose and whose instructions are not in the same class as the others mentioned, and to FORTRAN, which is primarily intended for engineering and scientific applications. Any serious reader will have no difficulty in finding descriptions of at least five more high-level languages on a computer science bookshelf in a large bookstore. WHAT YOU'LL FIND IN EACH CHAPTER When one reaches the computer science section in a bookstore, one finds that most of the reference books dealing with program- Introduction xv ming languages are fairly large. A typical reference book on BASIC alone has as many pages as this one. How then can we hope to discuss such complex subjects within these covers? We'll answer that question in the following paragraphs. The largest portion of this book is devoted to two very popular languages—BASIC and COBOL. They have a good deal in common. Records, files, arithmetic operators, coding forms, and flowcharts, for example, are more alike than different from one language to another. Therefore, one general discussion of these subjects common to all languages is given in Chapter 2. Next, we have concentrated on the 'core' of each language, eliminating discussions of rarely used instructions and those that apply to only one brand of computer. Knowledge of uncommon instructions is of very little use to anyone other than a programmer of a specific model. We've also limited the number of sample programs to one per language. A great many programming books have an excess of sample programs and only the most dedicated reader ever uses them. These are some of the ways in which we've managed to 'boil down' a great deal of material to a usable size. Now let's examine how the material is organized and what you can expect to find in each chapter. There are five chapters, which are supplemented by a Glossary of Terms. Each chapter is followed by a self-test. The five chapters are: Chapter 1. What Programming Is 2. Components of a Programming Language 3. BASIC, Beginner's All-purpose Symbolic /nstruc- tion Code 4. COBOL, Common Business Oriented Language 5. Other Languages, Old and New Chapter 1, What Programming Is, provides the fundamentals: What programs are, how they are planned and organized, what elements of the computer the programmer controls, flowcharting, and how computer data is organized. Chapter 2, Components of a Programming Language, covers material common to all languages. It shows that each language is really a system, consisting of a set of words the programmer may use and a group of complex programs that interpret and apply those words. The entry program, the compiler, the run-time xvi Computer Programming Languages in Practice system are described, and their relationship to the programmer is shown. This chapter also discusses syntax diagrams and coding forms, which establish the sentences that may be used and the form in which they are provided. Next covered are topics common to all languages, including character sets, operators, variables, con- stants, expressions, arrays, functions, and procedures. Chapters 3 and 4, each deal with a specific programming language, covering BASIC and COBOL, respectively. Each chapter provides the following information: • A brief history of the language's development and use. • A description of how the programming system is organized. Its major components, divisions of instructions, and a description of its instruction set (instruction-by-instruction). • How a program is written, including a sample program. • A self-test, including exercises in which programming state- ments must be written. Chapter 5, Other Languages, Old and New, discusses those languages which the reader is less likely to use but should know about. Included are descriptions of FORTRAN and RPG II. This chapter does not provide programming examples but does show the instruction set and the appearance of a program. Also included in Chapter 5 are descriptions of recent additions to BASIC. 1 What Programming Is THE PURPOSE OF A PROGRAM Many people think of a computer as an intelligent machine; it is not. All the 'intelligence' is entered into the machine by man, either as part of the machine design or in the form of a program. The question to be asked then is: What is a program? And the answer is a very simple one: It is a set of instructions that make the computer perform a specific task. The instructions chosen must all be within the capacity of the computer to perform them, and they must be arranged in the proper order. Computer programmers originally had to choose from a set of instructions each of which executed a very small step. A great many instructions were necessary to perform even small jobs, and arranging the steps in order was a complex task, requiring a great deal of time and skill. Fortunately, high-level programming languages have been available for many years. A high-level language is one in which each instruction performs a recognizable operation rather than one small step. For example, a PRINT instruction in the high-level language called BASIC causes information to be shown on the screen. Actually, the computer must execute many small steps to produce the display, but a programmer using the high-level language does not have to be concerned about them. WHAT IS SOFTWARE? For many years the term 'software' has meant the programs that a computer executes. 'Hardware' has become the commonly used term for the equipment—it being 'hard' in the sense that it is not

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.