BASIC is an imperative programming language . It was developed in 1964 by John G. Kemeny , Thomas E. Kurtz and Mary Kenneth Keller at Dartmouth College, initially as an education-oriented programming language and, in its form at that time, did not yet have the characteristics of structured programming , but worked with line numbers and jump instructions ( GOTO ). There are now a large number of different BASIC dialects , some of the more recent ones having all elements of higher programming languages, such as object orientation .
The acronym "BASIC" stands for " B eginner's A ll-purpose S ymbolic I nstruction C ode" which translates as "symbolic general purpose programming language for beginners". The abbreviation seen as a word also means "fundamental". This clearly shows the design goal: to create a simple programming language suitable for beginners. Except for some product names, the word "BASIC" is always written in capital letters.
The language was designed based on eight principles:
- Easy to learn for beginners
- Universally applicable
- Extensibility of the language for experts
- Clear error messages
- Short response times
- Hardware independence
- Operating system independence
BASIC was developed in 1964 by John G. Kemeny , Thomas E. Kurtz and Mary Kenneth Keller at Dartmouth College to make it easier for electrical engineering students to get started with programming compared to Algol and Fortran . On May 1, 1964 at 4:00 p.m. local time, New Hampshire, the first two BASIC programs were running simultaneously on a General Electric GE-225 computer in the basement of Dartmouth College. BASIC was then developed further for many years by more and more new computer science students at this college, and from the late 1960s onwards, Kemeny and Kurtz propagated it at several schools in the area that wanted to include computer courses in their curriculum for the first time. BASIC was free for schools, as requested by its “fathers”, in contrast to almost all other programming languages common at the time, which usually cost several thousand dollars. Many of the large computer manufacturers at the time (such as DEC ) soon offered BASIC interpreters for their new minicomputers because of the ease with which the language was easy to learn and the fact that it can be used without a license fee . Many medium-sized companies, which at that time were buying large numbers of computers for the first time, came into contact with BASIC.
Some of the pupils, students and middle-class programmers who were so familiar with BASIC were active a little later in the short-lived craft computer scene in the mid-1970s, which preceded the commercial microcomputers , and made BASIC known there; Hardly any other high-level language widespread at the time was as good as (a stripped-down) BASIC for the extremely limited storage space of these first microcomputers. BASIC reached its peak in the late 1970s and early 1980s with the first home computers that emerged from the craft computers , almost all of which had a BASIC interpreter as a user interface and programming environment . Prominent examples are Sinclair computers of the ZX series with Sinclair Basic ( ZX80 , ZX81 and ZX Spectrum ), the Tandy TRS-80 , the Texas Instruments TI-99 / 4A , the Schneider / Amstrad CPC , the Apple II , the Atari 8-bit home computer or the best-selling home computer of all time, the Commodore 64 . But also the forerunners of personal computers, such as those from Philips , could work with CP / M -BASIC in an interpretive or compiled manner. The vast majority of these BASICs came from Microsoft . BASIC was Microsoft's first and most important product in the early years, several years before the company's first operating system, MS-DOS , came onto the market.
Practically all owners of home computers at that time had at least a basic knowledge of BASIC, since most computers started the BASIC interpreter when they were switched on, which allowed further programs to be loaded using BASIC commands. Even when graphic user interfaces with the Macintosh , Amiga and Atari ST were introduced in the mid-1980s, BASIC interpreters were also supplied with them. There were also additional versions of BASIC dialects for sale. Using compilers, it was possible to translate some BASIC dialects directly into significantly faster machine programs or, by bypassing the interpreter, to translate them directly into call lists of the underlying interpreter functions. MS-DOS , which has been widespread since 1981 , also contained a BASIC interpreter - initially BASICA or GW-BASIC , later QBasic - which played a role in computer science teaching at many schools in Germany . At that time, however, a change set in because other high-level languages such as C became available for home computers or the resources of the respective system were only inadequately supported by the BASIC interpreter supplied, which forced the programmer to become familiar with assembler .
Due to the implementation as interpreter language, the early BASIC dialects were also significantly slower than most other, usually compiler-based high-level languages. This made it particularly unattractive for time-critical applications or led to the use of subroutines in machine language , which were often written into the main memory with POKE instructions from BASIC. Such programs, of course, were not portable . Because of this, and because of its fragmentation into countless dialects, BASIC is almost not considered portable.
Some BASIC dialects, e.g. B. AmigaBASIC , have been extended by labels , which serve as jump addresses instead of line numbers. Other BASIC dialects then mastered the use of functions and procedures. The jump instruction
GOTObecame dispensable and is even frowned upon today. The much criticized so-called spaghetti code (source code that is confusing, especially difficult to understand because of surprising jumps) could be avoided in favor of structured and function-oriented programming.
Over time, standard applications such as word processors, spreadsheets and databases established themselves. As a result, it was no longer necessary for many computer users to develop such programs themselves, which is why the use of programming languages generally declined.
The use of BASIC today
Microsoft went back to its own tradition and in 1991 introduced the commercial Visual Basic for the rapid development of Windows-based applications. The code was no longer interpreted at runtime , but rather translated into machine-level bytecode by a compiler during program development or, in later versions, even into native machine code . This measure made it possible to significantly increase the speed and stability of the program execution. As the speed of computers increased more and more, Visual Basic became more and more interesting for professional developments.
But it was only with Visual Basic version 5 or higher that Microsoft achieved significant successes in terms of processing speed, which, however, could not regain the ground it had previously lost.
In Europe in particular, Visual Basic has only been able to assert itself to a limited extent in the developer community. It offered a better and much easier connection to Windows than any other programming language, but it was slower. Only with the implementation of Visual Basic within the .NET system was it possible to overcome some of the structural weaknesses of BASIC. At the same time, however, this step meant the end of Visual Basic as an independent programming language . Within the .NET system, Visual Basic .NET is just one language implementation among others. With the introduction of the JIT compiler and .NET as the basis for all Microsoft languages, there is no longer any great difference between the processing speed of BASIC and other programming languages under .NET.
BASIC is successfully used in many Microsoft Office products from Microsoft and also in some other applications as VBA for internal macro programming. Many software manufacturers also offer BASIC-based programming languages for internal macro programming of their products.
The goal of a platform-independent programming language has never been achieved. In contrast to the well-standardized C , BASIC created hundreds of dialects, all of which are incompatible with one another except for certain basic similarities. The similarities are limited to the pure data processing, while each manufacturer implemented his own commands for input and output, which are tailored to the respective hardware, in the course of the rapid hardware development. Well-structured BASIC programs in the source code can often be easily and quickly transferred to a wide variety of systems.
At the beginning of BASIC programming, commands were structured as follows:
1. Zeilennummer Befehl [Parameter1, Parameter2 ...] 2. Zeilennummer Variable1=Variable2
Line number: a sequential value that i. d. Usually increases in steps of 10, so that lines (with commands) can be added later, which are then given numbers in between. The command
RENUMBERcan be used to renumber a program taking into account all jump commands. In order to execute individual commands directly in the interpreter, no line number may be specified, otherwise the line will be stored in the program memory under the specified line number.
Command: Any command such as
Parameter : One or more values that can be passed to a command.
The assignment of values is shown in Example 2 below. The variable to which a value is to be assigned precedes the equal sign; it is followed by the expression whose value is to be assigned to the variable. Variables only need to be defined if they are arrays. The type of the variable results from a special character at the end of the name, e.g. B. $ for string (A $, B $, ...),% for integer (A%, A5), & for long (A &, B &, ...). The% can be omitted.
Examples of common commands:
INPUT [Text], Variable1 [,Variable2,...] - Per Eingabe werden der/den Variablen Werte zugewiesen, auf dem Bildschirm steht: Text PRINT [Text] - auf dem Bildschirm wird ein Text ausgegeben LOCATE X,Y - Legt die aktuelle Schreibposition des Cursors fest. PSET X,Y - Zeichnet einen Punkt auf dem Bildschirm CLS - Löscht den Anzeigebereich LET [Variable] = [Ausdruck] - weist einer Variablen einen Wert zu
Several commands and instructions can also be specified in the same program line. A colon is used to separate:
10 LET A$="Hallo":LET B$="Welt!":PRINT A$;:PRINT " ";:PRINT B$
However, such a notation has hardly any advantages. The processing speed does not increase and individual commands within such a line have no jump address. Such code is also poorly readable. Only in some restricted systems with only a small line number memory does this method enable larger programs that otherwise require more lines than the system makes available for storage.
Usually the first statement is automatically indented with just a single space separated from the line number. However, you can quickly lose track of things, especially with nested program loops. The colon is therefore often used to represent code indented:
10 FOR A=100 TO 200 STEP 10 20 :FOR B=1 TO 10 30 ::PRINT A + B 40 :NEXT B 50 NEXT A
Some later dialects, e.g. B. AmigaBASIC, can use so-called labels as jump target. Labels are ended with a colon and thus marked as such. With labels, targets can be addressed independently of a line number. Programs can do without line numbers at all, even if this option still exists. An example:
Hauptprogramm: FOR A=1 TO 10 GOSUB Farbwechsel PRINT "Hallo Welt!" NEXT A END Farbwechsel: COLOR A,0 RETURN
The following example shows a typical BASIC code. Many commands that have become established in newer languages and newer BASIC dialects do not yet exist in the BASIC used in the example. This forced the programmer to program in an unstructured manner. An advantage of the old BASIC dialects, however, was that they could easily process character strings (see lines 70–90 in the example program).
10 INPUT "Geben Sie bitte Ihren Namen ein"; A$ 20 PRINT "Guten Tag, "; A$ 30 INPUT "Wie viele Sterne möchten Sie?"; S 35 S$ = "" 40 FOR I = 1 TO S 50 S$ = S$ + "*" 55 NEXT I 60 PRINT S$ 70 INPUT "Möchten Sie noch mehr Sterne?"; Q$ 80 IF LEN(Q$) = 0 THEN GOTO 70 90 L$ = LEFT$(Q$, 1) 100 IF (L$ = "J") OR (L$ = "j") THEN GOTO 30 110 PRINT "Auf Wiedersehen"; 120 FOR I = 1 TO 200 130 PRINT A$; " "; 140 NEXT I 150 PRINT
Norms and standards
- ANSI . ISO Standard for Minimal BASIC (ISO / IEC 6373: 1984 Data Processing — Programming Languages — Minimal Basic )
- ANSI standard. ISO standard for full basic (ISO / IEC 10279: 1991 Information Technology - Programming Languages - Full Basic )
- 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 )
Most interpreters and compilers only partially adhere to these guidelines.
In addition to the standard commands, almost all interpreters have additional functions and language extensions in order to use the corresponding platform completely and more effectively. An instruction set expanded in this way is called a BASIC dialect , see the list of BASIC dialects .
- Hans-Joachim Sacht: BASIC dialects . Humboldt-Taschenbuchverlag, Munich 1985, ISBN 3-581-66524-7 .
- Rüdeger Baumann: BASIC - An introduction to programming. Klett Verlag, Stuttgart 1980, ISBN 3-12-717700-3
- Hans-Joachim Sacht: BASIC programming language - step by step. Humboldt-Taschenbuchverlag, Munich 1983, ISBN 3-581-66456-9
- A Manual for Basic (1964). October 1, 1964, accessed May 1, 2020 .
- Education: High Math at Hanover . In: Time . February 23, 1959, ISSN 0040-781X ( time.com [accessed May 1, 2020]).
- Fifty Years of BASIC, the Programming Language That Made Computers Personal. Retrieved May 1, 2020 .