Introducing smallbasic

I learnt my programming originally using Sinclair Basic, so I was interested to see how the language has developed in the last 30 years or so.

Small Basic is produced by Microsoft as an introduction to programming.  It is designed to develop smoothly towards use of VB.NET, and programs produced in Small Basic can be easily converted into VB.NET and built on further.

small basic intellisense code completer

intellisense code completer

The feature that attracts me most towards Small Basic is the Intellisense, a built in code assistant.  As you start typing, it will help you see what the options are, and will even correct capitals and put in the indentation.

The first program, of course, is the standard hello world program.  This is achieved in one simple line in Small Basic: TextWindow.WriteLine(“Hello World”)

small basic window displaying hello world

A text window with the text displayed

This produces a window with the required line.

Using the pdf from the Small Basic website, I quickly progressed to my first proper program, a Fahrenheit to Celsius converter:

TextWindow.Write("Enter temperature in Fahrenheit: ")
fahr=TextWindow.ReadNumber()
celsius=5*(fahr-32)/9
TextWindow.WriteLine("Temperature in Celsius is " + celsius)

Interestingly, this produced a floating point answer rather than the integer answer you would get in something like Python, which will reply with the same data type as it took in.

Some theory here: computers can handle different types of data.  Numbers are usually stored as integers, or whole numbers, and any maths involving integers will have an integer answer.  So in Python, as in many other languages, as this code has all integers, or whole numbers, the answer would be a whole number too.  According to Python, 3/2 = 1 (it will simply discard the remainder).  To obtain the partial part of the answer, you would have to cast (change) one of the numbers to float type rather than integer, for example using print float(3)/2 or put in one of the numbers as a float, e.g. 3/2.0.  Float is another commonly used data type, referring to the decimal point as floating, i.e. its position in the number will change the value.

All that is fairly theoretical, but it does make the point that in Small Basic there is no need to worry about casting an integer to a float if you need an answer that’s not a whole number, possibly a welcome simplicity.

The next structures introduced in the Small Basic pdf are branching and looping structures – If, While, etc.  I was disappointed to note that the Goto: option still exists, as I thought that was supposed to be seen as a great weakness of BASIC programs, offering the chance to jump to a completely different place in the code.  The gosub: option has disappeared, but there is still the facility to write subroutines which are demarked by Sub and EndSub, and are called simply by calling the subroutine by name, very like defining functions in other languages, at least at first glance.

small basic graphic code

Small Basic graphic code

At this point I was feeling optimistic about Small Basic, but then the pdf seemed to divert into drawing graphics and then stop, leaving me searching around for further materials to learn from.  While the fractals and using Small Basic with a Turtle (emulating Logo) looked vaguely interesting, it didn’t really offer much opportunity to make programs that did very much except draw shapes.

small basic graphic shapes

Drawing and filling shapes

I now know how to draw and fill simple shapes (rectangle, ellipse, lines), and how to use looping to produce different shapes and patterns, but not much about how to use graphics to actually do anything interactive.

I could find no more learning materials on that site, but a small poke around found the Microsoft support site, which contains a link to a whole load of structured lessons, so that what I’ll be looking at next time I pick up Small Basic.  In the meantime, it looks promising as a step between dragging and dropping code blocks and typing out proper code: it feels like typing proper code, but the intellisense support and clear colour coding helps greatly in knowing what options are available and forming them correctly.  I would just point out very clearly to students that it is correcting missing capitals, and that when they move to a proper grown-up language capitals really will matter!

Small Basic is very limited, but the chance of growing into its big brother VB.NET means that its simplicity is not likely to prove a major disadvantage to anyone who is really making progress with coding and needs more, while it will protect and nurse the beginner through their first steps in typing code.  There is also the opportunity for learners to discuss their problems via the forum and publish their code online, so that others can download it and play with it too.

Advertisements

About emmyleigh
Writer/editor/proofreader who loves technology

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: