The myth about BASIC

Is it true ? That BASIC is bad and teaches poor programming practices .

Is it true ? That BASIC is for novices only and should be shunned if one wants to learn “real” programming.

Is it true ? That BASIC is obsolete.

The myth about BASIC

All of the above are an urban legend, a myth. No self respecting modern programmer likely will agree with this accessment, but that does not change the truth. Yes, the statements above do not represent the reality about BASIC.

Why BASIC in the first place ?

In the early years, programming was done using assembler (machine language) and the need for higher level languages generated all sorts of different programming languages, like Algol, Pascal, Forth, Fortran, Lisp, C and yes BASIC.  Many of the early languages have passed on into obscurity, while others have grown, matured and are still used today.  Having learned both 6502 machine language and 8086 (early x86) machine language myself, I can attest to the challenges of coding using machine language.

What many programmers may not fully appreciate today is that the different programming languages were developed to solve a unique problem. A different problem promoted the development of each different language. The idea of the “superior” language is a myth. Each language had a purpose and the better a language solved its specific problem, the more likely it stayed around. In the early years of programming one of the biggest problems was how slow computers were and how little resources they had (hard drive, memory, video). Some programming languages were the product of these limitations and the language reflected strange syntaxes which were less of a benefit to a programmer and were more of a benefit to the compiler itself (to make it faster or require less memory when compiling). Programmers from that era can remember the hours long compile cycle, so it is no wonder some programming languages had syntax which made life easier on the computer (faster), rather than the programmer.

Especially programming languages which have been around a long time, their syntax may have more to do with the early years of limited hardware rather than todays needs. Because it took hours to compile an application, the syntax may have been designed to speed up the compile cycle, making it easier for the compiler to parse the code, rather than make the code easier to read or understand.

BASIC has been misunderstood over time, because todays programmers will often highlight syntax specific to ancient BASIC interpretors, such as line numbers, GOTO, etc. But back when a computer only had less than 64 kilobytes of available RAM, languages like BASIC had to solve the problem of limited hardware, saving memory at all costs and keeping code size to a minimum. How early ROM based BASIC languages like the one in the Commodore 64 computer did this and made programming possible is simply amazing when you know the facts. That ancient BASIC allowed programmers to write hooks into the ROM interpreter to add new commands, embed machine language directly and provided direct access to the hardware (remember PEEK and POKE). For what it accomplished back then, BASIC was truly an amazing language. Early BASIC interpreters sped up development because one could see and test the results of their code almost immediately. This is why the PCode based interpreter was invented! I can remember writing code in Fortran in college on punch cards and have to wait hours for the computer department to run my cards and print out the results.  When BASIC interpreters were created which could run on a standalone terminals, using time sharing, the results were simply amazing.

BASIC also attempted to solve another key problem in programming, ease of use. If there is one primary problem BASIC attempted to solve, it was ease of use. Today we would refer to this as making a programming language with a more “natural syntax”. What does that mean ? Ancient programming using machine language was definitely not natural and some early programming languages were designed to solve problems with compile speed, database issues or complex math problems, but cared little about ease of use and a more natural syntax (closer to the way people think and speak). BASIC from the beginning concentrated on ease of use and a natural syntax. One simple example is the use of the “end of line” as a block recognition rather than say curly brackets in C. People who speak English, don’t write books using curly brackets to break things up. BASIC’s simple end of line syntax has made it much more readable, even to non-programmers.

BASIC’s original purpose of ease of use and natural syntax has remained, while other aspects such as line numbers have disappeared because computers are not limited in memory and speed anymore. Like other programming languages, BASIC has matured over time. Some things like GOTO and GOSUB still remain in some BASICs, but not because the language hangs on to obsolete coding styles, but because the concepts of GOTO and GOSUB are at the core of machine language and how computers really work, so keeping the commands in the language provides performance enhancements to the language. Yes, the lowly GOSUB can be used in modern modular procedural code to improve speed. Subroutines and functions provide a higher level of modular design, but GOSUB can produce modular design and performance within a subroutine itself.

Modern BASIC’s have added aspects from many other languages, such as Pascal and C. For example, BASIC used to use data type identifiers for variables, such as the % or & character (ie. MyNumber%), while today adding type definitions (ie. MyNumber AS LONG). Some compilers support both (data type indentifiers have some advantages for some oldtime programmers). The data types in ancient BASIC’s were limited, but todays BASIC’s are rich with data types.

When Object Oriented Programming (OOP) became the rage, many BASIC’s added their own forms of OOP. Some compilers today support both a more procedural style of coding (similar to older style C coding) as well as support objects, classes, methods and properties. Some BASIC compilers support low level functionality found in C like pointers, pointers to pointers, etc.  The need for interpreters in BASIC is much less today and a few BASIC dialects are available as interpreters which target hobby programmers mostly. Yet some BASIC’s are lightning fast compilers with compile speeds so fast that there is little need for an interpreter anymore. For example, I just did a quick compile of one of my libraries with over 45,500 lines of code in it and only took 1.6 seconds to compile and on an old legacy Vista PC with only a Pentium D processor and 2 gig RAM at that. No need for an interpreter today with compile speeds like that. Such compile speeds in BASIC rival that of any C compiler today.

BASICs longevity

Rather than simply die, BASIC has matured over time and its longevity is evidence of this. The number of different BASIC dialects today is astounding for a programming language which is suppose to be obsolete and dead. Let’s consider some those dialects. The following is not all inclusive, but simply some of the BASIC dialects I have tried and am familiar with. There are many more than this. BASIC tends to fall out of the mainstream, so each dialect tends to target a specific market, such as game development, hobby programming, cross platform development, WIN32 native code compiling, etc.

BASIC for game development

BlitzMax

Dark Basic  (Now Open Source)

BASIC which is Cross Platform

Monkey-X

App Game Kit 2

NS Basic

PureBasic

GLBasic

Free BASIC compilers

FreeBasic

Hobby BASICs

Liberty Basic

Microsoft Small Basic

ThinBasic

Windows Professional BASIC compilers

PowerBasic  (WIN32 native code compiler)

 

The above is not all inclusive, but is only a few of the BASIC languages I am familiar with. In the microcontroller world, there are a number of BASIC’s which target a group of microcontrollers (ie. PicBasic). They come in different flavors from interpreter to full blown compilers. The App Game Kit language has recently annouced a freeware version for the Raspberry PI computer, which is worth mentioning.

BASIC is still alive and thriving

BASIC is obviously still alive and thriving. Microsofts Visual Basic dot.net is an example of BASIC changing and adapting to the needs ot managed language development. While Visual Basic dot.net has left behind many of the core tenants of BASIC, in favor of managed language development, it still provides some aspects BASIC programmers prefer, over other languages. Each dialect of BASIC attempts to solves problems specific to a certain market or situation, so there is no “one size fits all” BASIC available. It is not uncommon for programmers who love BASIC to have multiple dialects of BASIC on their computers, using different ones for different purposes.