Over time I’ve been trying to engage my young children with computer programming, so far we’ve looked at Squeak, Small Basic and more recently F#.
They really enjoyed playing with the Turtle in Small Basic, an idea that comes from Logo, a programming language I myself played with as a child.
For i = 1 to 4
Small Basic is a variant of Basic with just 14 keywords. It also ships with a library of static methods for fun stuff like graphics and sound, removing the need to understand the vagaries of threading before getting started.
The SmallBasicLibrary.dll can be also be referenced from C# and F#. However, rather than using value types for passing parameters, it defines it’s own union type called Primitive and associated implicit conversions, a little like the Variant type used in Visual Basic.
I’ve been trying a few different ways of bringing first class Turtle graphics to F#. A few months back I created a simple internal DSL in F# that looks quite a lot like Logo, and can be run in the browser:
repeat 10 [rt 36; repeat 5 [fd 54; rt 72]]
Just hit the TryFSharp.org button on this Turtle F# Snippet, or download the Silverlight code.
More recently based on some of the ideas in the Small Basic Library, I’ve created a small library for C# and F# called Small Sharp, which is hosted on CodePlex.
static void Main(string args)
Turtle.Right(i * 7);
Small Sharp provides a fun environment to learn about programming, while giving you the full power of either the C# or F# programming languages. It also includes some LINQ and Ruby like extension methods, for example the sample above runs 1000 times.
Instructions for getting started with C# and F#