Choosing an appropriate computer language - ACS Publications

ACS2GO © 2018. ← → → ←. loading. To add this web app to the home screen open the browser option menu and tap on Add to homescreen...
6 downloads 0 Views 8MB Size
edited by JOHN W. MOORE Eastern Michigan "nivwsiv, ypsilanti, a 1 9 7

computer ~ e r i eS~O.

Choosing an Appropriate Computer Language G. Scott Owen Atlanta University, Atlanta, GA 30314 One of the most frequently asked questions from computer users (and potential users) is "What is the best computer language?" This question is usually asked in a situation (such as during a formal conference presentation) which precludes an adequate answer. In this article I want to express some of my opinions on this very controversial subject. Rather than discussing this subject by focusing only on the properties of different computer languages, I would like to put it in the context of the rapidly evolving microcomputer technology. I will discuss the brief history of microcomputers and present some predictions about hardware trends. Next I will give some explicit criteria for judging a computer language, and finally I will discuss different programming languages in terms of what has been used in the past, and why, and what might he appropriate for the future. .. . fwill also present my opinions on the virtues and faults of some of the lanpuapes. You may not agree with what I have to say (there are always some unreasonable people around), hut I hope that this article will cause you to consider this issue critically. T o put this discussion in perspective, I feel it would he useful to describe hrieflv .mv" involvement and exnerience with romputers so that you will know my biases. I have nr\.er hnd a formal course in . urorrarnm~ne " hut learned I.'OH'I'KAN on my own as a graduate student (using cards on a mainframe IBM 7094). I continued usina FORTRAN on mainframes until I ohtainrd my f m t "prrsunal" computer in 1976. This was a I'DI'8e. with HASIC. Digital Euuiprnwn Ctmorntion (Dl?(') 1 2 1 ~ 12-bit'words, , d;al DECtape drives, and an ASR 33 teletypewriter for a terminal. For the next couple of years I programmed in BASIC on the 8e, and BASIC and FORTRAN on timeshared PDP 11minicomputers. In 1977 I obtained an Apple I1 computer with 20 Khytes of memory. I used BASIC (and some assembly . lanruare) . . on the Apple 11 for graphics programs, computer-instrument interfacing, and Computer Assisted Instruction (CAI). In 1979 I taught myself pascal and started converting my programs from BASIC to Pascal. Pascal has been my primary programming language since then, although I still write some BASIC and asse~.hlylanguage programs (on both the Apple I1 and the IBM PC). In the past three years I have also programmed in hoth FORTRAN and Pascal on a VAX 111780. I have recently learned Ada and started using it on an IBM PC. T o summarize my experience: I have programmed in assembler on PDP ll's, the Apple 11, and IBM PC; in BASIC on the same set of machines (and the PDP 8e); in FORTRAN on an IBM 7094, PDP 11'5, a VAX 111780,the Apple 11, and on the IBM PC (three different FORTRAN's); in Pascal on PDP ll's, the Apple 11, IBM PC (three different Pascal's), and VAX 111780; and in Ada on the IBM PC. I have not had personal experience with FORTH, C, LISP, LOGO, APL, or Modula-2, although I have read several articles (hoth pro and con) about them and in the case of FORTH, discussed itwith the FORTH

-

440

Journal of Chemical Education

freaks (there is annarentlv no middle mound with FORTH). For h o t h e r vi'eb on this issue I wokd suggest that you read the series of articles by Ray Dessy (1).Dessy focuses on languages for laboratory use, but much of his discussion is apdicahle to general nroerammine. A brief discussion of general ianguage ccoice isBlsogiven inthe article by ~ a r s h a i l ( 2 ) . Microcomputer Hardware Systems-Past, Present, and Future The first microcomputer systems which were really useful for any sort of CAI in chemistry appeared in 1977. In that year the Apple 11, TRS-80, and P E T were all introduced. These wcrr ill hased OII X-hit crntral pnrrssing units (('PU'sl and all hid about the same perfurmanre. At that time a system with lfi Kbvtrs of memory wasconsidered to he large, and the Apple cassette intrrtiice at l5t1chnra~wrsper s e n d (ens) was considered to he fast mass storage. A significant enhancement occurred in 1979 when disk drives became generally availahle. The disk drive helped immensely with software development and general usage of these systems. I might point out that disk drives had already been availahle for the more expensive "S-100" microcom~uter systems. One of my favorite memorit.~is from thr 1978 k e n nial Chemind Kducation Cunference at Furt Collin;. ('Arsdu. Allot the-hig hoys" with thrir Altsir and IMSAI 5 - 1 ~ 0 s y s PROGRAM FPBENCH(INPUT,OUTPUT)i

CONST PI=3.14159;

VRR

J.I,N:INTEGER; R.Y:REAL; CH: CHRR;

x:annaY

11..91

OF RERL;

REGIN REPEAT WRITELNt'THIS IS - R NUMBER CRUNCHING SPEED TEST' WRITELNI'ENTER THE NUMBER OF I T E R R T I O N S ' ) ; RERDLNINI; FOR I:= 1 TO N DO BEGIN ~

y:=

r112.1:

X141:= S Q H T I Y I ; X151:= EXP(Y); XLbl:= L,1(Y); x171:= Y;

x[ai:=

VIPI:

-.

XE91:= SINiY)+Z; FOR J:= 1 TO 9 DO

a:=

X I J I + X~~IJIIPI: ~

~

END: WRITELN(CHR(7l:FINISHED. RERDLNICH); UNTIL CH 0 ' Y '

RGRIN !YIN)

END.

Figure 1. Floating point benchmark in Pascal.

7'1;

)

;

w i t h nathlib,Timelib.ut~l.Fl~atiii Packags Bmdv Dpacc Is .pee., and accuracy test + r a m nr. ~ o b b . 5 Journal Sept., 1983 page 122

--

---- t n , s Us.

is d o u b l e preciston n.thlib.Ti.elib,"tll;

tems told me I should . pet myself a "real computer" instead of my Apple toy. In 1982 the next generation of microcomputers, with 16-hit processors, hegan appearing. These systems were much more powerful than the previous 8-hit systrms, could accommodate much more memory (see Figures 1 and 2). and had floppy disk drives with greater storage capacity. The relative processor power figures given in Tahle I are not for interpreted BASIC or for assembler. They are derived from running benchmarks on the different machines using high level languages (FORTRAN and Pascal) currently available. For example, Apple Pascal is faster than Apple BASIC, and a Pascal program on the IBMPC executes 2 5 3 0 times faster than the same Pascal oroaram on the A ~ d eFor . floating point calculations this is o&y&ue if the IBM-PC has the 8087 Numeric Data Processor chi^ installed and supported. The third generation of microcomputers (based on 32-hit and super 16-bit processors) should begin to appear within the next year. These will have even greater computing memory and mass storage capability (Tahle 1) and.will continue the current trend toward multiprocessinp, i.e., having specialized processors for different taiks. The XU86 family is gaud example of this since the 80Rfi/88 is the general purpose pruccsar, the 8087 is thr numeric roprotcssor, and the 8ud9 is the InputIOutpnt coprocessor. This trend should continue and hy the late 1980's we will have machines with multiple seffi of

a

Table 1.

Slze Comparison of Computer Systems Relative Processing Power

Description 8 bit cpu's (6502: Apple ii, PET, 2-60, TRS-80) I 8 bit CPU'S(80861808818087): IBM PC. (Zenith 100) 32 bit (Plus Super 16): (80286.68000.432. 16032) VAX 111780 (IBM 3701148. IBM 4341)

Table 2. Description Memory type (1 Mbyle) Memory costI(1 Mbyte) Mass storage device Capacity Access time Data transfer rate Mass storage cost

Memory Addressing Space

1

64Kbyte

25-30

1 Mbyte

50-300

16 Mbyte

300

coprocessors, i.e., there may he a dozen general purpose and numeric Drocessors in the same machine. These Hystems will also have excellent graphics capabilities and will have dedicated maohics - . Drocessors. which are alreadv avnilahle and appearing in some currmt systems. For example, hoth the DEC Hainhow and rhe NEC APC' microcomouters use the NEC 7220 graphics processor, as do several add-on high resolution graphics hoards for the IBM PC. This processor is a 16-bit chip that is specially designed for graphics control and display. It can address 256 Khytes of graphics memory (which is enough tosupport aresolution of 640 X 480 pixels with 64 colors) and has a line drawing- speed -meater than Hn 8086 or a 68000 microprocessor. The prire of memory and mass storage continues to drop drastically (see Tahle 2). This trend is rxpected to continue in the near future.Table3 shows past, present, andestimated future complete system costs. These are not necessarily list prices since educational institutions normally receive a 15-20% discount. Note that, for 1986, I have actually described two different svstems in these tables. one for software develo~mentand one &r general (student) use. This would also he true for current systems because i t is reasonable to have a more powerful software development system than the target system. However, the key point in the above discussion is that within a decade the microcomputers which are available for eeneral use will have develo~edfrom slow machines with rimited memory and externai storage to systems with fast, high-resolution color graphics and the memory size and computational capability of a VAX 111780 superminicomputer. Criteria for Judglng a Computer Language

The necessary criteria for judging a computer language are dependent upon the typesnd magnitude of the programs to be written in that language. If you only plan to write a simple, linear-least-squares analysis program you do not need the same caoahilities as vou would if vou wanted t o simulate completely a Cary 17 ~Tv-visiblesp&rophotometer or write a molecular modeline svstem. Therefore. some of the items discussed below are really only important for large programs. Table 3.

Tvnlcal Mlcrocomouter Svstems

1977 Apple 11 (8 bit) with 16 Kbyles memory, audio casselte tape. 280 X 140 pixel 4 mior graphics. Cost: $1800 1983 IBM PC (18 bit) with 256 Kbytes memory. 2 X 360 Kbyte Floppy Disk drives, 320 X 200 pixel 4 color graphics. Cost: 53,000 The same system with 640 X 480 pixel 16 color graphics (includingan RGB monitor) is $5,000. 1986 Suoer 1 132 bit) with 2 Mbvtes memorv. 10 Mbvte Hard Disk Drive. 1' byte ~ i o p p yDisk drive. 640 X 480 pixel 64 cilor graphics Cost $3.000 Sub i(32 bit) with 1 Mbyte memory. 1Mbyte Floppy Disk drive. 640 X 480 pixel 64 color graphics. cost % 75nn

4-16Mbyte

Comoarlson 01 Costs Versus Memow and Storaoe CaDabllRles: 1977. 1983. 1986 1977

512 16K bit chips $20,000 audio cas9ene 100 Kbyles minutes 150 cps $50

1983

1986 (Projected) 36 256K bit chips with parity $250 hard disk 10-20 Mbytes 50 ms 256 Kcps 5500

144 64K bit chips wilh parity 51,300 floppy disk 140-360 Kbytes 250 ms 15-20 Kcps $500

Volume 61

Number 5 May 1984

441

The first criterion would be the program development time, i.e.. how lone it takes vou to write and dehue-. vour Droeram. . The second criterion would be the actual program execution speed. Both of these are a function not only of your computer system but also of the type of language used. r imThere are two different t w e s of c o m ~ u t e laneuaee plementation systems: compiled and hterpreted. F o r a compiled language the program development process consists of the following:

-

1) Typing in the program using a text editor. 2) Translating the program statements into machine code using a eorndler: if svntax errors are discovered then vou must ro back

to th; editor & correct them.

3, Linkmy thepwgmn, r.~ths~~hrr~ut~nri(eithrrdevrl~~prd by you ur rlsr

lrom a system i~hrnryl.

4, Exrcuring the prurram and eliminating logical and

rull

timr

errors. With an interpreted languagc,such as RASI(', the program issimply typed into tht,mirchint. and run. As the program runs ~the individual statements are interoreted. line bv line. into machine code and then executed. Depending upon the implementation system, syntax errors are sometimes reported when the program line is typed in and sometimes when the oroeram is run. 'fhe advantage of an interpreted language is that it is very ouick and easv to write short Droerams. The disadvantaee is execute more slowly than do com&ed that these Droprams because everv time a Droeram statement is executed it &st be translated &to machine code. Thus, if you have a FOR NEXT loop which is executed 10,000 times then every statement in that loop is interpreted 10,000 times. With compiled languages this translation Drocess bas been done bv the Eompiler,io the executable pro&am is entirely in machine code, and, therefore, the execution speed, particularly for repetitive tasks, is much higher. The disadvantage of compiled languages is the longer program developmen~process& it takestime for the compilation and linking steps. However, this extra time is decreasing as the hardware capabilities increase. It will probably always he easier to write a 20-line interpreted language program than a compiled language program, hut as the program size increases this becomes less important. For larger programs the ahilitv to use a full text editor for statement and variable changes and evrn !t,r moving iecti~msd t h e program around is very" imnortnnt. This leads to another disadvantaae . - o i interpreted languages: there is generally only a limited editing caoabilitv available and thus chaneina - - statements and variable names, etc. is not as easy as when using a full text editor. There are some current language implementations that are a combination of the above, e.g., the UCSD-P system. This system compiles its FORTRAN and Pascal programs not to true machine code hut to an intermediate P code. This P code is then interpreted by the individual machine. This makes it very easy to implement this system on different machines, but you pay a definite price in execution speed, e.g., UCSD Pascal programs usually execute twice as fast as BASIC programs on an Apple I1 but about half as fast as a fully compiled program. In the section below I briefly mention other criteria for choosing a language. Some of these will he elaborated on in the next section (Comparison of Languages). Again, remember that the importance of some of these criteria is greatly dependent upon the size and complexity of the programming task. ~

1) Program size-how much memory and disk space does the program require; this is becoming somewhat less important as both memorv and mass storaee increase in size. 21 /'r,rlnhrhl\ -i- n w r y lmpamant vrit4m i n w Id