📄 vel01.htm
字号:
<HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Many people use computers all day long for word processing, database storage, and spreadsheet analysis, without realizing what is going on behind the scenes. You must always keep in mind that computers cannot think. Your computer does not know how to be a word processor. If you want your computer to do word processing, you must supply detailed instructions in the form of a program. Only by following the detailed instructions of a word processor program that you load can your computer perform word processing.<BR><P>It would be nice if writing a program is as easy as telling the computer what you want done. Many people can handle ambiguous instructions, but computers are not smart enough to understand vague requirements. Computers can only follow orders given to them, and you must supply those orders in the form of a program. Therefore, you must supply the programs that you write. Writing programs, especially complex programs, takes time and several procedural steps. Visual Basic speeds the process of creating programs, but even with Visual Basic some programs take time to write and perfect.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: </I>A <I>bug</I> is a program error.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Figure 1.1 shows you the typical steps that most programmers go through when writing programs. First, you have an idea for a program. Next, you use a program-development system, such as Visual Basic, to write the program. Errors, or <I>bugs,</I> often appear in programs because of the details needed for even the simplest of programs. Therefore, you must test the program thoroughly and fix the errors. Fixing errors is called <I>debugging</I>. Once all the errors are out of the program, you have a finished application.<BR><P><B> <A HREF="01vel01.gif">Figure 1.1. Writing a program involves several </B><B>steps.</A></B><BR><P>The second step, writing the source code, is the most tedious part of programming. Remember that the source code is the actual programming instructions that the computer is to follow. You will spend most of your programming time working on the source code so that you end up with a program whose instructions direct the computer in the way that you want.<BR><P>There are many ways to write the source code for programs. Although today's computers are more powerful than earlier machines in terms of memory capacity and speed, today's computers are no smarter than the very first computer. In the late 1940s, programmers had to write programs for those early computers just as today's programmers must do. The difference lies in the way today's programmers write programs. Today's programming tools—Visual Basic is a shining example—are far more powerful. They enable you to develop programs more powerful than before and with less effort on your part.<BR><BR><A NAME="E69E13"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Where Programmers Began</B></FONT></CENTER></H4><BR><P>The very early computers were not programmed through keyboards and mice. As a matter of fact, the first few computers did not even have keyboards! The first computers had to be programmed by routing wires from component to component. Instead of programmers, electrical engineers programmed the early computers.<BR><P>Those hard-wired programming methods were simply too tedious to be productive. If a different calculation was needed, somebody would have to rewire the computer. Programmers had to have electrical and engineering experience just to make a computer do something. There had to be a way to speed up the process.<BR><P>Those early computers had memory similar to the way in which today's computers have memory. The difference is that the early memory was minuscule—even the largest computers had only a few hundred memory locations for data storage. Despite the short supply of memory, one of the computer experts of the time developed the idea of using the memory to hold both data and the code that instructed the computer on a task. Until that point, the "code" consisted of the hard-wired circuitry.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Tip: </B>By putting the computer's instructions inside the memory along with data, the computer programs were easier to change because the memory could be changed. Engineers were no longer required to rewire the computer every time the program needed changing.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>The computer scientists put a panel of switches on those early computers. Figure 1.2 shows a simple representation of those switches. The programmers would flip the switches into a series of unique On and Off states, press the Enter button, and repeat the process until a series of instructions that looked like the following "program" appeared in the program memory:<BR><PRE><FONT COLOR="#000080">On Off On On Off Off Off OnOff On On Off On On Off OffOff Off Off On On Off On OffOn On On On Off Off Off OnOff Off On Off Off On On OffOn On Off On On Off Off OnOff Off On Off On On On Off</FONT></PRE><P><B> <A HREF="01vel02.gif">Figure 1.2. The switch panel eliminated the hand </B><B>wiring.</A></B><BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: </I>The original On-and-Off programming was called <I>machine language</I>.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Although this On-and-Off program is virtually indecipherable, each combination of On and Off switches represents a single instruction. By combining several instructions that operated on data located elsewhere in the machine's memory, a complicated thirty-instruction program might not do anything more than multiply two numbers! Despite the difficulties involved, such a lightning-fast calculation would have been unheard of before computers. The military immediately began using computers for trajectories and other calculations.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Tip: </B>By seeing the short history of programming, you will <I>really</I> appreciate what Visual Basic can do when you start using Visual Basic for your programs.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>The world of computers began moving forward with the switch panel. More memory was added, and the programs got more powerful. Sometime in the late 1940s, somebody got the bright idea of replacing the switch panel with a typewriter-like keyboard. Instead of assigning On and Off combinations to mean <I>Add</I> and <I>Store,</I> programmers could actually type the words Add and Store on the keyboard. The computer would analyze the instruction, look up the On and Off combinations needed, and set the memory switches internally.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE>Machine Language is Dead!—Long Live Machine Language!: Luckily, you do not have to write programs in the On-and-Off machine language anymore. The computer languages today are much closer to spoken speech than On and Off switches can ever hope to be. Even so, today's most powerful computer, programmed with advanced programming tools such as Visual Basic, <I>still</I> recognizes only machine language.<BR>People do not like machine language because it is too difficult to use. Computers do not like anything else. The job of all programming languages is to take the source code that you type in a programming language and to convert it to machine language so that the computer can execute those instructions.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><BR><A NAME="E69E14"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Programming Languages Improved</B></FONT></CENTER></H4><BR><P>Once programmers got hold of keyboards, there was no stopping them. The languages grew from the primitive On-and-Off system to higher-level languages that read more like spoken text. Listing 1.1 shows an example of a short FORTRAN program from the early days of these high-level languages. Although this FORTRAN program will be cryptic to you, the more textual approach to programming, as opposed to On and Off switches, opened doors for more people to become programmers. The software industry blossomed in the 1950s, and programs went from simple calculating tools to complete business and scientific applications.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Note: </B>FORTRAN stands for <I>FOR</I>mula<I> TRAN</I>slator. It is used primarily in mathematical and scientific programming. Although FORTRAN was one of the earliest high-level programming languages, many computer installations still use FORTRAN programs today. Much of the Visual Basic language was founded in principles of the early FORTRAN language.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P><FONT COLOR="#000080"><B>Listing 1.1. An early FORTRAN program.</B></FONT><BR><PRE><FONT COLOR="#000080"> WRITE (6, 10) 10 FORMAT('** Payroll Calculations **') WRITE (6, 11) 11 FORMAT('** Enter the employee's ID, hours, and pay rate') TAXRAT = 0.25 101 READ(5, 102, END=900) IDEMP, HRSWRK, RATE 102 FORMAT(I5, 1X, I3, F5.2) IF (HRSWRK .GT. 40) GOTO 300*******COMPUTE REGULAR PAY GRSPAY = HRSWRK * RATE GOTO 500 300 OVRHRS = HRSWRK - 40*******COMPUTE OVERTIME PAY OTGRS = OVRHRS * RATE * 1.5 GRSPAY = 40.0 * RATE + OTGRS 500 TAXES = GRSPAY * TAXRAT PAYNET = GRSPAY - TAXES WRITE (6,503) IDEMP, PAYNET 503 FORMAT('EMP: ', I3, 2X, 'NET PAY:', F6.2) GOTO 101*******END-OF-JOB PROCESSING 900 END</FONT></PRE><P>If you are unfamiliar with FORTRAN programs or with programming in any other language, you probably will not understand much of what you see in Listing 1.1. You might, however, be able to tell from some of the words, that the code performs payroll calculations of some kind. It is true that FORTRAN does not produce extremely readable code, but the commands such as IF, GOTO, and WRITE, improved programmer productivity greatly over what programmers had to do before such languages came along.<BR><P>With high-level languages such as FORTRAN, the 1950s and 1960s saw an incredible distribution of new software. Programming became more accessible to more people because of the easier-to-use programming languages. The increased number of programs brought a tremendous increase in the number of computers sold. Companies, laboratories, and universities purchased computers. There was no turning back the computer era once so many people had access to so much computing power. As computer companies sold more computers, competition produced less expensive and more powerful machines. And you thought that the 1990s were exciting!<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: Syntax</I> refers to the spelling and grammar of languages.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Even though programming languages were easier to learn, there was still much need for easier programming methods. Some Dartmouth College professors decided to write an easier programming language based on FORTRAN but with fewer details than FORTRAN required. Those professors developed BASIC, the language that enabled students to write programs because of its easier format and less restrictive syntax than FORTRAN’s.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Note: </B>BASIC is an acronym for <I>B</I>eginner's<I> A</I>ll-purpose<I> </I><I>S</I>ymbolic<I> I</I>nstruction<I> C</I>ode. The acronym's meaning is almost as long as—and much more difficult to remember than—the BASIC language itself.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Listing 1.2 shows the BASIC equivalent of the FORTRAN program that you saw in Listing 1.1. To programming newcomers, this BASIC listing might not be significantly easier to understand than the FORTRAN code. Nevertheless, the BASIC language is a little cleaner and slightly less cryptic than its FORTRAN predecessor. Although programming still took effort, BASIC took some of the rough edges off programming, and it brought more people to the programming craft.<BR><P><FONT COLOR="#000080"><B>Listing 1.2. A BASIC program.</B></FONT><BR><PRE><FONT COLOR="#000080">10 PRINT "** Payroll Calculations **"20 PRINT "** Enter the employee's ID, hours, and pay rate"30 TAXRAT = .2540 INPUT IDEMP$, HRSWRK, RATE50 IF (IDEMP$ = "END") THEN GOTO 16060 IF (HRSWRK > 40) GOTO 7070 REM *******COMPUTE REGULAR PAY80 GRSPAY = HRSWRK * RATE90 GOTO 110100 OVRHRS = HRSWRK - 40110 REM *******COMPUTE OVERTIME PAY120 OTGRS = OVRHRS * RATE * 1.5130 GRSPAY = 40 * RATE + OTGRS140 TAXES = GRSPAY * TAXRAT150 PAYNET = GRSPAY - TAXES160 PRINT "EMP: "; IDEMP$; "NET PAY:"; PAYNET170 GOTO 20180 END</FONT></PRE><P>Well into the 1980s, the rate at which the number of programmers grew remained high. Despite all new programmers, the programming tools themselves really did not advance much. Many people developed new programming languages. Despite their "new and improved" claims, most of the languages retained the textual procedural quality that FORTRAN and BASIC offered.<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -