Click here to Skip to main content
15,881,172 members
Articles / All Topics

The Myth about BASIC

Rate me:
Please Sign up or sign in to vote.
4.75/5 (28 votes)
10 May 2016CPOL7 min read 37.4K   4   31
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 few 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 BASICs 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 (i.e., MyNumber%), while today adding type definitions (i.e., MyNumber AS LONG). Some compilers support both (data type indentifiers have some advantages for some oldtime programmers). The data types in ancient BASICs were limited, but todays BASICs are rich with data types.

When Object Oriented Programming (OOP) became the rage, many BASICs 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 BASICs 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 supposed 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

BASIC Which Is Cross Platform

Free BASIC Compilers

Hobby BASICs

Windows Professional BASIC Compilers

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 BASICs which target a group of microcontrollers (i.e., 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. Microsoft's Visual Basic .NET is an example of BASIC changing and adapting to the needs of managed language development. While Visual Basic .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.

This article was originally posted at http://cwsof.com/blog?p=897

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Computer Workshop
United States United States
Chris Boss is the owner (and programmer) of a small software development business in rural Virginia, called the Computer Workshop. For the last ten years or so he has been developing tools for use by Powerbasic programmers (see: http://powerbasic.com ). His main product called EZGUI (Easy GUI) is a high level GUI engine with Visual Designer and code generator. It is in its fifth generation now. He is an experienced Windows API programmer (more low level) and has experience in writing GUI engines (forms/controls), drag and drop Visual Designers, Graphics engines (printing and to the screen) and one of his favorites is a Sprite engine (2D animated movable images). His current project is version 5.0 of his main product EZGUI, adding such features as multi-monitor support, component engine, custom control engine, superclass engine and the latest project a 3D OpenGL based custom control. One of the goals he has is to push the limits of Windows software development, while making it easy, fast execution speed, small footprint (size of executables) and code reusability while providing a more graphic experience in user interfaces, while still being able to write software which can fit on a floppy disk (small footprint), use minimal amount of memory and able to run on multiple versions of Windows from 95 to Win8.

Comments and Discussions

 
Questionthanks for great info Pin
Southmountain10-Dec-22 7:43
Southmountain10-Dec-22 7:43 
GeneralMy vote of 5 Pin
Avelino Ferreira4-Jun-16 5:50
professionalAvelino Ferreira4-Jun-16 5:50 
GeneralMy vote of 5 Pin
Member 1242414023-May-16 5:26
Member 1242414023-May-16 5:26 
QuestionBasic BASIC Pin
BarbaAlba17-May-16 8:24
BarbaAlba17-May-16 8:24 
QuestionPick BASIC Pin
Jeremy David Thomson11-May-16 16:49
Jeremy David Thomson11-May-16 16:49 
QuestionOh no, not again. Pin
DaveArel11-May-16 9:17
DaveArel11-May-16 9:17 
AnswerRe: Oh no, not again. Pin
Chris Boss11-May-16 9:40
professionalChris Boss11-May-16 9:40 
QuestionTrue Basic Pin
Member 779680111-May-16 9:15
Member 779680111-May-16 9:15 
QuestionThe key to a modern BASIC Pin
Chris Boss11-May-16 9:05
professionalChris Boss11-May-16 9:05 
QuestionYes, Yes and Yes Pin
TimFlan11-May-16 8:05
TimFlan11-May-16 8:05 
AnswerRe: Yes, Yes and Yes Pin
Chris Boss11-May-16 8:16
professionalChris Boss11-May-16 8:16 
GeneralRe: Yes, Yes and Yes Pin
TimFlan11-May-16 23:14
TimFlan11-May-16 23:14 
GeneralRe: Yes, Yes and Yes Pin
Chris Boss12-May-16 3:27
professionalChris Boss12-May-16 3:27 
QuestionBASIC has its place Pin
Chris Boss11-May-16 8:00
professionalChris Boss11-May-16 8:00 
Having used a number of BASIC languages since the 1980's, I am still not convinced BASIC is only for beginners. Having worked with the low level WIN32 API for nearly a decade and a half, I can't imagine myself using anything but BASIC. My BASIC WIN32 code is much easier to read and following than C, IMO.

The old saying "the proof is in the pudding" holds true about BASIC. If a professional programmer can write an application in BASIC which runs as fast and works as well as one written in another language, then "why not use BASIC".

Having written things like a Visual Designer for programming (drag and drop engine), custom controls like an OpenGL based Canvas control, 2D sprite engines using the Windows DIB Engine and the like, I don't see any limits to BASIC. Having a compiler which can compile nearly 50,000 lines of code in 2 seconds on even a mass market Walmart purchased PC, IMO rivals any C compiler. Building apps smaller than anything one can do with todays managed languages is simply a plus. App performance is on par with C as well. So what is missing ?
QuestionBasic Language Pin
Member 1202926811-May-16 7:42
Member 1202926811-May-16 7:42 
QuestionMicrosoft's Visual Basic .NET is an example... Pin
Thornik11-May-16 7:07
Thornik11-May-16 7:07 
AnswerRe: Microsoft's Visual Basic .NET is an example... Pin
Member 1078816711-May-16 7:12
Member 1078816711-May-16 7:12 
GeneralRe: Microsoft's Visual Basic .NET is an example... Pin
Thornik12-May-16 5:30
Thornik12-May-16 5:30 
AnswerRe: Microsoft's Visual Basic .NET is an example... Pin
Slow Eddie11-May-16 8:06
professionalSlow Eddie11-May-16 8:06 
AnswerRe: Microsoft's Visual Basic .NET is an example... Pin
F. Xaver11-May-16 21:11
F. Xaver11-May-16 21:11 
GeneralRe: Microsoft's Visual Basic .NET is an example... Pin
Thornik12-May-16 5:21
Thornik12-May-16 5:21 
QuestionAll Dijkstra's Fault? Pin
PeejayAdams11-May-16 4:35
PeejayAdams11-May-16 4:35 
QuestionBASIC - one major issue Pin
Alex (RSA)10-May-16 23:25
professionalAlex (RSA)10-May-16 23:25 
AnswerRe: BASIC - one major issue Pin
Chris Boss11-May-16 5:14
professionalChris Boss11-May-16 5:14 
QuestionRe: BASIC - one major issue Pin
SteveHolle11-May-16 6:52
SteveHolle11-May-16 6:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.