Small Basic – A Fun way of Programming


 

Though normally now a days I mostly use C# (with few exception of VB.NET), I used to code in Visual Basic for a long period of time starting from VB4 to VB6. So I like Basic programming language and it’s syntax. With the introduction of .NET 4, one of the core theme for both C# and VB.NET programming language is to bring the languages closer to each other and narrow down the gap between these two languages. So both C# and VB.NET would start support features supported by their counter parts like automatically implemented properties.

Though when you are coding in .NET whether you’re coding in C# or VB you’re mostly using lot of BCL classes, syntaxes do matter to a programmer (in my humble opinion).

Microsoft Dev Labs had earlier released a fun programming language called Small Basic – as you can guess from the name it’s based on Basic and it’s a very small subset of Basic programming language. Since it’s intended audience is hobbyists and students, the creators of Small Basic have carefully avoided making the language bigger – so the language is very simple (it has not more than 20 keywords).

Small Basic (which could be downloaded and installed from Dev Labs site) comes with a compiler and an IDE for coding and running the program. Though it’s still does not support debugging (I am currently using version 0.2), probably debussing would be available in next version. Small Basic comes up with a nice yet simple WPF based IDE – 

 

As you type code, Visual Studio like Intellisense and contextual help about the API (class/method/variable) you use would be displayed in help window on the right. Small Basic comes with a small library and keywords.

Small Basic is very simple and easy to use – it does not have any notion of data type or type system or strong type system. Variables could be defined as variable = val (e.g. x = 1, y = 2). You also don’t have to instantiate classes – all the classes behave as static classes with static methods.

It supports Basic like keywords – If Then, Else, End If, For, End For, While etc

To show output in Console TextWindow.Write or TextWindow.WriteLine method is used

To show graphics window GraphicsWindow.Show method is used.

There are some interesting classes like Turtle, Flickr, Dictionary – I would not tell how they are used – rather let you figure that out. The install also comes with a PDF help file for quick reference and learning.

Excellent – Great Work by SB team.

Note: I could not restrain myself from showing what is Dictionary and how to use it. If you are coming from C# or other complex programming languages you would be tempted to think of Dictionary as a data structure (that stores key, value pair), but it’s not so. It’s actually what it literally means – Dictionary class helps to get the meaning of any word. Now you get it – yes it’s that simple. Simplicity is the hidden power of Small Basic. Here’s a program on how to use Dictionary class. Happy coding – 

TextWindow.WriteLine("Enter a word")
word = TextWindow.Read
defintion = Dictionary.GetDefinition(word)
TextWindow.WriteLine(defintion)

Advertisements

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