BASIC

ImprimirCitar

BASIC, an acronym for Beginners' All-purpose Ssymbolic Instruction Code (in Spanish: 'Código simbolico de general purpose instructions for beginners'), is a family of high-level programming languages. The original BASIC, Dartmouth BASIC, was designed in 1964 by John George Kemeny, Thomas Eugene Kurtz, and Mary Kenneth Keller at Dartmouth College in New Hampshire, USA, as a means of making computer programming easier for students (and teachers). They weren't science. At that time, almost all use of computers required coding custom software, thus restricting it to people trained as scientists and mathematicians. BASIC was originally developed as a teaching tool. The language and its variants became widely available on microcomputers in the late 1970s and 1980s. BASIC remains popular today in a handful of highly modified dialects, and in new BASIC-influenced languages such as like Microsoft Visual Basic or Gambas in GNU/Linux. In 2006, 59% of developers for the.NET platform used Visual Basic.NET as their only language.

History

Background

Screenshot showing Atari BASIC, an early BASIC language for small computers

In the early 1960s, computers were extremely expensive and used only for special purposes, performing "single task" at once. However, over the course of that decade, prices dropped to the point where even some small businesses could afford them. The processing speed of the machines increased to the point that they were often idle for too long, because there were not enough tasks for them. All this was due to the rapid evolution of hardware. The programming languages of those times were designed for specific purposes, like the machines on which they were executed; For example, to develop calculation or formula processing applications, the FORTRAN language was designed, while for programming in administration or information management, COBOL was specifically developed.

In order to increase performance and better amortize costs (by reducing processor idle time), and since the speed of the machines began to allow it, the idea of executing more than one task was proposed "simultaneously", it was thus that the concept of timeshare system emerged, which began to gain a lot of popularity. In systems of this type, the processing time of the central processor was divided up, and each user was sequentially and cyclically granted a small portion or "quota" of the data. of process time. The machines were fast enough to give users the illusion that they had the machine's functionality available to them all the time ("pseudo-simultaneity" of processes). This distribution of computing time among users considerably reduced the cost of computing, since a single machine could be shared by many users.

Birth and early years

The BASIC language was invented in 1964 by John George Kemeny (1926-1992) and Thomas Eugene Kurtz (1928-) at Dartmouth College, with the help of others such as programmer Mary Kenneth Keller. In subsequent years, as other BASIC dialects appeared, the original Kemeny and Kurtz BASIC became known as Dartmouth BASIC.

BASIC was designed to allow students to write programs using time-sharing computer terminals. It was intended to dramatically reduce the complexity of the other languages of the day, with one designed specifically for the kind of users that time-sharing systems allowed: a simpler user, outside of computer science, who doesn't care. I was so interested in speed, just being able to program and use the machine without too much hassle. The designers of the language also wanted it to remain in the public domain, which contributed to its rapid spread.

The eight principles that governed the design of BASIC were:

  1. Be easy to use for beginners.
  2. To be a language of general purpose (not oriented).
  3. Allow experts to add advanced features, keeping language simple for beginners.
  4. Be interactive in all cases.
  5. Provide clear and friendly error messages.
  6. Respond quickly in small programs in general.
  7. Do not require a computer hardware knowledge.
  8. Protect the user from the operating system.

The language was partly based on FORTRAN II and partly based on Algol 60, with additions to make it suitable for time-sharing systems and with elements to facilitate matrix arithmetic operation. BASIC was first implemented for the GE-265 mainframe, a machine that supported multiple terminals.

In 1968 Edsger Dijkstra published a letter with a famous critique in which he considered that programming languages that use GOTO statements to structure a program were detrimental to the programmer's productivity, and to the quality of the resulting code. This article does not mention any particular programming language; it only indicates that excessive use of GOTO in high-level languages is not recommended, and provides the technical reasons why this is so. But it was observed, since its inception, a marked tendency of programmers to excessively use the GOTO in BASIC, especially in newcomers; This fact that was decreasing with the incorporation to the language of other resources, such as parameterized subroutines, and later with the appearance of structured programming techniques.

Contrary to popular belief, BASIC was initially not an interpreted language but a compiled one. Almost immediately after its release, computer professionals began to claim that BASIC was too slow and too simple. Such an argument, until not long ago, was a recurring theme in the computer industry.

Even so, BASIC spread to many machines and platforms, becoming moderately popular on minicomputers such as the DEC PDP series and the Data General Nova. In these cases, the language was implemented as an interpreter, instead of a compiler, or alternatively, in both modes of operation.

Explosive Growth

Capture of the Commodore PET-32 microcomputer showing a program in the BASIC programming language, under the VICE emulator in a GNU/Linux distribution. The first line, entitled (rem) to the program to allow its storage, the second one, requests a data chain (input) that once obtained, will store in an instruction that the language has incorporated, called alphanumeric variable ($). The third line, establishes a condition, (if) determines that if the stored text string is not equal to the given value, proceed (then) to run the previous line, thus requesting new data, but in case it is equal, (=) continue to execute the next line of the program. The fourth line, prints the message on screen (print), to end the fifth line that sets its end. (end)

However, it was with the introduction of the Altair 8800 microcomputer in 1975 that BASIC became widely available. Most programming languages were too large to be accommodated by the small memories available to most machines at the time; and with the slow storage afforded by paper tape, and later audiocassette tape (magnetic disks did not yet exist), and the lack of suitable text editors, a small language like BASIC was a good choice. One of the first to appear was Tiny BASIC, a simple implementation of BASIC originally written by Dr. Li-Chen Wang, and later ported to the Altair machine by Dennis Allison, at the request of Bob Albrecht (who later founded Dr. Dobb's Journal (DDJ)). Tiny BASIC's design and complete source code was published on DDJ in 1976.

In 1975 Microsoft (then made up of two people: Bill Gates and Paul Allen) released Altair BASIC. Versions for other platforms then began to appear under license, and millions of copies and variants would soon be in use. VISUAL BASIC became one of the standard languages on the Apple II. In 1979 Microsoft was negotiating with various microcomputer vendors, including IBM, to license a BASIC interpreter for their computers. A version was included in IBM PC ROMs for diskless computers. The computers that had a floppy drive, BASIC was started automatically as long as no bootable floppy disk was placed as the operating system.

New companies were trying to follow in the footsteps of Altair's success: IMSAI, North Star, and Apple, creating the home computer revolution. BASIC became a standard feature for almost all home computers; most came with a basic operating system and BASIC interpreter, all housed in a ROM (first done on the Commodore PET in 1977). Soon there would be many millions of computers around the world running BASIC, a number far greater than all the users of other languages combined. Many programs, especially those on the Apple II and IBM PC, depended on the presence of the Microsoft BASIC interpreter and could not run without it; so Microsoft used the copyright license in the BASIC interpreters to influence negotiations with computer vendors.

BASIC was also the language pre-installed on European home computers of the 1980s such as the ZX Spectrum (Sinclair BASIC), Amstrad CPC (Locomotive BASIC), MSX (MSX BASIC), the Commodore 64 and 128 (Basic 2.0, Basic 7.0, Simons' Basic), the Commodore Amiga (AmigaBASIC) or the Atari 8-bit family (Atari BASIC) and on the Japanese NEC PC-8801 and NEC PC-9801 (N88-BASIC) home computers, many times doing the function of interpreter and primitive operating system, since they were both implemented in ROM. Texas Instruments incorporated its own version in its microcomputers, such as the TI99/4A, and also with an extended version in an external ROM or cartridges (TI-Basic and TI Extended

Maturity

New and more powerful versions of BASIC were created in this period. Microsoft sold several versions of BASIC for MS-DOS/PC-DOS, including BASICA, GW-BASIC (a BASICA-compatible version that did not need the IBM ROM), and Quick BASIC. Turbo Pascal's maker, Borland, released Turbo BASIC 1.0 in 1985 (successor versions are still sold under the PowerBASIC name by another company). Various extensions of BASIC appeared for home computers, typically with capabilities for graphics, sound, and DOS commands, as well as facilities for Structured Programming. There were languages that used the BASIC syntax as a base for totally different systems, for example GRASS.

In the late 1980s, however, newer computers were much more complex, and included features (such as the Graphical User Interface) that made BASIC less suitable for programming them. At the same time, computers were progressing from hobbyist interest to tools used primarily to run applications written by others, and programming itself became less important to a growing majority of users. BASIC began to fade, although numerous versions were still available.

One of the most powerful was the so-called Locomotive BASIC 2 designed for the GEM graphical environment. This new version of the language made it possible to create applications with graphical interfaces equipped with windows, menus and different types of statistical graphs.

BASIC's fortunes turned again with the introduction of Visual Basic from Microsoft. Although this language uses practically all the keywords (statements, control structures and intrinsic functions) and way of handling and type of data than previous BASIC versions (DOS); VB is abysmally more powerful and evolved; and it has become one of the most widely used languages on the Windows platform; It is estimated [citation required] that between 70 and 80% of all commercial applications are programmed in VB. Starting in 2002, and with the introduction of Microsoft's.NET Framework, Visual Basic began to use the "object-oriented" paradigm, increasing the power of the language and making it cross-platform. Visual Basic for Applications (VBA) was added to Microsoft Excel 5.0 in 1993 and to the rest of the Microsoft Office product line in 1997. Windows 98 included a VBScript interpreter. The latest version of Visual Basic is called VB.NET. On the other hand, there is also the less powerful but VBA-like variant OpenOffice.org Basic from Microsoft.

Language

Syntax

The minimal BASIC syntax requires only the LET, INPUT, PRINT, IF, and GOTO commands. An interpreter that runs programs with this minimal syntax does not need a stack. Some of the early implementations were that simple. If a stack is added to it, nested FOR loops and the GOSUB command can also be added. A BASIC interpreter with these characteristics requires that the code have line numbers.

Line numbers were a very distinctive aspect of classic BASIC. However, the use of line numbers has the disadvantage of requiring the programmer to estimate how many lines the part of the program they write will occupy. This requirement is generally met by incrementing the line numbers at a regular interval, such as 10, but this leads to problems when later added code exceeds the space available between the original lines. To alleviate this problem for early BASIC interpreters, expert users soon wrote their own utilities to renumber their programs, after initial login. Later, BASIC interpreters appeared that included a specific RENUMBER command, which allowed renumbering quickly (and as many times as desired) all the code again, with any indicated interval between lines and starting from a given integer; thus eliminating the main problem of mandatory line numbering.

Modern MIUN BASIC dialects no longer need to include line numbers (although they are allowed), and most (or all) have added structured control flow and data declaration constructors similar to those of other languages, such as C and Pascal:

  • do
  • loop
  • while
  • until
  • Success
  • on...
  • Gosub
  • select... case

Almost all BASIC dialects include the REM (remark) command, which was later replaced by the ´ (apostrophe or single quote) symbol. It is a non-executable command, it is used for the purpose of including explanatory lines and notes in the source code, for a better understanding (and documentation) of the program.

Recent variants like Visual Basic have introduced some object-oriented features, and even inheritance in the latest version. Memory management is easier than with many other procedural programming languages because of the use of a Garbage Collector (and at the cost of execution speed).

Procedures and Flow Control

BASIC does not have a standard external library like other languages like C. Instead, the interpreter (or compiler) contains a built-in library of intrinsic procedures. These procedures include most of the tools a programmer needs to learn to program and write simple applications, as well as functions for performing mathematical calculations, handling strings, console input, graphics, and file manipulation.

Old BASIC dialects did not allow programmers to write their own procedures. Programmers instead had to write their programs with a large number of GOTO statements to make the flow and return derivations of the program. This could produce very confusing source code (most of the time it did), commonly known as Code Spaghetti; which was extremely difficult to maintain, much less by programmers unrelated to software development.

With the later inclusion of GOSUB statements (Go-Subroutine) the program was branched to species of subroutines, without parameters or local variables. They provide a way to implement some sort of procedure (it really isn't, it's just a "jump and return") and to further structure the program, rather avoiding the use of the harmful GOTO statement.

Most newer versions of BASIC, such as Microsoft QuickBASIC (1985-1988) and BASIC PDS (Professional Development System - 1990) added full support for subroutines, functions, and structured programming. This is another area where BASIC differs from many programming languages. However, the GOSUB primitive has been kept up to current versions, for compatibility reasons.

BASIC, like Pascal, makes a distinction between a procedure that doesn't return a value (called a subroutine) and a procedure that does (called a function). Many other languages (like C) don't make that distinction and treat everything as a function (some returning a “void” value).

While functions that return a value are a relatively recent addition to BASIC dialects, many early systems supported the definition of mathematical functions inline, with DEF FN (“DEFine FunctioN ” [DEFINE FUNCTION]). The original Dartmouth BASIC also supported Algol-style functions as well as subroutines from its earliest days.

Types of Data

BASIC is known to have very good functions for manipulating strings. Early dialects already had a set of fundamental functions (LEFT$, MID$, RIGHT$) to easily extract and/or replace substrings. Since strings are used in everyday applications, this was a considerable advantage over other languages at the time of its introduction.

The original Dartmouth BASIC supported only string and numeric data types. There was no whole type. All numeric variables were floating point. Strings were dynamically sized. It supported arrays of both numbers and strings in one or two dimensions.

Every modern dialect of BASIC has at least the numeric and string data types. These data types can be distinguished by using a postfix: string identifiers end with $ (dollar sign, eg the variable NAME$), while numeric ones simply have no postfix; unless you are required to explicitly state and force what kind of numeric it is, eg A% is integer, A! is real single precision and A# is real double precision.

In BASIC, variables do not necessarily need to be declared before they are used, except for arrays with more than 10 elements; although relatively modern BASIC versions have the option (considered good programming practice) to force the programmer to declare every variable before its use (a directive like OPTION EXPLICIT). Variable declaration in BASIC is done using the DIM keyword.

Many dialects also support additional numeric types, such as 16-bit and 32-bit integers (simple and long, respectively), in addition to their floating-point numbers. Additionally, some allow the use of user-defined data types, similar to "records" of Pascal, or the "structs" of C.

Modern versions of BASIC (such as VBA) support a wide variety of primitive (or intrinsic) data types, in addition to user-defined ones.

Most BASIC dialects support arrays on all of their data types; support for multidimensional arrays is also common

Examples:

 DIM Enteros Matrix(100,100) AS INTEGER DIM VectorDeEnteros%(30) DIM List of Names(50) AS STRING DIM List of Cities$(50)

Depending on the dialect of BASIC and the use of the OPTION BASE statement, the first index of arrays declared will be 1, the default is zero.

In the above examples, if "OPTION BASE 1" is not previously declared, the first is a two-dimensional array of 16-bit integers, with indices ranging from 0 to 100 (101 x 101 x 101 items); while the second is an array of integers in a single dimension, from 0 to 30 (vector of 31 elements). Note that the two ways of declaring integers are equivalent, making it explicit or using the % postfix. Similarly for strings or strings of characters, which in this case are also of variable length (dynamic, by default).

Language availability and variants

BASIC is available for almost all existing platforms and operating systems. A free, standards-compliant, cross-platform implementation is Bywater BASIC (bwBASIC). The interpreter is written in C and comes under the GNU license. It is designed for text or console (non-graphical) interface, it does not include support to create graphical user interfaces (GUI's, Graphical User Interface). There is a free BASIC that does include GUI support, is similar to Visual Basic and runs on Windows and GNU/Linux, it is Phoenix Object BASIC.

The best-known interpreter/compiler versions are the Quick BASIC product line and QBASIC, the latter being an interpreter only, both are from Microsoft. At present it is the modern Visual BASIC, which Microsoft has tried to keep at least minimally compatible with even the first versions of its BASICs (actually it is barely compatible), although there is FreeBASIC which is a free compiler, syntax compatible with QBASIC/QuickBASIC.

Other commercial versions include PowerBASIC by PowerBASIC, PureBasic by Fantaisie Software, as well as TrueBASIC by TrueBASIC, which conforms to the latest official BASIC standards. (True BASIC Inc. was founded by the original creators of Dartmouth BASIC.)

REALbasic is a variant available for Mac OS Classic, Mac OS X, Microsoft Windows and GNU/Linux, marketed by the current owners of Rapid-Q, another initially free implementation of BASIC now abandoned. A simple dialect version of BASIC for the parrot virtual machine shows how a BASIC interpreter is implemented in an assembly-like language. SmallBASIC is a dialect that runs on many platforms (Win32, DOS, GNU/Linux and PalmOS) and comes under the GNU license (GPL).

There are many freeware or GNU BASIC implementations, such as BCX, YaBasic, HBasic, XBasic, Gambas or Just BASIC, among others.

Source Code Examples

Example 1: Hello World!

 PRINT "Hello World!"

Example 2: Original Unstructured BASIC (Applesoft BASIC)

 10 INPUT "What's his name:; NN$ 20 PRINT "Welcome to the 'assist'";NN$ 25 PRINT 30 INPUT "with how many asterisks starts [Cero departs]:; N 40 IF N0 THEN GOOD 200 50 AS$=" 60 FOR I=1 TO N 70 AS$=AS$+ 80 NEXT I 90 PRINT "WHERE YOU ARE."; AS$100 INPUT "Desea más asteiscos:";SN$110 IF SN$=" THEN GOOD 100120 IF SN$"S" OR SN$"s" THEN GOOD 200130 INPUT "FUL VECES DESAS TO REPET [Chuckles]; VECES140 IF VECES0 THEN GOOD 200150 FOR I=1 TO VECES160 PRINT AS$;170 NEXT I180 PRINT185. REM To repeat the entire cycle (comentary)190 GOOD 25200 END

Example 3: Structured BASIC equivalent (Quick BASIC)

 DEFINT I-N 'Declares all variable that begins with letters I to N iTrue = -1 'Flag in True INPUT "What's his name"; NameUsario$ PRINT "Bivened to the 'assist',"; NameUsario$ DO PRINT " INPUT "With how many asterisks he starts [Cero departs]:; NroAsteriscos IF NroAsteriscos0 THEN EXIT DO Asteriscos$ = " FOR I=1 TO NroAsteriscos Asteriscos$=Asteriscos$ +  NEXT I PRINT "WHO THEY ARE: "; Asteriscos$ DO INPUT "Desea más asteiscos:";SN$ LOOP UNTIL SN$" IF SN$"S" OR SN$"s" THEN EXIT DO 'Outside INPUT "FUL VECES DESAS TO REPET [Chuckles];Veces IF Veces0 THEN EXIT DO 'Outside FOR I = 1 TO Veces PRINT Asteriscos$; NEXT I PRINT LOOP WHILE iTrue END

Contenido relacionado

Anti virus

The antivirus are programs whose objective is to detect and eliminate computer viruses. Over time, antiviruses have evolved towards more advanced programs...

PLC

The acronym PLC or plc can refer...

Monoid

In abstract algebra, a monoid is an algebraic structure with a binary operation, which is associative and has a neutral element, that is, it is a semigroup...
Más resultados...
Tamaño del texto:
Copiar