BASIC From Wikipedia, the free encyclopedia Jump to: navigation, search This article is about the programming language

. For the think tank, see British American Security Information Council. For the group of nations popularly called BASIC block, see G4 bloc. This article is written like a personal reflection or essay and may require cleanup. Please help improve it by rewriting it in an encyclopedic style. (January 2010)

Screenshot of Atari BASIC, an early BASIC language for small computers BASIC unstructured, later procedural, later object-oriented 1963 John George Kemeny and Thomas Eugene Kurtz strong Apple BASIC, Commodore BASIC, Microsoft BASIC, BBC BASIC, TIBASIC ALGOL 60, FORTRAN II, JOSS


Appeared in

Designed by

Typing discipline

Major implementations

Influenced by

2 Structured BASIC 2.2 Explosive growth: the home computer era 1. The original BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire.2 Program flow control 4. Perl.1 Early years: the mainframe and mini-computer era 1.3 Input and output 4.NET platform used Visual Basic .1 Data manipulation 4. REXX. As of 2006.NET as their only language. Visual Basic .[2] Contents [hide] y 1 History o o o 1.NET. USA to provide computer access to non-science students. Visual BASIC. GRASS In computer programming.1 Unstructured BASIC 2.3 Maturity: the personal computer era y 2 Examples o o o 2.Influenced COMAL. nearly all use of computers required writing custom software. At the time.4 Miscellaneous . 59% of developers for the . which was something only scientists and mathematicians tended to be able to do.3 BASIC with object-oriented features y y 3 Data types and variables 4 List of typical BASIC keywords o o o o 4. Realbasic. BASIC remains popular to this day in a handful of highly modified dialects and new languages influenced by BASIC such as Microsoft Visual Basic. BASIC (an acronym for Beginner's All-purpose Symbolic Instruction Code[1]) is a family of high-level programming languages. The language and its variants became widespread on microcomputers in the late 1970s and 1980s.

Being able to use a computer to support teaching and research was quite novel at the time. a system which allows multiple users or processes to use the RAM and memory. But during the 1960s faster and more affordable computers became available. Be easy for beginners to use. a less technical user who did not have the mathematical background of the more traditional users and was not interested in acquiring it.1 Standards y 8 External links [edit] History Before the mid-1960s. there was a strong tendency to consider efficiency to be the most important feature of a language. The eight design principles of BASIC were: 1. In theory. . computers would sometimes sit idle. less expensive machines were still major investments. these specialized languages were difficult to use and had widely disparate syntax. like the machines on which they ran. BASIC was designed to allow students to write programs for the Dartmouth Time-Sharing System. one after another. for specific purposes (such as scientific formula calculations or business data processing or eventually for text editing). Programming languages in the batch programming era tended to be designed. Newer computer systems supported time-sharing. In the following years. timesharing reduced the cost of computing tremendously. giving each one running time on the RAM before switching to another. the possibility of sharing computer access began to move from research labs to commercial use. [edit] Early years: the mainframe and mini-computer era The original BASIC language was designed in 1963 by John Kemeny and Thomas Kurtz[3] and implemented by a team of Dartmouth students under their direction. Kemeny and Kurtz's original BASIC dialect became known as Dartmouth BASIC. As prices decreased. The machines had become fast enough that most users could feel they had the machine all to themselves. In general. With this extra processing power. Since even the newer. A simple batch processing arrangement ran only a single "job" at a time. computers were extremely expensive and used only for special-purpose tasks. In such a system the operating system alternates between running processes. as a single machine could be shared among hundreds of users. It was intended to address the complexity issues of older languages with a new language design specifically for the new class of users that time-sharing systems allowed that is. as other dialects of BASIC appeared. without jobs to run.y y y 5 See also 6 Notes 7 References o 7.

Not to require an understanding of computer hardware. The language was based partly on FORTRAN II and partly on ALGOL 60. 7. 4. notably Edsger W.2.[4] Some have also derided BASIC as too slow (most interpreted versions are slower than equivalent compiled versions) or too simple (many versions. it was a compiled language. In these instances the language tended to be implemented as an interpreter. with matrix arithmetic support from its initial implementation as a batch language and full string functionality being added by 1965. promoted poor programming practices. Respond quickly for small programs. highly respected computer professionals. NH area and put a considerable amount of effort into promoting the language.) It had been preceded by other teaching-language experiments at Dartmouth such as the DARSIMCO (1956) and DOPE (1962 implementations of SAP and DART (1963) which was a simplified FORTRAN II). Allow advanced features to be added for experts (while keeping the language simple for beginners). instead of (or in addition to) a compiler. left out important features and capabilities). beating FORTRAN II and ALGOL 60 implementations on the 265 at several fairly computationally intensive (at the time) programming problems such as numerical integration by Simpson's Rule. The designers of the language decided to make the compiler available free of charge so that the language would become widespread. especially for small computers. Be interactive. Shield the user from the operating system. (The features of other time-sharing systems such as JOSS and CORC. Several years after its release. As a result. Be a general-purpose programming language. Provide clear and friendly error messages. and the Pick operating system. expressed their opinions that the use of GOTO statements. [edit] Explosive growth: the home computer era . which existed in many languages including BASIC. It was also quite efficient. becoming fairly popular on newer minicomputers like the DEC PDP series and the Data General Nova. Dijkstra. 8. They also made it available to high schools in the Hanover. were also considered. knowledge of BASIC became relatively widespread (for a computer language) and BASIC was implemented by a number of manufacturers. The BASIC language was also central to the HP Time-Shared BASIC system in the late 1960s and early 1970s. BASIC concentrated on supporting straightforward mathematical work. 5. with additions to make it suitable for timesharing. At the time of its introduction. and to a lesser extent LISP. 6. BASIC was first implemented on the GE-265 mainframe which supported multiple terminals. 3. Initially.

The first Altair version was co-written by Gates. newer computer designs also introduced their own version of the language. Kemeny and Kurtz's earlier proselytizing paid off in this respect and the few hobbyists' journals of the era were filled with columns that made mentions of the language or focused entirely on one version compared to others.[5] all three had BASIC as their primary programming language and operating environment. in its interpreted form with a built-in code editor.0 Notwithstanding the language's use on several minicomputers. One of the first to appear for the 8080 machines like the Altair was Tiny BASIC. Versions of Microsoft BASIC (also known then. developed by Bill Gates and Paul Allen as the company Micro-Soft. which became widespread in small business environments. As the popularity of BASIC on CP/M spread. limited memory and often substituted recordable audio tapes for disk space. and generally worked in the electronics industries of the day. to operate within those constraints. Commodore Business Machines paid a one-time fee for an unlimited license to a version of Micro-Soft BASIC that was ported to the MOS 6502 in their PET computer. Most programming languages required suitable text editors. Li-Chen Wang. Microsoft. MITS released Altair BASIC. it was the introduction of the MITS Altair 8800 "kit" microcomputer in 1975 that provided BASIC a path to universality. large amounts of memory and available disk space. When three major new computers were introduced in what Byte Magazine would later call the "1977 Trinity".MSX BASIC version 3. and most widely as M BASIC or MBASIC) was soon bundled with the original floppy disk-based CP/M computers. BASIC also had the advantage that it was fairly well-known to the young designers and computer hobbyists who took an interest in microcomputers. Dobb's Journal). which grew into today's corporate giant. or had Micro-Soft port its version to their platform. All these issues allowed a language like BASIC. while Apple II and TRS-80 both . whereas the early microcomputers had no resident editors. a simple BASIC implementation originally written by Dr. and Monte Davidoff. Allen. In 1975. and then ported onto the Altair by Dennis Allison at the request of Bob Albrecht (who later founded Dr. The Tiny BASIC design and the full source code were published in 1976 in DDJ.

10 As early as 1979 Microsoft was in negotiations with IBM to supply their IBM PCs with an IBM Cassette BASIC (BASIC C) inside BIOS. The similarities are striking because the first 50 tokens. additional versions were added that subtly changed the BASIC family. such as Learn to Program BASIC would also have gaming as an introductory focus. [edit] Maturity: the personal computer era The examples and perspective in this article may not represent a worldwide view of the subject.0 in 1985 (successor versions are still being marketed by the original author under the name PowerBASIC). largely similar versions of the language. The BBC published BBC BASIC. there are more dialects of BASIC than there are of any other programming language. Microsoft sold several versions of BASIC for MS-DOS/PC-DOS including IBM Disk BASIC (BASIC D). and other programs. magazines (such as Creative Computing Magazine in the US) published complete source code in BASIC for games. developed for them by Acorn Computers Ltd. allowing the machines to boot directly into BASIC. As new companies entered the field. incorporating many extra structuring keywords. As the popularity of BASIC grew in this period.[6][7][8] Later packages.introduced new. Correcting the publishing errors that frequently occurred in magazine listings was an educational exercise in itself. GW-BASIC (a BASICA-compatible version that did not need IBM's ROM) and QuickBASIC. BASIC source code was also published in fully-fledged books: the seminal examples being David Ahl's BASIC Computer Games series. though some BASIC programs were considered universal and could be used in machines running any variant of BASIC (sometimes with minor adaptations). it was a simple matter to type in the code from the magazine and execute the program. Please improve this article and discuss the issue on the talk page. Given BASIC's straightforward nature. (January 2010) IBM Cassette BASIC 1. Most of the home computers of the 1980s had a ROM-resident BASIC interpreter. Turbo Pascal-publisher Borland published Turbo BASIC 1. utilities. were all the same. Different magazines were published featuring programs for specific computers. Because of this legacy. used for conserving memory. The Atari 8-bit family had their own Atari BASIC that was modified in order to fit on an 8 kB ROM cartridge. . IBM BASICA (BASIC A).

By that time. even VB. Ironically given the origin of BASIC as a "beginner's" language. such as line numbers and the INPUT keyword.NET.[9] also became a favourite for amateur game development. like QBasic before it. and apparently even to the surprise of many at Microsoft who still initially marketed Visual Basic or "VB" as a language for hobbyists. such as improved string manipulation and graphics support. While this could be considered an evolution of the language. since much development was done using "drag and drop" methods without exposing all code for commonly used objects such as buttons and scrollbars to the developer. The only significant similarity to older BASIC dialects was familiar syntax. computers had progressed from a hobbyist interest to tools used primarily for applications written by others. because of the major shift in its orientation towards an object-oriented and event-driven perspective. the language had come into widespread use for small custom business applications shortly after the release of VB version 3. during the lengthy lifetime of VB3. The new graphical features of these languages also helped lay the groundwork for PC video gaming. However. Many small business owners found they could create their own small yet useful applications in a few evenings to meet their own specialized needs. albeit they cannot be used in certain places. These languages introduced many extensions to the original home computer BASIC. as long as massive amounts of data were not involved.0. knowledge of Visual Basic had become a marketable job skill. BASIC's fortunes reversed once again with the introduction of Visual Basic by Microsoft.BAS showing what the PC could do. by the latter half of the 1980s newer computers were far more capable with more resources. computers running Windows 3. While many advanced programmers still scoffed at its use. with BASIC programs like DONKEY. and programming became less important for most users.[10] . Syntax itself no longer "fully defined" the language. VB met the needs of small businesses efficiently wherever processing speed was less of a concern than easy development. and INPUTBOX is available for direct user input. The language. for instance before SUB).1 of the preemptive multitasking GUI Amiga computers (late 1985/ early 1986). few of the distinctive features of early Dartmouth BASIC. It is somewhat difficult to consider this language to be BASIC. which is widely considered the first relatively stable version. More important were the facilities for structured programming.Microsoft wrote the windowing based AmigaBASIC that was supplied with version 1. remain (although Visual Basic still uses INPUT to read data from files. although the product unusually did not bear any Microsoft marks. including additional control structures and proper subroutines supporting local variables. Eventually. BASIC started to recede in importance. line numbers can also optionally be used in all VB versions.1 had become fast enough that many business-related processes could be completed "in the blink of an eye" even using a "slow" language. Compiled BASIC or CBASIC is still used in many IBM 4690 OS point of sale systems. access to the file system and additional data types. At the same time. though numerous versions remained available.

More complex examples of free software BASIC implementations (development tools and compilers) include Gambas and FreeBASIC. Please help improve this article by adding citations to reliable sources.Three modern Basic variants: Mono Basic. Many other BASIC variants and adaptations have been written by hobbyists. This generally involves simple use of the language's PRINT statement to display the message (such as the programmer's name) to the screen. has since 2005 fully compiled programs for Microsoft Windows. However in keeping with BASIC tradition. RealBasic compiled programs may execute natively on these platforms as services. The ubiquity of BASIC interpreters on personal computers was such that textbooks once included simple "Try It In BASIC" exercises that encouraged students to experiment with mathematical and computational concepts on classroom or home computers. An example of an open source interpreter. Unsourced material may be challenged and removed.[11] [edit] Examples This section does not cite any references or sources. from the same object-oriented source code. One notable variant is RealBasic which although first released in 1998 for Macintosh computers. OpenOffice. single-platform hobbyist versions are also still maintained. equipment Basic and Gambas Many BASIC dialects have also sprung up in the last few years. . and others. is MiniBasic. (December 2008) [edit] Unstructured BASIC New BASIC programmers on a home computer might start with a simple program similar to the Hello world program made famous by Kernighan and Ritchie. including Bywater BASIC and True BASIC (the direct successor to Dartmouth BASIC from a company controlled by Kurtz). consoles or windowed applications. written in C. Mac OS X and 32-bit x86 Linux. as it is a relatively simple language to develop translators for. Futurist and sci-fi writer David Brin mourned the loss of ubiquitous BASIC in a 2006 Salon article.

primarily related to structured and procedure-oriented programming. Most first generation BASIC languages such as MSX BASIC and GW-BASIC supported simple data types. A$ 100 IF LEN(A$) = 0 THEN GOTO 90 110 A$ = LEFT$(A$. 1) 120 IF A$ = "Y" OR A$ = "y" THEN GOTO 30 130 PRINT "Goodbye ". NumStars Stars$ = STRING$(NumStars. U$ 140 END [edit] Structured BASIC Second generation BASICs (for example QuickBASIC and PowerBASIC) introduced a number of features into the language. The following example is written for GW-BASIC. N 40 S$ = "" 50 FOR I = 1 TO N 60 S$ = S$ + "*" 70 NEXT I 80 PRINT S$ 90 INPUT "Do you want more stars? ". U$ 20 PRINT "Hello ". "*") .[12] INPUT "What is your name: ". Usually. loop cycles and arrays. UserName$ DO INPUT "How many stars do you want: ".Often an infinite loop was used to fill the display with the message. but will work in most versions of BASIC with minimal changes: 10 INPUT "What is your name: ". line numbering is omitted from the language and replaced with labels (for GOTO) and procedures to encourage easier and more flexible design. U$ 30 INPUT "How many stars do you want: ". UserName$ PRINT "Hello ".

REALbasic. UserName) Do Console. Answer. NumStars) Console. stars As String.WriteLine("Hello {0}". Answer$ LOOP UNTIL Answer$ <> "" Answer$ = LEFT$(Answer$.Write("Do you want more stars? ") .WriteLine(stars) Do Console. NumStars As Integer Console. The following example is in Visual Basic .ReadLine()) stars = New String("*".ReadLine() Console.PRINT Stars$ DO INPUT "Do you want more stars? ".Write("How many stars do you want: ") NumStars = CInt(Console.Write("What is your name: ") UserName = Console. Most built-in procedures and functions now represented as methods of standard objects rather than operators. UserName$ [edit] BASIC with object-oriented features Third generation BASIC dialects such as Visual Basic.NET: Public Class StarsProgram Public Shared Sub Main() Dim UserName. 1) LOOP WHILE UCASE$(Answer$) = "Y" PRINT "Goodbye ". StarOffice Basic and BlitzMax introduced features to support object-oriented and event-driven programming paradigm.

or after. WEND and REPEAT . More powerful versions of BASIC offered floating-point arithmetic. A variable that acts as a counter is available within the loop.used to perform comparisons or make decisions. ELSE Statement .holds a list of values which are assigned sequentially using the READ Command.WriteLine("Goodbye {0}"... FOR .jumps to a numbered or labelled line in the program.repeat a section of code while the specified condition is true. String variables are usually distinguished by having $ suffixed to their name. and variables could be labelled with names six or more characters long. UNTIL Commands .ReadLine() Loop Until Answer <> "" Answer = Answer.. WHILE . THEN . UserName) End Sub End Class [edit] Data types and variables Minimal versions of BASIC had only integer variables and single-letter variable names.. y y .. [edit] List of typical BASIC keywords [edit] Data manipulation y y LET Command .repeat a section of code a given number of times. The condition may be evaluated before each iteration of the loop. GOTO Command .Substring(0.assigns a value (which may be the result of an expression) to a variable. and string values are typically enclosed in quotation marks. floating point or string variables.. DATA Statement ..ToUpper() = "Y" Console. [edit] Program flow control y y IF .. NEXT Statement ..Answer = Console.. 1) Loop While Answer. Arrays in BASIC could contain integers.

. This is used to implement subroutines.displays a message on the screen or other output device. GOTO/GOSUB Command . ON .y GOSUB Command . TAB or AT Function . returning to the following line after encountering the RETURN Command. often used to give a title to the program and to help identify the purpose of a given section of code.temporarily jumps to a numbered or labelled line. See Switch statement for other forms. y [edit] Input and output y y PRINT Statement .holds a programmer's comment..asks the user to enter the value of a variable. The statement may include a prompt message. y [edit] Miscellaneous y REM (Remark) ..sets the position where the next character will be shown on the screen or printed on paper. INPUT Statement .chooses where to jump based on the specified conditions.

Sign up to vote on this title
UsefulNot useful