BASIC was, well… basic

The BASIC programming language was so called because it was meant to be easy to learn , and easy to use.

BASIC descended from Fortran, with the same simple structure and an avoidance of nesting and recursion. The first version of BASIC had remarkably few statements: LET, PRINT, END, FOR, NEXT, GOTO, IF THEN, DEF, READ, DATA, DIM, GOSUB, RETURN and REM. The distinction between integer and real variables was abolished and variable were restricted to names consisting of a single letter or a single letter and a digit. The simplicity of BASIC made it easy for novice programmers to learn.

Consider the following example BASIC program that calculates accrued interest:

10 INPUT "principal"; P
20 INPUT "interest rate"; R
30 INPUT "no of periods per year"; NP
40 INPUT "years"; YRS
50 I = P * ((1+R/(100*NP))^(NP*YRS)-1)
60 PRINT "total interest =" I

Here is the same program in C:

#include <stdio.h>
#include <math.h>
int main(void)
    double p, r, np, yrs, i;
    printf("principal? ");
    scanf("%lf", &p);
    printf("interest rate? ");
    scanf("%lf", &r);
    printf("no. of periods per year? ");
    scanf("%lf", &np);
    printf("years? ");
    scanf("%lf", &yrs);
    i = p*(pow(1+r/(100*np),np*yrs)-1);
    printf("total interest = %lf\n", i);
    return 0;

This illustrates many of the differences between the two languages. The most apparent is that BASIC uses line numbers, C doesn’t. But the BASIC program is 6 lines long, the C program is 17. The C program uses two lines to achieve input from the user, one for the prompt, one for actually reading in the value. The BASIC program uses one line.

BASIC was successful in the 1980s due to the personal computer. Most personal computers of the time had a ROM-resident BASIC interpreter. The Apple II, PET 2001 and TRS-80 all used BASIC as their core programming language when released in 1977.



One thought on “BASIC was, well… basic

  1. Tim says:

    To be fair, you COULD ask for user input, and receive it, on a single line in C. It’s just bad coding practice. 🙂
    I have fond memories of BASIC from the text-based games people submitted to 3-2-1 Contact magazine. My siblings and I would enter them into QBasic on our 286 line by line. Had no idea what any of it meant (other than SOUND statements, which produced a system beep at the desired frequency — pre-sound-blaster days), and so debugging meant reading through the whole thing line-by-line to spot the typo.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.