Microsoft Small Basic

This article is about the Microsoft programming language. For the GPL programming language, see SmallBASIC.
Microsoft Small Basic
Paradigm Structured, imperative, object-oriented
Designed by Microsoft, Vijaye Raji
Developer Microsoft
First appeared October 23, 2008 (2008-10-23)[1][2]
Stable release v1.2 / October 1, 2015 (2015-10-01)[3]
Typing discipline Dynamic, weak
Platform .NET Framework 4.5[3]
OS Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008 R2[4]
License Freeware
Filename extensions .sb
Website www.smallbasic.com
Influenced by
Visual Basic .NET, QBasic

Microsoft Small Basic is a programming language and associated IDE. It is Microsoft's simplified variant of the BASIC programming language, intended as an easy programming language for beginners. The associated IDE provides a simplified programming environment with functionality such as syntax highlighting, intelligent code completion, and in-editor documentation access.[5] The language has only 14 keywords.[6]

History

Version Release date
Old version, no longer supported: v0.1 October 23, 2008[1]
Old version, no longer supported: v0.2 December 17, 2008[7]
Old version, no longer supported: v0.3 February 10, 2009[8]
Old version, no longer supported: v0.4 April 14, 2009[9]
Old version, no longer supported: v0.5 June 16, 2009[10]
Old version, no longer supported: v0.6 August 19, 2009[11]
Old version, no longer supported: v0.7 October 23, 2009[2]
Old version, no longer supported: v0.8 February 4, 2010[12]
Old version, no longer supported: v0.9 June 11, 2010[13]
Old version, no longer supported: v0.91 November 17, 2010[14]
Old version, no longer supported: v0.95 February 8, 2011[15]
Older version, yet still supported: v1.0 July 12, 2011[16]
Old version, no longer supported: v1.1 March 27, 2015[17]
Current stable version: v1.2 October 1, 2015[3]
Legend:
Old version
Older version, still supported
Latest version
Latest preview version
Future release
Legend:
Old version
Older version, still supported
Latest version
Latest preview version
Future release

Microsoft announced Small Basic in October 2008,[1] and released the first stable version for distribution on July 12, 2011[16] on a Microsoft Developer Network (MSDN) website with a teaching curriculum[18] and an introductory guide.[19] Between announcement and stable release, a number of Community Technology Preview (CTP) releases were made.

On March 27, 2015, Microsoft released Small Basic version 1.1,[17] which fixed a bug and upgraded the targeted .NET Framework version from version 3.5 to version 4.5.

Microsoft released Small Basic version 1.2 on October 1, 2015.[3] Version 1.2 was the first update after a four-year hiatus to introduce new features to Small Basic. The update added classes for working with Microsoft's Kinect motion sensors,[3] increased the number of languages supported by the included Dictionary object, and fixed a number of bugs.[4]

Language

In Small Basic, one writes the illustrative "Hello, world!" program as follows:

TextWindow.WriteLine("Hello World!")

Microsoft Small Basic is Turing complete. It supports conditional branching, loop structures, and subroutines for event handling. Variables are weakly typed and dynamic with no scoping rules.

Conditional branching

The following example demonstrates conditional branching. It requests the current temperature in Fahrenheit and comments on the answer.

TextWindow.Write("Enter the temperature today (in F): ")
temp = TextWindow.ReadNumber()
If temp > 100 Then
  TextWindow.WriteLine("It is pretty hot.")
ElseIf temp > 70 Then
  TextWindow.WriteLine("It is pretty nice.")
ElseIf temp > 50 Then
  TextWindow.WriteLine("Don't forget your coat.")
Else
  TextWindow.WriteLine("Stay home.")
EndIf

Looping

This example demonstrates a loop. Starting from one and ending with ten, it multiplies each number by four and displays the result of multiplication.

TextWindow.WriteLine("Multiplication Tables")
For i = 1 To 10
  TextWindow.Write(i * 4)
EndFor

While loops are also supported, and the demonstrated For loop can be augmented through the use of the Step keyword. The Step keyword is used in setting the value by which the counter variable, i, is incremented each iteration.

Data types

Small Basic supports basic data types, like strings, integers and decimals, and will readily convert one type to another as required by the situation. In the example, both the Read and ReadNumber methods read a string from the command line, but ReadNumber rejects any non-numeric characters. This allows the string to be converted to a numeric type treated as a number rather than a string by the + operator.

TextWindow.WriteLine("Enter your name:")
name = TextWindow.Read()

TextWindow.Write("Enter your age: ")
age = TextWindow.ReadNumber()

TextWindow.WriteLine("Hello " + name + "!")
TextWindow.WriteLine("In 5 years you will be " + ( age + 5 ) + " years old!")

As Small Basic will readily convert between data types, numbers can be manipulated as strings and numeric strings as numbers. This is demonstrated through the second example.

TextWindow.WriteLine(Math.log("100")) 'Prints 2
TextWindow.WriteLine("100" + "3000") ' Prints 3100
TextWindow.WriteLine("Windows " + 8) ' Prints Windows 8
TextWindow.WriteLine(Text.GetLength(1023.42)) ' Prints 7 (length of decimal representation including decimal point)

In the second example, both strings are treated as numbers and added together, producing the output 3100. To concatenate the two values, producing the output 1003000, it is necessary to use the Text.Append(text1, text2) method.

Libraries

Standard library

The Small Basic standard library includes basic classes for mathematics, string handling, and input/output, as well as more exotic classes that are intended to make using the language more fun for learners. Examples of these include a Turtle graphics class, a class for retrieving photos from Flickr, and classes for interacting with Microsoft Kinect sensors.

To make the classes easier to use for learners, they have been simplified. This simplification is demonstrated through the code used to retrieve a random mountain-themed image from Flickr:

For i = 1 To 10
  pic = Flickr.GetRandomPicture("mountains")
  Desktop.SetWallPaper(pic)
  Program.Delay(10000)
EndFor

Turtle Graphics

Small Basic includes a "Turtle" graphics library that borrows from the Logo family of programming languages. For example, to draw a square using the turtle, the turtle is moved forward by a given number of pixels and rotated 90 degrees in a given direction. This action is then repeated four times to draw the four sides of the square.

For i = 1 to 4
  Turtle.Move(100) ' Forward 100 pixels
  Turtle.Turn(90) ' Turn 90 degrees right
EndFor

More complex drawings are possible by altering the turning angle of the turtle and the number of iterations of the loop. For example, one can draw a hexagon by setting the turn angle to 60 degrees and the number of iterations to six.

Third-party libraries

Small Basic allows the use of third-party libraries. These libraries must be written in a CLR-compatible language, and the compiled binaries must target a compatible .NET Framework version. The classes provided by the library are required to be static, flagged with a specific attribute, and must use a specific data type.

An example of a class to be used in Small Basic is provided below, written in C#.

[SmallBasicType]
public static class ExampleClass
{
    public static Primitive Add(Primitive A, Primitive B) => A + B;

    public static Primitive SomeProperty
    {
        get;
        set;
    }

    public static Primitive Pi => (Primitive)3.14159;
}

If available, the Small Basic development environment will display documentation for third-party libraries. The development environment accepts documentation in the form of an XML file, which can be automatically generated from source code comments by tools such as Microsoft Visual Studio and MonoDevelop.

See also

Related Microsoft technologies:

Related languages:

References

  1. 1 2 3 Raji, Vijaye (23 October 2008). "Hello World". Small Basic. MSDN Blogs. Microsoft. Retrieved 9 February 2014.
  2. 1 2 Raji, Vijaye (23 October 2009). "Happy Birthday Small Basic". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  3. 1 2 3 4 5 Scherotter, Michael (1 October 2015). "Small Basic 1.2 Released with Kinect Support and Bug Fixes". Small Basic. MSDN Blogs. Microsoft. Retrieved 2 October 2015.
  4. 1 2 "Download Microsoft Small Basic 1.2 from Official Microsoft Download Centre". Small Basic. Microsoft. 1 October 2015. Retrieved 2 October 2015.
  5. Price, Ed (22 October 2012). "The Unique Features of Small Basic". Small Basic. TechNet. Microsoft. Retrieved 22 April 2015.
  6. Price, Ed (8 October 2012). "What are the 14 Keywords of Small Basic?". Small Basic. MSDN Blogs. Microsoft. Retrieved 9 February 2014.
  7. Raji, Vijaye (17 December 2008). "Announcing Small Basic v0_2!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  8. Raji, Vijaye (10 February 2009). "Microsoft Small Basic v0.3 is here". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  9. Raji, Vijaye (14 April 2009). "v0.4 of Small Basic says "Bonjour"". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  10. Raji, Vijaye (16 June 2009). "The newest, leanest and the meanest is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  11. Raji, Vijaye (19 August 2009). "Now available: Small Basic v0.6". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  12. Raji, Vijaye (10 February 2010). "Small Basic v0.8". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  13. Raji, Vijaye (11 June 2010). "Small Basic V0.9 is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  14. Aldana, Sandra (17 November 2010). "Small Basic V0.91 is more international than ever!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  15. Aldana, Sandra (8 February 2011). "Small Basic v0.95 speaks another language!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  16. 1 2 Aldana, Sandra (12 July 2011). "Small Basic 1.0 is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  17. 1 2 Price, Ed (27 March 2015). "Small Basic 1.1 is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  18. Price, Ed (29 April 2014). "Small Basic Curriculum". TechNet. Microsoft. Retrieved 9 February 2014.
  19. Price, Ed; Takahashi, Nonki (25 February 2014). "Small Basic Getting Started Guide". TechNet. Microsoft. Retrieved 12 February 2015.

External links

This article is issued from Wikipedia - version of the Saturday, April 16, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.