Scott Hanselman

The Weekly Source Code 49 - SmallBasic is Fun, Simple, Powerful Programming for Kids and Adults

February 10, 2010 Comment on this post [20] Posted in Learning .NET | MSDN | Programming | Silverlight | Source Code
Sponsored By

While the boys are only 2 and 4, I'm always keeping an eye out on new ways to teach them programming. Certainly I hope they'll be more well-rounded and I and spend more time outside, but a even a basic background in programming and logic, I think, produces a more empowered individual.

Created by Vijaye Raji, Small Basic is a simple (only 15 keywords) but powerful environment for getting started programming. Great for kids and non-technical spouses, but powerful enough even for the professional game developer. In fact, Small Basic is probably the fastest and simplest way I've seen yet to produce and publish Silverlight-based games. Read on to see why.

Small Basic is part of MSDN DevLabs and just released version 0.8. It's the eighth installment, but I suspect they are too modest to call it 8.0. ;) It's even internationalized in English, Chinese, French, German, Italian, Japanese, Jorean, Russian, Spanish, Brazilian Portuguese and Turkish...so if you know a computer teacher, you might tell them about this!

Take a look at Small Basic Tetris, for example. You can run it in the browser with Silverlight, right here. The full Small Basic source code for the app is listed right on the page. There's a bunch of great sample Small Basic apps here also.

It has a nice friendly IDE (Integrated Development Environment) with a clever take on Intellisense as seen below. The IDE goes out of its way to give you as much information and context as possible not only with the intellisense "arc" but also context-sensitive help in the right doc.

The Small Basic IDE

Even more clever, I think, is the "Graduate" button that will convert your Small Basic program into Visual Basic for use directly in Visual Studio.

Here's what a Small Basic text mode application would look like:

number = 100
While (number > 1)
TextWindow.WriteLine(number)
number = number / 2
EndWhile

Here's a SmallBasic Windows app:

GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.Width = 200
GraphicsWindow.Height = 160
GraphicsWindow.PenColor = "Blue"
For i = 1 To 10
GraphicsWindow.PenWidth = i
GraphicsWindow.DrawLine(20, i * 15, 180, i * 15)
EndFor

For those of us old enough to remember learning to program with LOGO and its ubiquitous Turtle, Small Basic includes a Turtle object built in! Remember this?

sides = 50
length = 400 / sides
angle = 360 / sides
Turtle.Speed = 9
For j = 1 To 20
For i = 1 To sides
Turtle.Move(length)
Turtle.Turn(angle)
EndFor
Turtle.Turn(18)
EndFor

Which gives us this image. See the turtle inside?

The LOGO Turtle drawing Circles in SmallBasic

The most amazing part from a learning perspective is the ability to publish your game directly to the Small Basic website and play it or give it to your friends. I hit Publish for this Turtle app and Small Basic - in one click - gave me this link: http://smallbasic.com/program/?WKN265. Now I can send my friends or students to that link.  They can play the game LIVE, see the source listing right there, or even embed it on their own website with included HTML.

I'm really impressed with the amount of though that was put into this app and how easy it was. I hope other folks at Microsoft check it out and appreciate the simplicity.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
February 10, 2010 1:52
This is really nice. Simple syntax, user-friendly interface, and the ability to get instant gratification makes this a really powerful and promising tool to teach/learn programming.

Plus, I really like the ability to share your code online with your friends/classmates.

This is complete win, I love to see stuff like this.

Plus, that intelli-sense is killer, where was that when I was in Junior High?
February 10, 2010 2:20
Awesome, I wonder if my wife will try it out hehe
February 10, 2010 2:48
It's so, so, tempting to ask if VB has a "Graduate" button that converts the project into C#, but I'm not going to say that. Nope, not going to start a language war.
February 10, 2010 4:02
I've used this with my 10 year old and it is neat - I don't want to take anything about the implementation with this comment, but... :-)

Are we sure that this traditional imperative non-functional basic style is the right way to start people of programming? I wonder how many new people we are making that will struggle with FP, LINQ or even SQL.

We might be too old and wizened to tell, but we might be teaching the new 'electric' generation how to program using 'steam' because that's how we started, i.e. the paradigms that we are embedding in an early eduction can tend to stick and the future of programming ain't looking imperative folks...

Anyway, just an comment for discussion - SmallBasic is a lot of fun, and I didn't really find anything else as good.
February 10, 2010 4:49
That's a very interesting question David. Have you tried teaching your 10 year old Squeak?
February 10, 2010 5:18
I'm from Jordan they teach us programming using at 10th grade using Arabized version of Logo and i think it's nice idea to have this with small basic so kids can learn how to program
February 10, 2010 10:53
I think I would confuse my daughters with the GraphicsWindow and TextWindow stuff. Scratch (http://scratch.mit.edu/) on the other hand is graphical and intuitive. And also... I don't like VB.
February 10, 2010 11:21
The MIT has a nice project called Scratch that allows kids to develop a program visually and interactively, I think it's easier and more exiting than writing code.

Nordine Ben Bachir
February 10, 2010 13:04
I'm sure you will like to create web applications without writing code but using only mouse and visual scripting.

See a short video presentation here: http://www.youtube.com/watch?v=Krb7OCmTJ-w
or this one http://www.youtube.com/watch?v=F7J9dnIIAVQ

It's perfect for creating business software, but for sure you can find many other uses to it...
February 10, 2010 17:35
Thanks for pointing out this language; I might try it in the future. I agree that learning the basics of logic does make for a more empowered individual, so I plan on teaching my HFO's (hypothetical future offspring) the basics of logic and computer programming.

Scratch is _great_ for teaching the very basics.

I haven't found good instructions on Squeak or eToys yet.
February 10, 2010 21:18
I gave a talk at the Twin Cities Languages User Group on Small Basic last year. Many people were interested in it for their kids. On top of that I discovered some of my youth again when using it. It felt like I was going back to 5th grade on an Apple IIe. I really hope Vijaye's dream of having it bundled with Windows comes true. Not having a programming environment built into Windows impedes upon newcomers to programming. Many of us first were exposed to programming because the OS we had on our first computers had some environment to program in. Apple IIe BASIC, QBASIC..

It is definitely a quick to learn and fund language/platform to use. Extending it is extremely simple for any .NET developer. There have been some great extensions released for it already.
February 10, 2010 23:00
I and some friends have just set up an after school 'code 4 kids' club for 12-16s at our local High School here in the UK. Believe it or not but the actual curriculum doesn't touch code until the guys reach 16...madness!

Anyway, we are working with MS VS Express and coding4fun (http://blogs.msdn.com/coding4fun/) and are definitely going to take a good look at SmallBasic as another resource we can 'tap' into.

If anyone has any further info or insights on 'code4kids' we're all ears...thanks!
February 10, 2010 23:20
broken link: bunch of great sample Small Basic apps here also
Don
February 11, 2010 6:44
Not seen the LOGO turtle for years that was a great little intro to programming for the time. I suspect some of my colleagues would prefer this to the usual business and data entry apps I give them :-)
February 11, 2010 12:22
I've almost forgotten about LOGO - awesome programming Language. I wrote a whole bunch of apps when I was 13 or so but later on I got annoyed because there was a pretty low memory limit in the version I was using. Still, a very nice starting point for new programmers.
February 13, 2010 2:41
Smallbasic is nice. I have been using it to teach my son and daughter. I also picked up the Hello World book. Going to start moving through that one also.
February 15, 2010 1:28
So this is VB's final resting ground?
February 17, 2010 18:38
Thats cool. The below line in the For loop giving wonderful random colors. Tried it in both inner and outer for loops.

GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()


Thanks,
Kamlesh
April 01, 2010 6:23
@Nordine

Writing lines of code may not get kids very excited, but it teaches programming concepts that will help them for years to come. I'd rather not go through teaching a kid about computers and then showing them a proper IDE with them thinking "WTF? What am I supposed to drag-and-drop?" and getting bored with it. Give someone a code window, he will know to use code windows. Give them a visual enviroment and THEN a code window and you will get someone who doesn't want to program anymore.
July 14, 2010 3:02
Thanks for posting all of this, and thanks for the source code. :-)

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.