Basic Articles

BASIC, The Language of Simplicity, Power, and Change Part 4

Now that BASIC is no longer included with most computers or operating systems, it must be obtained from other sources. Fortunately, there are several ways to get BASIC that are both easy and quick.

A good list of BASICs can be found at The Basics Page. This site offers links to about 90 BASIC programming languages with a brief overview and, in some cases, a review and rating.

The Microsoft Visual Basic packages are not included in the list at the above site. If your operating system is Windows and you want to learn BASIC programming using the .NET framework, Microsoft offers Visual Basic 2008 Express Edition free download HERE. The Microsoft Beginner Developer Learning Center offers a lot of excellent resources. The Kid's Corner is a great place to start a youngster off.

FreeBasic is a QBasic/QuickBasic compatible programming package. The site has many links that will be helpful to new programmers. If your interest is in writing software that is usable on Windows, Linux, and DOS, this is a good place to start. FBEdit is an excellent code editor for FreeBasic. Both are open source software programs.

Another multi-platform BASIC is KBasic. This package uses the Qt toolkit for compatibility across platforms. KBasic is available for Windows, Linux, and OS X. Code may be writen in QBasic, Visual Basic 6, or Visual Basic .NET style. This is the package I use for most BASIC projects. Here is a screen shot of the KBasic IDE running on a Debian GNU/Linux system:


KBasic, as with most alternative BASICs, is constantly being improved. It is an easy language for programmers that have some prior experience with BASIC. Beginning programmers will find many resources to assist them with learning and using the package. The only major area that I feel needs work is documentation. It can be a little difficult to find specific information due to things being spread out over several different HTML files. I recommend downloading the Qt documentation, and referring to it, for functions that are not well documented in the KBasic information. Note that to generate standalone executable programs, or to develop commercial software, you have to register KBasic. Registration, as of the last time I checked, cost about $35US, a real bargin compared to many programming languages.

Another interesting, and free, BASIC compiler is Jabaco. The development environment runs on Windows XP. The output files are Java bytecode and will run on any system that has the Java Runtime. The language is very similar to Visual Basic 6 so programmers who are familiar with VB6 will be right at home.

This series is intended to give a little background on the BASIC language with some suggestions on how to obtain the language for those interested in getting started with BASIC programming. There are many other programming languages and, at least as many, opinions that it is better to start with one of them. I believe in using the best tool for the job. For me, BASIC is the fastest and easiest way to do some tasks.

What types of programs can be written in BASIC? Pretty much anything you want to write! From programs to generate simple reports, to games with complex graphics. Todays BASICs are up to the challenge.

Custom reports, using data from multiple sources, and data conversions are two tasks that I often use BASIC for. The string manipulation functions available make these jobs quick and easy. Using output from one program as input to another program is another place where BASIC can save time. For example; generating GL entries that can be imported from standalone inventory programs, is a common tasks for many small businesses. This is the type of job where BASIC can often be the fastest language to use.

BASIC was not the first programming language that I learned. I started with machine language and then progressed to Assembly. The need to create a quick terminal program, for a new computer that included BASIC, was what prompted me to learn it. Today, I write programs using many languages. But, BASIC will always be a big part of my toolbox.

BASIC, The Language of Simplicity, Power, and Change Part 3

With the release of programs like QBasic, Turbo Basic, and QuickBASIC, things got much better for programmers. A lot of things changed in these new BASICs. The change that was easiest to see, was the elimination of the need for numbers on each line, although they could still be used if desired. BASIC could now use plain name labels for GOTO or GOSUB points.

Our simple program to say HELLO could look like this:


















The "GetName:" line is a label for a subroutine that is called with a GOSUB statement.

The other change that was easy to notice was the user interface. A mouse could now be used in the programming interface. Break points could be set to help debug a program. An immediate window was available to test code or to check the values of variables during breaks. The user interface for QBasic looks like this:


Programmers now had a much easier, and more powerful, interface. Skills learned with QBasic were easily transferred to more powerful BASIC compilers, such as QuickBASIC, where programs could be compiled to an executable and run on systems without the need for BASIC.

Using libraries, most with assembly language routines, programs had access to advanced hardware features. Libraries were also available for building graphic user interfaces to be included in a finished program. BASIC was not just for beginning programmers any more. Many commercial programs were being developed with the new BASICs.

Because BASIC was still included with most computers and operating systems, people were still learning to write their own programs with it. QBasic was included with operating systems from Microsoft through, at least, some versions of Windows 98.

As graphical user interfaces and multi-tasking operating systems, such as Microsoft Windows, became dominant, BASIC programmers wanted to be able to write software that took advantage of them. Microsoft released Visual Basic as the replacement for QuickBASIC. Visual Basic changed the game, once again, for BASIC programming. Programs can now be event driven and object oriented. User interfaces can be created by using drag and drop to place elements, such as command buttons, on forms. This is a shot of the IDE for Visual Basic 5:



Using Visual Basic, programmers were able to use features of the Windows API. They were also able to create large portions of their programs without writing any code at all. Visual Basic is able to access many database files using ODBC and/or DAO. From 1995 to 2002, Visual Basic became the preferred language for BASIC programmers writing software for the Windows platform. Even today, a lot of programs are still being written with Visual Basic versions 4, 5, and 6.

In 2002 Microsoft introduced Visual Basic .NET. This language uses the .NET framework and has significant changes from the earlier Visual Basics. Microsoft has since gone back to using the name Visual Basic without the .NET. However, all versions, since Visual Basic 6, use the .NET framework.

Visual Basic has been used for many commercial software packages. At one time, in 2006 according to Wikipedia, 59% of the programmers working on .NET applications were using Visual Basic as their only language. BASIC is not a hobbyist toy anymore.

No operating systems, that I know of, include a BASIC language by default any more. But, there are still many options available for programmers and those who want to write their own software. A lot of these are available at little to no cost. The next article in this series will look at some of these options. It will also show how BASIC can be used to perform some tasks without having to learn a lot of programming or write a lot of code.

BASIC, The Language of Simplicity, Power, and Change Part 2

In Part 1 I mentioned that as hardware changed, BASIC changed with it. The biggest change was in the way BASIC programs flowed.

BASIC programs were a lot like the assembly instructions for things like model airplanes or furniture. Every step was numbered and, with some exceptions, each step was done in numerical order. Programmers controlled the flow of their programs by the numbers placed at the start of every line. For example, a simple program might be something like this:

10 PRINT "Hello"
20 PRINT "Have A Great Day"
30 PRINT "Goodbye"
40 SYSTEM

The system would run each line in order until it got to line 40 and then it would return to the operating system. This simple program would just print 3 lines on the screen and then end. The screen would look like this:


Not really a very useful program, unless you wanted to greet a user with a generic greeting when they start the computer. More often you want to get some input from the user. Here is a BASIC program that gets the users name:

10 PRINT "What is your name? "
20 LINE INPUT A$
30 PRINT "Hello "+A$
40 END

This one asks the user for their name, waits for the ENTER key to be pressed, then greets them by name. The screen output is:


Did you notice the difference in the last line of this screen shot compared to the last line in the one before? In this one the C:\> is not there. The last line is "OK" instead. That is because the last line of code in this program is "END" instead of "SYSTEM". The program ended with the BASIC interpreter still running. That allows a programmer to test a program from the command line and then make changes to it without having to restart the interpreter.

BASIC runs each line in numeric order. But, numbers can be skipped and that leaves some space in case a programmer finds that something needs to be added later. The short programs above use only line numbers that are multiples of 10. This is a common practice. Line numbers higher than the number of the line that contains an "END" or "SYSTEM" are also allowed. Often, subroutines exist in a program and the line numbers are well above the end of the normal program. This makes understanding the program much easier.

GOTO and GOSUB give BASIC a way to respond to things like user input. Using those statements, a programmer can do things like branching to different operations based on user input. Many of the programs that were very popular used the GOTO statement to make menu systems that made commands easier for users. To show how these statements work, I like to go back to the model airplane assembly instructions. In this case, the airplane is a fighter jet with four rockets:

20 Glue top half to bottom half of right wing
21 Glue top half to bottom half of left wing
22 Glue right wing to fuselage
23 Glue left wing to fuselage
24 Go to subassembly step 2000 (This is a GOSUB instruction)
25 Glue assembled rockets to wings

2000 Number Of Complete Rockets = 0 (No rockets have been assembled yet)
2001 Glue one rocket top to one rocket bottom
2002 Number Of Complete Rockets = Number Of Complete Rockets + 1
2003 If Number Of Complete Rockets < 4 then repeat from step 2001 (GOTO)
2004 Return to one step after the step that called this subassembly (RETURN)

If you would like more information on the early BASICs, the BASIC page at the Open Directory Project has many good links.

So what changed that gave BASIC more power. Around 1985 new BASICs from Microsoft (QuickBASIC) and Borland (Turbo BASIC) dropped the need to use line numbers. Labels were used to define subroutines and branch entry points. It also became easier to interface to machine language or assembly language programs by the use of libraries. A new industry sprang up that supplied libraries of routines for things like advance graphics, communications, and complex calculations. BASIC programmers, many of whom started with the BASIC that came with their computers, were able to write more complex applications without having to learn a new language. They were also able to compile their programs to executable format so they did not have to release source code.

While these two BASICs were not free, like most BASICs were prior to this, they were very resonable when compared to other languages available at the time.

PCs had become the dominant platform by this point. When Microsoft released MS-DOS 5.0, GW-BASIC was replaced with QBasic. QBasic is a scaled down version of QuickBASIC 4.5 without the compiler or linker. QBasic was included with Microsoft operating systems, at least through Windows 98. Since it came with the operating system, many new programmers started with QBasic. Even today, there are many web sites that provide information and support for QBasic programmers.

Part 3 will show some of the features of the QuickBASIC and QBasic languages. Then it will introduce the next major shift for BASIC, Visual Basic.

BASIC, The Language of Simplicity, Power, and Change Part 1

Many things affected the evolution of computers as they went from the massive systems, that occupied entire buildings and required very large cooling systems, to the systems that now fit in the palm of our hands. Programming languages that made it simpler to create applications played a big role in that evolution.

BASIC (Beginners All-purpose Symbolic Instruction Code) is, in my opinion, the language that fueled the explosive growth of computer usage by medium and small businesses, as well as use by individuals.

Most early small computers, such as the Apple II, Commodore PET, TRS-80 and IBM PC, included a BASIC language. At the time, software available for these systems was limited, modems were slow and expensive, and most data storage was done with audio tape drives. Most, if not all, Mini and Micro computers, as well as some calculators, included a BASIC programing language as part of the package until very recently. History has shown that when something is available, we humans are driven to find ways to make use of it. BASIC is a good example of this. Curiosity, need, desire, and a thirst for knowledge, all played a part in the rapid growth in the number of people using BASIC to tell their computers to do something.

People, often seeking uses for these computers to justify having them, started writing their own programs, using the included BASIC, to address the needs of their business or for their own entertainment. Given the limited hardware resources available on these early systems, some of these programs were remarkable. Games with incredible graphics, business applications that performed very complex calculations, and typewriter replacements that allowed corrections and changes to be made prior to putting anything on paper, were some of the programs being written in BASIC.

Magazines and books targeting these new small computers flourished. These publications started printing basic programs that readers could type in and run on their systems. Some of these readers came to realize that BASIC programing was not hard. They began using pieces of code and adding to it to satisfy their own needs. A new generation of programmers was born.

Computer hardware advanced rapidly, driven in large part by the demand created by all the applications which had become available. Faster processers , more memory, disk drives, and better graphic capabilities allowed programs to become larger and more complex. Programing languages evolved along with the rest of the industry. While most commercial software was being written in more complex languages, such as Assembly or C++, there were still a lot of programmers working with BASIC.

The next article in this series will explore the changes to BASIC that allowed programmers to continue using it with the new hardware. Without having to give up the skills they developed using the language that came with their computers, these changes allowed for more complex programs that took advantage of the new hardware.

No comments: