Small Basic Small Basic Books > Beginning Microsoft Small Basic > 1. Introducing Small Basic

Preview

You are about to start a new journey. Writing programs that ask a computer to do certain tasks is fun and rewarding. Like any journey, you need to prepare before starting. In this first class, we do that preparation. You will learn why you might want to learn Small Basic. You will see the historical lineage of Small Basic. You will download and install the Small Basic development software that will help you create Small Basic programs. Once the preparation is done, you will run your first Small Basic application to check that you have prepared properly. Let’s get started.

Why Learn Small Basic?

We could very well just ask the question – Why Learn a Programming Language? A programming language is used to provide instructions to a computer to do specific tasks. There are several reasons for doing this. First, if you know how to program, you will have a better understanding of just how computers work. Second, writing programs is good exercise for your thinking skills – you must be a very logical thinker to write computer programs. You must also be something of a perfectionist – computers are not that smart and require exact, perfect instructions to do their jobs. Third, computer programmers are in demand and you can make a good living. And, last, writing computer programs is fun. It’s rewarding to see your ideas for a certain computer program come to life on the computer screen.

This chapter is adapted from the book BEGINNING Microsoft Small Basic by Philip Conrod and Lou Tylee.

To purchase this book in its entirety, please see the Computer Science For Kids web site.


So, why learn Small Basic? One big reason is that it’s free from Microsoft. Another reason for learning Small Basic is that it is one of the easiest languages to learn. Small Basic is a simple language. There are many built-in elements that make your work simpler and the language itself is very simple – only 15 reserved keywords. But, just because it is a simple language doesn’t mean it lacks capabilities. You will see throughout these notes that you can build some fairly complex programs.

Because of its simplicity, you can learn to write Small Basic programs very quickly. But, just because you can write your first program quickly doesn’t mean you’ll learn everything there is to know about Small Basic. This course just introduces Small Basic. There’s still a lot to learn – there’s always a lot to learn. So, consider this course as a first step in a journey to becoming a proficient computer programmer.

And, once you’ve mastered Small Basic, you can graduate to its more capable big brother VisualBasic, another Microsoft product used to develop GUI (graphical user interface) based applications. These are applications with menus, toolbars, buttons, scroll bars, and other controls which depend on the computer mouse for input. Examples of GUI applications you may have used are word processors, spreadsheet programs and computer games.

A Brief History of Small Basic

We’re almost ready to get started. But, first I thought it would be interesting for you to see just where the SmallBasic language fits in the history of some other computer languages and, in particular, with Microsoft products.

Most programming in the early days of programming was done in such cryptic languages by engineers and mathematicians. Two professors at Dartmouth College wanted to explain programming to “normal” people and developed the BASIC (Beginner’s All-Purpose Symbolic Code) language to help in that endeavor. BASIC was meant to be a simple language with just a few keywords to allow a little math and a little printing.

In the later 1960’s, timeshare computing, where a user could sit at a terminal and interact with the computer, became popular. The primary language used in these interactive sessions was BASIC. The Dartmouth BASIC was not sufficient for the many applications being developed, so many extensions and improvements were made in the BASIC language. Many of the first computer games were written on timeshare terminals using BASIC. The first complete game I wrote was on an HP-1000 Timeshare Basic system using a TTY-33 Terminal. Here is one such terminal:

HP-1000 Timeshare Basic system

These terminals allowed direct interaction with a mini or mainframe computer. Your computer output was on paper and programs could be saved on a punched paper tape.

In the summer of 1969, Bill Gates and Paul Allen began writing BASIC programs at Lakeside High School in Seattle using this same kind of teletype terminal. Bill continued programming and started little business ventures until January 1975 when this magazine appeared on the stands:

magazine

On the cover is an Altair 8800 computer. It must have been really expensive – note the ‘Save Over $1000’ line. About all the computer could do was flash some lights according to a program written by the user. But, it was the first home computer. Bill Gates and Paul Allen saw the potential. They developed a BASIC language for the Altair computer and marketed it through their new company – Microsoft. Yes, the first product sold by Microsoft was the BASIC computer language. It sold for $350 and was distributed on a cassette tape.

Then, in the late 1970’s and early 1980’s, it seems there were computers everywhere with names like Radio Shack TRS-80, Commodore 64, Texas Instruments 99/4A, Atari 400, Coleco Adam, Timex Sinclair and the IBM PC-Jr. Stores like Sears, JC Penneys and even K Mart sold computers. One thing all these machines had in common was that they were all programmed in some version of Microsoft’s BASIC. Each computer had its own fans and its own magazines. Computer users would wait each month for the next issue of a magazine with BASIC programs you could type into your computer and try at home. My computer of choice at that time was the TRS-80 Color Computer:

TRS-80 Color Computer

Like Microsoft’s first product, our BIBLEBYTES programs were distributed on audio cassette tapes.

This was a fun and exciting time for the beginning programmer, but the fun times ended with the introduction of the IBM-PC in the early 1980’s. Bigger and faster computers brought forth bigger languages and more complicated development environments. These new languages were expensive to purchase and difficult for the beginning programmer to grasp. Which brings us to SmallBasic, which I would call a close relative of the early, original BASIC language. Small Basic was developed by Vijaye Raji, a developer at Microsoft, in 2008 in response to an article written in September 2006 by David Brin called, “Why Johnny can’t code”. It would be best to let Vijaye tell the story of how Small Basic was born. The following Small Basic History was copied from Vijaye’s Blog dated October 23, 2008 entitled “Hello World”.

“It all happened in August of 2007 when someone sent me a pointer to the article Why Johnny Can't Code and it got me thinking. After all, when I was a kid, I started programming in ZX Spectrum with a built in Sinclair BASIC interpreter and did so until I ran into Turbo BASIC. To me that transformation was groundbreaking and was the single most important reason why I chose to write software for a living, for the rest of my life.

An informal poll along the corridors in Microsoft revealed that most developers within Microsoft had started programming in some variant of BASIC. It had all the good characteristics of a good beginner programming language - simplicity, minimal ceremony, instant gratification and ubiquity. It helped them "get" programming and assisted them with understanding the need for more advanced concepts.

When I asked them how they're going to teach programming to their children, they were stumped. Almost everyone wanted to, they just didn't know how. Some said KPL, Python and Ruby. Some said Alice and Scratch. But they all felt that none of these have the charm of BASIC. Of course there were some that took the Dijkstra's stand, but they were few.

Of the numerous programming languages, BASIC, from its inception in the 1960s has undergone some major transformations. Even among Microsoft's BASIC offerings, the language and the environment (VS) has been repeatedly updated to include more powerful features with every release. On the one hand this makes the language and the environment very powerful and capable, but on the other hand, it makes it daunting for a beginner.

That got me thinking as to why isn't there a "Small" variant of BASIC that brings the simplicity of the original language to the modern day. And after a year, here we are, announcing Small Basic. Small Basic is a project that will help make programming easy and approachable for beginners. Now, that's a pretty big claim - let's see how Small Basic does it.

Make programming approachable

Small Basic starts with a really simple programming language that gathers inspiration from the original BASIC language. It has no more than 15 keywords and is strictly imperative. There are no classes, scopes, generics, lambdas, etc. - just pure imperative code. The language is typeless and all variables are dynamic and global all the time. The code gets compiled to IL and runs on the .Net Framework.

It comes with a set of libraries that can be accessed from within a Small Basic program. Since the language itself is .Net based, new libraries can be created or the existing libraries modified using any .Net programming language.

Next, it combines the features of the language and the libraries into a very simple and friendly programming environment. This environment gives beginners, access to professional features like Intellisense(TM) and Instant context sensitive help. It makes writing programs and executing them a breeze.

The development of Small Basic was a several year by Vijaye Raj to rekindle the exciting days when just about anyone could sit down at a computer and write a simple program using the BASIC language. Those of you who wrote programs on those old “toy” computers will recognize the simplicity of the Small Basic language and the ease of its use. And, you will also notice Small Basic is a great environment for writing and testing code, something missing in the early 1980’s. Let’s get started now. For those of you new to programming, I hope you can feel the excitement we old timers once had. For the old timers, I hope you rekindle your programming skills with this new product.”

Let’s Get Started

Learning how to use SmallBasic to write a computer program (like learning anything new) involves many steps, many new terms, and many new skills. We will take it slow, describing each step, term, and skill in detail. Before starting, we assume you know how to do a few things:

  • You should know how to start your computer and use the mouse.
  • You should have some knowledge on working with your particular operating system (Windows 7, Me, 2000, XP, NT, Vista). In these notes, we use Windows Vista. If you are using another operating system, your screens may appear different than those shown here.
  • You should know how to resize and move windows around on the screen.
  • You should know how to run an application on your computer by using the StartMenu or some other means.
  • You should know how to fill in information in dialog boxes that may pop up on the screen.
  • You should know about folders and files and how to create and find them on your computer.
  • You should know what file extensions are and how to identify them. For example, in a file named Example.ext, the three letters ext are called the extension.
  • You should know how to click on links to read documents and move from page to page in such documents. You do this all the time when you use the Internet.
  • You should know how to access the Internet and download files.

You have probably used all of these skills if you’ve ever used a word processor, spreadsheet, or any other software on your computer. If you think you lack any of these skills, ask someone for help. They should be able to show you how to do them in just a few minutes. Actually, any time you feel stuck while trying to learn this material, never be afraid to ask someone for help. We were all beginners at one time and people really like helping you learn.

Let’s get going. And, as we said, we’re going to take it slow. In this first class, we will learn how to install Small Basic and its documentation on your computer, how to load a Small Basic program, how to run the program, and how to stop the program. It will be a good introduction to the many new things we will learn in the classes to come.

Note: At this writing, Microsoft was offering Version 0.8 of Small Basic. That is the version used in these notes.

Downloading and Installing Small Basic

To write and run programs using Small Basic, you need the Small Basic program. This is a free product that you can download from the Internet. This simply means we will copy a file onto our computer to allow installation of Small Basic.

Start up your web browser (Internet Explorer, Netscape or other). Small Basic is hosted at Kid’s Corner in Microsoft’s Beginner Development Learning Center:

http://www.smallbasic.com/

This web site has lots of useful programming information. As you become more proficient in your programming skills, you will go to this site often for answers to programming questions, interaction with other programmers, and lots of sample programs. Though it’s hosted at a ‘kid’ site, Small Basic is appropriate for all ages.

On the Small Basic web page, you should see a button that allows to download Small Basic:

DownLoad Small Basic

Click the download button. This window will appear:

Security Warning

Click Run and the download of the installer begins:

download of the installer begins

When complete, you should see:

Security_Warning

Again, click Run to see the Setup Wizard:

Setup_Wizard

Click Next to start the installation process. Accept the licensing agreement. Then, for each screen afterwards, accept the default choice by clicking Next. When done you should see a screen announcing a successful installation.

Installation_Complete

Starting Small Basic

We’ll learn how to start Small Basic, how to load a Small Basic program, and how to run a program. This will give us some assurance we have everything installed correctly. This will let us begin our study of the Small Basic programming language.

Once installed, to start Small Basic:

  • Click on the Start button on the Windows task bar
  • Select Programs, then Small Basic
  • Click on Microsoft Small Basic

(Some of the headings given here may differ slightly on your computer, but you should have no trouble finding the correct ones.) The Small Basic program should start. Several windows will appear on the screen.

After installation and trying to start, you may see an error message that announces Small Basic cannot be started. If this occurs, try downloading and installing .NET Framework version 3.5.1 of the Microsoft .NET framework at:

NOTES:

  1. Check you have .NET Framework 3.5.1 installed AND TURNED ON before installing Small Basic.
  2. It's okay to have later versions of .NET installed BUT you must also have .NET Framework 3.5.1 installed and turned on.
You can download the latest version of .NET Framework here:

The framework contains some files that Small Basic needs to operate and such files may not be on your computer.

Upon starting, my screen shows:

Small_Basic_Development_Environment

This window displays the SmallBasicDevelopment Environment. We will learn a lot more about this in Class 2. Right now, we’re just going to use it to test our Small Basic installation and see if we can get a program up and running. There are many windows on the screen. At the top of the window is the TitleBar. The title bar gives us information about what program we’re using and what Small Basic program we are working with. Below the title bar is a Toolbar. Here, little buttons with pictures allow us to control Small Basic. Almost all Windows applications (spreadsheets, word processors, games) have toolbars that help us do different tasks. This is the purpose of the Small Basic toolbar. It will help us do most of our tasks. In the middle of the screen is the Editor. This is where we will write our Small Basic programs. To the right is a Help area. Small Basic has great help features when writing programs. This area will display hints and tips while we write code.

Opening a Small Basic Program

What we want to do right now is open a program. Included with these notes are many Small Basic programs you can open and use. Let’s open one now. Make sure Small Basic is running. We will open a program using the toolbar. Follow these steps:

  • Click the Open Program button:

    Open_Program_Button

    An OpenProgram window will appear:

    Open_Program_Button

  • Find the folder named BeginSB (stands for Beginning Small Basic). This is the folder that holds the notes and programs for this course. Open that folder.
  • Find and open the folder named BSB Code. This folder holds all the programs for the course

Remember how you got to this folder. Throughout the course, you will go to this folder to open programs you will need. Open the program folder named Welcome. Note there is one file in Welcome named Welcome. Select that file and click Open.

NOTE: The Welcome folder and Welcome file come as a download when you purchase this book. If you have not purchased the book, then please ignore this part. 

This should appear in the Small Basic editor:

Small_Basic_editor

You now finally see your first Small Basic program: We’ll learn what these few lines of code do in the next class. Right now, we just want to see if we can get this program running.

Running a Small Basic Program

After developing a Small Basic program, you want to start or run the program. This gets the program started and allows the computer do its assigned tasks. We can also run a program also using the toolbar. Look for a button that looks like the Play button on a VCR, CD player, or cassette tape player:

Run_Program_Button

  • Click this button to run the Welcome program (the program we opened previously).

NOTE: The Welcome folder and Welcome file come as a download when you purchase this book. If you have not purchased the book, then please ignore this part. 
 
You can also run a program by pressing the <F5> function key.

A window should open and you should see the following Welcome message:

Welcome_Program

If you’ve gotten this far, everything has been installed correctly. If you don’t see the Welcome message, something has not been installed correctly. You should probably go back and review all the steps involved with installing Small Basic and Small Basic and make sure all steps were followed properly.

To stop this program, press any key or click the boxed X in the upper right corner of the window.

Stopping Small Basic

It’s been a lot of work just to get to this point. We finally have our first Small Basic program running and now we’re just going to stop it and move on. We’ll dig into many more details in Class 2.

When you are done working with a Small Basic program, you want to leave the Small Basic environment. To stop Small Basic, click on the close button in the upper right hand corner of the main window. It’s the button that looks like an X. Stop Small Basic now. Small Basic will close all open windows and you will be returned to the Windows desktop. You may be asked if you would like to save the program modifications (in case any were made):

Microsoft Small Basic

If you are asked such a question, answer No so the Welcome program remains unchanged.

Summary

We covered a lot of new material here. As we said earlier, you learned a lot of new words and concepts. Don’t worry if you don’t remember everything we talked about here. You will see the material many times again. It’s important that you just have some concept of what goes into a Small Basic program. You also know how to start and stop the Small Basic environment.

In summary, we installed the Small Basic environment. Using Small Basic, we learned how to open a Small Basic program. We learned how to run a program. In the next class, you will learn (in detail) what each of these steps really means. And, you will begin to acquire the skills that allow you to start building your own Small Basic program. Using the Welcome program as an example, you will learn about important concepts related to a Small Basic program. Then, in Class 3, you will actually build your first program!

NOTE: The Welcome folder and Welcome file come as a download when you purchase this book. If you have not purchased the book, then please ignore this part. 

Next Chapter > >

Excerpt © Copyright 2010-2013 By Kidware Software LLC All Rights Reserved. Computer Science For Kids, the Computer Science For Kids logo, and related trade dress are trademarks or registered trademarks of Kidware Software LLC. Philip Conrod & Lou Tylee have co-authored dozens of books and tutorials for beginning Microsoft Basic, Small Basic, Visual Basic, and Visual C# developers of all ages for over 25 years.