Microsoft Small Basic#Language
{{Short description|Programming language dialect and development environment}}
{{Primary sources|date=April 2022}}{{About|the Microsoft programming language|the GPL programming language|SmallBASIC}}
{{Infobox programming language
| name = Microsoft Small Basic
| logo =
| screenshot = Small Basic.png
| caption = Small Basic running on Windows 7
| paradigm = Structured, imperative, object-oriented
| developer = Microsoft
| released = {{Start date and age|2008|10|23}}
| latest release version = v1.2
| latest release date = {{Start date and age|2015|10|1}}
| influenced by = Logo, QBasic, Visual Basic .NET
| File extensions = .sb, .smallbasic
| operating system = Small Basic Desktop: Windows XP (up to version 1.0), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008 R2{{cite web
| url=https://www.microsoft.com/en-us/download/details.aspx?id=46392
| title=Download Microsoft Small Basic 1.2 from Official Microsoft Download Centre
| work=Small Basic
| publisher=Microsoft
| date=1 October 2015
| access-date=2 October 2015
}}
Small Basic Online: web browser
| platform = .NET Framework 4.5
| license = MIT License{{Cite web|url=https://github.com/sb/smallbasic-editor/blob/master/LICENSE|title = SmallBasic| website=GitHub |date = 17 October 2021}}
| genre = Integrated development environment, educational software
| website = {{URL|https://smallbasic-publicwebsite.azurewebsites.net/}}
| designer = Microsoft, Vijaye Raji{{cite book |last1=Conrod |first1=Philip |last2=Tylee |first2=Lou |title=Programming Games with Microsoft Small Basic |date=February 2013 |publisher=Kidware Software, LLC |isbn=978-1-937161-56-9 |url=https://books.google.com/books?id=YXVVngEACAAJ |language=en}}{{cite web |title=Featured Article: Interviews with Vijaye Raji, the creator of Small Basic |url=https://techcommunity.microsoft.com/t5/small-basic-blog/featured-article-interviews-with-vijaye-raji-the-creator-of/ba-p/337729 |website=TECHCOMMUNITY.MICROSOFT.COM |language=en |date=13 February 2019}}
| status = Active
}}
Microsoft Small Basic is a programming language, interpreter and associated IDE. Microsoft's simplified variant of BASIC, it is designed to help students who have learnt visual programming languages such as Scratch learn text-based programming.{{cite web |url=https://smallbasic-publicwebsite.azurewebsites.net/ |title=Small Basic |access-date=6 September 2020}} The associated IDE provides a simplified programming environment with functionality such as syntax highlighting, intelligent code completion, and in-editor documentation access.{{cite web
|url=http://social.technet.microsoft.com/wiki/contents/articles/14114.aspx#Simple
|title=The Unique Features of Small Basic
|date=22 October 2012 |access-date=22 April 2015
|first= Ed |last=Price
|work=Small Basic |series=TechNet |publisher=Microsoft}} The language has only 14 keywords.{{cite web
|url=https://techcommunity.microsoft.com/t5/small-basic-blog/what-are-the-14-keywords-of-small-basic/ba-p/335469
|title=What are the 14 Keywords of Small Basic?
|date=8 October 2012 |access-date=9 February 2014
|first= Ed |last=Price
|work=Small Basic |series=MSDN Blogs |publisher=Microsoft}}
History
class="wikitable floatright" style="text-align:center; width: 22.4em; clear: right; margin: 0.5em 0 0.5em 1em;" |
Version
! Release date |
---|
{{Version|o|v0.1}}
| October 23, 2008{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/small-basic-blog/hello-world/ba-p/335289 | title=Hello World | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=23 October 2008 | access-date=9 February 2014 }} |
{{Version|o|v0.2}}
| December 17, 2008{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/small-basic-blog/announcing-small-basic-v0-2-again/ba-p/335303 | title=Announcing Small Basic v0_2! | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=17 December 2008 | access-date=27 September 2015 }} |
{{Version|o|v0.3}}
| February 10, 2009{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Microsoft-Small-Basic-v0-3-is-here/ba-p/335310 | title=Microsoft Small Basic v0.3 is here | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=10 February 2009 | access-date=27 September 2015 }} |
{{Version|o|v0.4}}
| April 14, 2009{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/v0-4-of-Small-Basic-says-quot-Bonjour-quot/ba-p/335322 | title=v0.4 of Small Basic says "Bonjour" | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=14 April 2009 | access-date=27 September 2015 }} |
{{Version|o|v0.5}}
| June 16, 2009{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/small-basic-blog/the-newest-leanest-and-the-meanest-is-here/ba-p/335331 | title=The newest, leanest and the meanest is here! | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=16 June 2009 | access-date=27 September 2015 }} |
{{Version|o|v0.6}}
| August 19, 2009{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Now-available-Small-Basic-v0-6/ba-p/335411 | title=Now available: Small Basic v0.6 | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=19 August 2009 | access-date=27 September 2015 }} |
{{Version|o|v0.7}}
| October 23, 2009{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Happy-Birthday-Small-Basic/ba-p/335419 | title=Happy Birthday Small Basic | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=23 October 2009 | access-date=27 September 2015 }} |
{{Version|o|v0.8}}
| February 4, 2010{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Small-Basic-v0-8/ba-p/335438 | title=Small Basic v0.8 | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=10 February 2010 | access-date=27 September 2015 }} |
{{Version|o|v0.9}}
| June 11, 2010{{cite web | first=Vijaye | last=Raji | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Small-Basic-V0-9-is-here/ba-p/335455 | title=Small Basic V0.9 is here! | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=11 June 2010 | access-date=27 September 2015 }} |
{{Version|o|v0.91}}
| November 17, 2010{{cite web | first=Sandra | last=Aldana | url=https://techcommunity.microsoft.com/t5/small-basic-blog/small-basic-v0-91-is-more-international-than-ever/ba-p/335458 | title=Small Basic V0.91 is more international than ever! | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=17 November 2010 | access-date=27 September 2015 }} |
{{Version|o|v0.95}}
| February 8, 2011{{cite web | first=Sandra | last=Aldana | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Small-Basic-v0-95-speaks-another-language/ba-p/335460 | title=Small Basic v0.95 speaks another language! | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=8 February 2011 | access-date=27 September 2015 }} |
{{Version|co|v1.0}}
| July 12, 2011{{cite web | first=Sandra | last=Aldana | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Small-Basic-1-0-is-here/ba-p/335461 | title=Small Basic 1.0 is here! | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=12 July 2011 | access-date=27 September 2015 }} |
{{Version|o|v1.1}}
| March 27, 2015{{cite web | first=Ed | last=Price | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Small-Basic-1-1-is-here/ba-p/337202 | title=Small Basic 1.1 is here! | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=27 March 2015 | access-date=27 September 2015 }} |
{{Version|c|v1.2}}
| October 1, 2015{{cite web | first=Michael | last=Scherotter | url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Small-Basic-1-2-Released-with-Kinect-Support-and-Bug-Fixes/ba-p/337523 | title=Small Basic 1.2 Released with Kinect Support and Bug Fixes | work=Small Basic | series=MSDN Blogs | publisher=Microsoft | date=1 October 2015 | access-date=2 October 2015 }} |
colspan="99" | {{Version|l|show=011000}}{{Version|l|show=000101}} |
Microsoft announced Small Basic in October 2008, and released the first stable version for distribution on July 12, 2011, on a Microsoft Developer Network (MSDN) website, together with a teaching curriculum{{cite web
|first= Ed |last=Price
|url=http://social.technet.microsoft.com/wiki/contents/articles/16299.small-basic-curriculum.aspx
|title=Small Basic Curriculum
|date= 29 April 2014|access-date=9 February 2014
|work=TechNet |publisher=Microsoft}} and an introductory guide.{{cite web
|url=http://social.technet.microsoft.com/wiki/contents/articles/16059.small-basic-getting-started-guide.aspx
|title=Small Basic Getting Started Guide
|date= 25 February 2014|access-date=12 February 2015
|first1= Ed |last1=Price |first2=Nonki |last2=Takahashi
|work=TechNet |publisher=Microsoft}} 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, which fixed a bug and upgraded the targeted .NET Framework version from version 3.5 to version 4.5, making it the first version incompatible with Windows XP.
Microsoft released Small Basic version 1.2 on October 1, 2015. 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, increased the number of languages supported by the included Dictionary object, and fixed a number of bugs.
On February 19, 2019, Microsoft announced Small Basic Online (SBO). It is open source software released under MIT License on GitHub.{{Cite web|url=https://techcommunity.microsoft.com/t5/Small-Basic-Blog/Announcing-Small-Basic-Online-1-0-Public-Preview/ba-p/353682|title = Announcing Small Basic Online 1.0 – Public Preview|date = 20 February 2019}}{{Cite web|url=https://social.technet.microsoft.com/wiki/contents/articles/52801.microsoft-small-basic-online-v1-0-cs-installation-guide.aspx|title=TechNet Wiki|date=17 January 2024 }}
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 ask the user for Celsius or Fahrenheit and then comments on the answer in the appropriate temperature unit.
' A Program that gives advice at a requested temperature.
TextWindow.WriteLine("Do you use 'C'elsius or 'F'ahrenheit for temperature?")
TextWindow.WriteLine("Enter C for Celsius and F for Fahrenheit:")
question_temp: ' Label to jump back to input if wrong input was given
tempunit = TextWindow.Read()
' Temperature Definitions in Celsius:
tempArray["hot"] = 30 ' 30 °C equals 86 °F
tempArray["pretty"] = 20 ' 20 °C equals 68 °F
tempArray["cold"]= 15 ' 15 °C equals 59 °F
If tempunit = "C" OR tempunit = "c" Then
TextWindow.WriteLine("Celsius selected!")
tempunit = "C" ' Could be lowercase, thus make it uppercase
ElseIf tempunit = "F" OR tempunit = "f" Then
TextWindow.WriteLine("Fahrenheit selected!")
' We calculate the temperature values for Fahrenheit based on the Celsius values
tempArray["hot"] = ((tempArray["hot"] * 9)/5) + 32
tempArray["pretty"] = ((tempArray["pretty"] * 9)/5) + 32
tempArray["cold"] = ((tempArray["cold"] * 9)/5) + 32
tempunit = "F" ' Could be lowercase, thus make it uppercase
Else
GOTO question_temp ' Wrong input, jump back to label "question_temp"
EndIf
TextWindow.Write("Enter the temperature today (in " + tempunit +"): ")
temp = TextWindow.ReadNumber()
If temp >= tempArray["hot"] Then
TextWindow.WriteLine("It is pretty hot.")
ElseIf temp >= tempArray["pretty"] Then
TextWindow.WriteLine("It is pretty nice.")
ElseIf temp >= tempArray["cold"] Then
TextWindow.WriteLine("Don't forget your coat.")
Else
TextWindow.WriteLine("Stay home.")
EndIf
Small Basic does not support an inline If
statement as does Visual Basic, for example:
=Looping=
This example demonstrates a loop. Starting from one and ending with ten, it multiplies each number by four and displays the result of the 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 and 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 shall be " + ( age + 5 ) + " years old!")
As Small Basic will readily convert among 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.{{cite web |title=System Requirements Kinect for Small Basic |url=https://ininet.org/system-requirements.html |website=ininet.org}}
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:
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#.
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.{{cite web |last1=Protalinski |first1=Emil |title=Yet another programming language from Microsoft: Small Basic |url=https://arstechnica.com/information-technology/2008/11/yet-another-programming-language-from-microsoft-small-basic/ |website=Ars Technica |language=en-us |date=17 November 2008}}
References
{{Reflist|30em}}
Further reading
- {{Cite book|author1-first=Majed|author1-last=Marji|author2-first=Ed|author2-last=Price|year=2016|title=Learn to Program with Small Basic: An Introduction to Programming with Games, Art, Science, and Math|publisher=No Starch Press|isbn=978-1593277024|url=https://nostarch.com/smallbasic}}
- {{Cite book|author1-first=Edward H|author1-last=Carlson|author2-first=Philip|author2-last=Philip Conrod|author3-first=Lou|author3-last=Tylee Conrod|year=2013|title=Small Basic For Kids: A Computer Programming Tutorial|publisher=Kidware Software|isbn=978-1937161828|url=https://kidware-software.e-junkie.com/product/233-V2-DL/Small-Basic-For-Kids---Second-Edition---Single-User---PDF-E-Book}}
- [http://channel9.msdn.com/posts/Charles/Expert-to-Expert-The-Basics-of-SmallBasic/ The Basics of Small Basic] discussion with Vijaye Raji and Erik Meijer on SmallBasic
- [http://channel9.msdn.com/shows/the%20knowledge%20chamber/intro-to-small-basic-with-vijaye-raji/ Introduction to Small Basic] {{Webarchive|url=https://web.archive.org/web/20100711084516/http://channel9.msdn.com/shows/the%20knowledge%20chamber/intro-to-small-basic-with-vijaye-raji/ |date=2010-07-11 }} discussion with Vijaye Raji and Robert Hess on SmallBasic
- [http://www.simple-talk.com/dotnet/.net-tools/microsoft-small-basic-for-.net/ Microsoft Small Basic for .NET] {{Webarchive|url=https://web.archive.org/web/20160413043657/http://www.simple-talk.com/dotnet/.net-tools/microsoft-small-basic-for-.net/ |date=2016-04-13 }} Review of Microsoft Small Basic, with sample application
- [http://rosettacode.org/wiki/Category:Microsoft_Small_Basic Category:Microsoft Small Basic] Tasks implemented in Microsoft Small Basic on [http://rosettacode.org rosettacode.org]
External links
{{Wikibooks|Windows Programming}}
- {{Official website|http://www.smallbasic.com}}
- {{GitHub|sb|Microsoft Small Basic}}
{{BASIC}}
{{.NET}}
{{Microsoft development tools}}
{{Microsoft FOSS}}
{{Integrated development environments}}
Category:BASIC programming language family
Category:Educational programming languages
Category:.NET programming languages
Category:Programming languages created in 2008
Category:Articles with example C Sharp code
Category:Software using the MIT license
Category:Pedagogic integrated development environments