Basic

BASIC (Beginner's All-purpose Symbolic Instruction Code) is a simple dynamic imperative programming language developed in the 1960s.

Why would I learn this language?

BASIC is a simple language which is easy to learn. It provides a simple set of semantic constructs and data types. There are many free software implementations, but unfortunately the most typically used implementation is proprietary (Microsoft Visual Basic).

Starting Points

Gambas
Gambas is a full-featured object language and development environment built on a BASIC interpreter.
FreeBASIC
FreeBASIC is a completely free, open-source, 32-bit BASIC compiler with a large supportive community.
Visual Basic Developer Center
Introduction to programming with Visual Basic, as well as many other more advanced topics.
Visual Basic .NET Tutorials for Beginners
An introduction to programming for beginners.

BASIC was developed by Microsoft into several platforms, including QBasic and Visual Basic. Visual Basic has object oriented features and includes a drag and drop user interface toolset. These tools are proprietary and generally only work on Microsoft Windows. Other dialects of BASIC exist for various platforms, such as REALbasic.

Example Code

The following is an example of the Fizz Buzz problem.

FOR I = 1 TO 100
    IF MOD(I,3)=0 AND MOD(I,5)=0 THEN
        PRINT "FizzBuzz"
    ELSEIF MOD(I,3)=0 THEN
        PRINT "Fizz"
    ELSEIF MOD(I,5)=0 THEN
        PRINT "Buzz"
    ELSE
        PRINT I
    ENDIF
NEXT I

The following is an example of the 100 doors problem.

' Define an array of 100 doors
DIM doors(0 TO 99)

' Process the doors
FOR pass = 0 TO 99
	FOR door = pass TO 99 STEP pass + 1
		' Toggle the door
		doors(door) = NOT doors(door)
	NEXT door
NEXT pass

' Print out the results
FOR i = 0 TO 99
	PRINT "Door #"; i + 1; " is ";
	IF NOT doors(i) THEN
		PRINT "closed."
	ELSE
		PRINT "open."
	END IF
NEXT i

Further Reading

comments powered by Disqus