Concepts of Programming Languages

(Sean Pound) #1

portions of their largest operating system for the PDP-11 minicomputers,
RSTS, in the 1970s.
BASIC has been criticized for the poor structure of programs written in
it, among other things. By the evaluation criteria discussed in Chapter 1, spe-
cifically readability and reliability, the language does indeed fare very poorly.
Clearly, the early versions of the language were not meant for and should not
have been used for serious programs of any significant size. Later versions are
much better suited to such tasks.
The resurgence of BASIC in the 1990s was driven by the appearance of
Visual BASIC (VB). VB became widely used in large part because it provided
a simple way of building graphical user interfaces (GUIs), hence the name
Visual BASIC. Visual Basic .NET, or just VB.NET, is one of Microsoft’s .NET
languages. Although it is a significant departure from VB, it quickly displaced
the older language. Perhaps the most important difference between VB and
VB.NET is that VB.NET fully supports object-oriented programming.
The following is an example of a BASIC program:


REM BASIC Example Program
REM Input: An integer, listlen, where listlen is less
REM than 100, followed by listlen-integer values
REM Output: The number of input values that are greater
REM than the average of all input values
DIM intlist(99)
result = 0
sum = 0
INPUT listlen
IF listlen > 0 AND listlen < 100 THEN
REM Read input into an array and compute the sum
FOR counter = 1 TO listlen
INPUT intlist(counter)
sum = sum + intlist(counter)
NEXT counter
REM Compute the average
average = sum / listlen
REM Count the number of input values that are > average
FOR counter = 1 TO listlen
IF intlist(counter) > average
THEN result = result + 1
NEXT counter
REM Print the result
PRINT "The number of values that are > average is:";
result
ELSE
PRINT "Error—input list length is not legal"
END IF
END


2.7 The Beginnings of Timesharing: BASIC 65
Free download pdf