community
directory
books
authors
images
encyclopedia

Email:
Password:
Register

Knowledgerush Search

 

Google
  Web knowledgerush


Search for images of BASIC


Message boards   Post comment

BASIC

BASIC is a family of high-level programming languages. Originally devised as a teaching tool, it became widespread on home microcomputers in the 1980s, and remains popular to this day in a handful of heavily altered dialects.

BASIC's name, coined in classic, computer science tradition to produce a nice acronym, stands for Beginner's All-purpose Symbolic Instruction Code,¹ tied to the name of an unpublished paper by the language's co-inventor Thomas Kurtz (the name thus having no relation to C. K. Ogden's series "Basic English").

History

Background

Prior to the mid-1960s, computers were highly expensive tools used only for special-purpose tasks, which ran a single "job" at a time. During the 1960s, however, computer prices started to drop to where even small companies could afford them, and their speed increased to the point they often sat idle, without jobs to run.

Programming languages of the era tended to be designed, like the machines on which they ran, for specific purposes such as scientific formula processing. Since single-job machines were expensive, the tendency was to consider execution speed the most important feature of all. In general, they were hard to use, and tended toward a certain "ugliness."

It was at this time that the time-sharing system concept started to become popular. In such a system the processing time of the main computer is "sliced up" and each user is given a small amount in alternation. The machines were fast enough for most users to feel they had a single machine all to themselves. In theory, timesharing reduced the cost of computing tremendously, as a single machine could be shared among hundreds of users.

Birth and early years

The original BASIC language was invented in 1964 by John George Kemeny (1926–93) and Thomas Eugene Kurtz (1928–) at Dartmouth College. In the following years, as other dialects of BASIC appeared, Kemeny and Kurtz' original BASIC dialect became known as Dartmouth BASIC.

BASIC was designed to allow students to write programs using time-sharing computer terminals. BASIC was intended to address the complexity issues of older languages with a new language designed specifically for the new class of users the time-sharing systems allowed—that is, a "simpler" user who was not as interested in speed as in simply being able to use the machine. The designers of the language also wanted it to remain in the public domain, which helped it spread.

The eight design principles of BASIC were:

  1. Be easy for beginners to use
  2. Be a general-purpose language
  3. Allow advanced features to be added for experts (while keeping the language simple for beginners)
  4. Be interactive
  5. Provide clear and friendly error messages
  6. Respond fast for small programs
  7. Not require an understanding of computer hardware
  8. Shield the user from the operating system

The language was based partly on FORTRAN II and partly on Algol 60, with additions to make it suitable for timesharing and matrix arithmetic. BASIC was first implemented on the GE-265¹ mainframe which supported multiple terminals. Contrary to popular belief, it was a compiled language at the time of its introduction. Almost immediately after its release, computer professionals started deriding BASIC as too slow and too simple;² such elitism is a recurring theme in the computer industry.

BASIC nevertheless spread to a number of machines, and became fairly popular on newer minicomputers like the DEC PDP series and the Data General Nova. In these instances the language tended to be implemented as an interpreter instead of a compiler, or alternately, both were supplied.

Explosive growth

However, it was the introduction of the Altair 8800 microcomputer in 1975 that truly spread BASIC. Most programming languages were too large to fit in the small memory most users could afford on these machines, and with the slow storage on paper tape (or later audio cassette tape: disks of any kind were not available at any price for some years) and the lack of suitable text editors, a small language like BASIC was a good fit. One of the first to appear for this machine was Tiny BASIC, a simple BASIC implementation originally written by Dr. Li-Chen Wang, and then ported onto the Altair by Dennis Allison at the request of Bob Albrecht (who later founded Dr. Dobbs Journal). The Tiny BASIC design and the full source code were published in 1976 in DDJ.

In 1977, Microsoft (then only two people—Bill Gates and Paul Allen) released Altair BASIC. Versions then started appearing on other platforms under license, and millions of copies and variants were soon in use; it became one of the standard languages on the Apple II. By 1979, Microsoft was talking with several microcomputer vendors, including IBM, about licensing a BASIC interpreter for their computers. A version was included in the IBM PC ROM chips and PCs without hard disks automatically booted into BASIC.

Newer companies attempted to follow the successes of Altair, IMSAI, North Star and Apple, thus creating the home computer revolution; meanwhile, BASIC became a standard feature of all but a very few home computers. Most came with a BASIC interpreter in ROM, a feature pioneered by the Commodore PET in 1977. Soon there were many millions of machines running BASIC around the world, likely a far greater number than all the users of all other languages put together. Many programs, especially on the Apple II and IBM PC, depended on the presence of Microsoft's BASIC interpreter and would not run without it; in this way, Microsoft used its copyright licenses on its BASIC interpreter to gain leverage in negotiations with the computer vendors.

Maturity

Many newer and more powerful BASIC versions were created during this period. Microsoft sold several versions of BASIC for MSDOS/PCDOS including BASICA, GW-BASIC (a BASICA-compatible version that didn't need IBM's ROM) and Quick BASIC. Turbo Pascal-publisher Borland published Turbo BASIC 1.0 in 1985 (successor versions are still being sold by another company under the name PowerBASIC). Various extensions of home computer BASIC appeared, typically with graphics, sound and DOS commands, as well as facilities for structured programming. Other languages used the widely-known BASIC syntax as the basis for otherwise completely different systems, GRASS being one example.

However, by the latter half of the 1980s newer computers were far more complex and included features (such as graphical user interfaces) that made BASIC less suitable for programming. At the same time, computers had progressed from a hobbyist interest to tools used primarily for applications written by others, and programming as a whole became less important for the growing majority of users. BASIC started to fade, though numerous versions remained available.

BASIC reversed in fortune once again with the introduction of Visual Basic from Microsoft. Though it is somewhat difficult to consider this language to be BASIC (despite its many familiar BASIC keywords) by the time of writing it had become one of the most-used languages on the Windows platform. It is said to represent some 70 to 80% of all commercial development. Microsoft added Visual Basic for Applications (VBA) to Excel 5.0 in 1993 and to the rest of its Office suite in 1997. Windows 98 included a VBScript interpreter. The most recent version of Visual Basic is called VB.NET. The competing OpenOffice suite includes a BASIC variant reportedly less powerful than its Microsoft counterpart.

The language

Syntax

Basic statements are terminated by line endings unless there is a line continuation character. A very minimal BASIC syntax only needs the LET, PRINT, IF and GOTO commands. An interpreter which executes programs with this minimal syntax doesn't need a stack. Some early microcomputer implementations were this simple. If one adds a stack, nested FOR-loops and the GOSUB command can be added. An interpreter with these features requires the BASIC code to have line numbers.

Line numbers were a very distinctive aspect of classic home computer BASIC. Alas, the use of line numbers has the disadvantage of requiring the programmer to guesstimate ahead of program entry how many lines a given program part will take. This need is most often met by habitually incrementing successive line numbers by a regular interval, say 10, but naturally leads to problems as soon as later-added code exceeds the number-space available between the original lines. To alleviate this problem with early BASIC interpreters, expert users soon wrote their own utility programs for renumbering their programs after initial entry. Some BASIC interpreters later appeared with a built-in RENUMBER command, thus eliminating the most pressing problem with line numbers.

Modern BASIC dialects have abandoned line numbers, and support most (or all) of the structured control and data declaration constructs known in other languages like C and Pascal (note also that some advanced versions of line number-based home computer BASICs incorporated such constructs as these to good effect):

  • do - loop - while - until - exit
  • on x goto / gosub (switch & case)

Recent variants such as Visual Basic have introduced object-oriented features, and even inheritance in the latest version. Memory management is easier than in many other procedural programming languages because of the commonly included garbage collector (presumably for which, however, one pays a run-time performance penalty).

This wealth of variants shows that the language is an "organic" one and that it may be seen as a subculture dealing with computer programming rather than as a fixed set of syntactic rules. This applies as well to other "old" computer languages like COBOL and FORTRAN, although the BASIC movement is by far the largest; this may be explained by the large number of IT professionals who cut their teeth on BASIC programming during the home computer era in the 1980s.

Procedures and flow control

BASIC doesn't have a standard external library like other languages such as C. Instead, the interpreter (or compiler) contains an extensive built-in library of intrinsic procedures. These procedures include most of the tools a programmer needs to learn programming and write simple applications, including functions for math, strings, console input/output, graphics and file manipulation.

Some BASIC dialects do not allow programmers to write their own procedures. Programmers must instead write their programs with large numbers of GOTO statements for branching. This can result in very confusing source, commonly referred to as spaghetti code. GOSUB statements branch to simple kinds of subroutines without parameters or local variables. Most modern versions of BASIC such as Microsoft QuickBASIC have added support for full subroutines and functions. This is another area where BASIC differs from many other programming languages. BASIC, like Pascal, makes a distinction between a procedure which does not return a value (called a subroutine) and a procedure which does (called a function). Many other languages (notably C) make no distinction and consider everything a function (with some returning a "void" value).

While functions in the larger sense of subroutines returning values were a latecomer to BASIC dialects, many early systems supported the definition of one-line mathematical functions by DEF FN ("DEFine FunctioN"). The original Dartmouth BASIC also supported Algol-like functions and subroutines from an early date.

Data types

BASIC is well known for good string manipulation functions. Early dialects already had a set of fundamental functions (LEFT$, MID$, RIGHT$) to deal with strings easily. Because strings are often used in everyday applications this was a considerable advantage over other languages at the time of its introduction.

The original Dartmouth BASIC supported only numeric and string data types. There was no integer type. All numeric variables were floating point. Strings were dynamic in length. Arrays of both numbers and strings were supported, as well as matrices (two dimensional arrays).

Every modern BASIC dialect at least has the integer and string data types. Data types are usually distinguished by a suffixed character; string identifiers end in $, whereas integers do not. In some dialects, variables must be declared (with DIM) on their first usage; other dialects do not require it, but can optionally enforce it—typically using a directive such as Option Explicit. Many dialects also support such additional types as 16- and 32-bit integers and floating-point numbers. Additionally, some allow user-defined types similar to Pascal "records" or C "structs".

Most BASIC dialects beyond the most primitive also support arrays of integers or other types. In some, arrays must be preallocated (with the DIM statement) before they can be used. Support for two- and higher-dimensional arrays, as well as arrays of non-integer types, is common.

DIM myIntArray (100) AS INTEGER DIM myNameList (50) AS STRING

Depending on the dialect of BASIC and use of the Option Base statement, values can range from myIntArray(0) to myIntArr(100), from myIntArr(1) to myIntArr(100) or from myIntArray(LowInteger) to myIntArray(HighInteger). However, in Visual Basic .NET, all arrays are zero-indexed, meaning the first element has an index of 0, as in the first of the above examples.

Relational and logical operators

= equal <= less than or equal NOT logical negation <> not equal >= greater than or equal AND logical conjunction < less than OR logical disjunction > greater than

(Note that there is no lexical distinction between the equality operator and the assignment operator in BASIC.)

Availability and dialect variants

BASIC is available on nearly every microprocessor platform made. One interpreted free version, compliant with standards and highly cross-platform, is Bywater BASIC (bwBASIC). The interpreter is written in C and comes under a GNU license. It is meant for text console programs, and as such does not include a builder for creating graphical user interfaces (GUIs). A free BASIC that includes a GUI builder, runs on Linux and Windows and is similar to Visual Basic is Phoenix Object Basic.

The best known compiled versions are Microsoft's Quick BASIC and QBASIC (a version which does not generate standalone programs.) Some versions of Visual Basic are also compiled, though Microsoft has kept Visual Basic at least minimally compatible even with early versions of its own BASICs.

Other versions include (PowerBASIC's) PowerBASIC programming language, as well as (True BASIC's) True BASIC, which is compliant with the latest official BASIC standards. (True BASIC, Inc. was founded by the original creators of Dartmouth BASIC.)

REALbasic, for the Apple Macintosh, is a variant that also generates executables for Microsoft Windows. A simple BASIC dialect for the parrot virtual machine shows a BASIC interpreter implementation in an assembly-like language. PureBasic is a variant with simple syntax that produces fast, tiny executable files for Windows and Linux, and is additionally capable of compiling in-line assembly instructions. The SmallBASIC dialect runs on many platforms (Win32, DOS, Linux and PalmOS) and comes with a GNU license (GPL).

Examples

Sample 1: Unstructured original BASIC (Applesoft BASIC) ---------- Sample 2: Modern Structured BASIC

10 INPUT "What is your name: "; U$ INPUT "What is your name"; UserName$ 20 PRINT "Hello "; U$ PRINT "Hello "; UserName$ 25 REM DO 30 INPUT "How many stars do you want: "; N INPUT "How many stars do you want"; NumStars 35 S$ = "" Stars$ = "" 40 FOR I = 1 TO N Stars$ = REPEAT$("*", NumStars) '<- ANSI BASIC 50 S$ = S$ + "*" --or-- 55 NEXT I Stars$ = STRING$(NumStars, "*") '<- MS BASIC 60 PRINT S$ PRINT Stars$ 65 REM DO 70 INPUT "Do you want more stars? "; A$ INPUT "Do you want more stars"; Answer$ 80 IF LEN(A$) = 0 GOTO 70 LOOP UNTIL Answer$ <> "" 90 A$ = LEFT$(A$, 1) LOOP WHILE UCASE$(LEFT$(Answer$, 1)) = "Y" 100 IF (A$ = "Y") OR (A$ = "y") THEN GOTO 30 110 PRINT "Goodbye "; PRINT "Goodbye "; 120 FOR I = 1 TO 200 FOR I = 1 TO 200 130 PRINT U$; " "; PRINT UserName$; " "; 140 NEXT I NEXT I 150 PRINT PRINT

Dialects

Standards

  • ANSI Standard for Minimal BASIC (ANSI X3.60-1978 "FOR MINIMAL BASIC")
  • ISO Standard for Minimal BASIC (ISO/IEC 6373:1984 "DATA PROCESSING - PROGRAMMING LANGUAGES - MINIMAL BASIC")
  • ANSI Standard for Full BASIC (ANSI X3.113-1987 "PROGRAMMING LANGUAGES FULL BASIC") $79 USD
  • ISO Standard for Full BASIC (ISO/IEC 10279:1991 "INFORMATION TECHNOLOGY - PROGRAMMING LANGUAGES - FULL BASIC") $53 USD
  • ANSI Addendum Defining Modules (X3.113 INTERPRETATIONS-1992 "BASIC TECHNICAL INFORMATION BULLETIN # 1 INTERPRETATIONS OF ANSI 03.113-1987")
  • ISO Addendum Defining Modules (ISO/IEC 10279:1991/ Amd 1:1994 "MODULES AND SINGLE CHARACTER INPUT ENHANCEMENT")

External links

References and notes

 

Compose Your Message

Your Email Address or Pen Name (optional):
Subject:
Your Message:
 

 

 

 

 

 

This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "BASIC".

 

Contact UsPrivacy Statement & Terms of Use

 
Copyright © 1999-2003 Knowledgerush.com. All rights reserved.