Microsoft Small Basic

Last updated
Microsoft Small Basic
Small Basic.png
Paradigm Structured, imperative, object-oriented
Designed by Microsoft, Vijaye Raji [1] [2]
Developer Microsoft
First appearedOctober 23, 2008;15 years ago (2008-10-23) [3] [4]
Stable release
v1.2 / October 1, 2015;8 years ago (2015-10-01) [5]
Typing discipline Dynamic, weak
Platform .NET Framework 4.5 [5]
OS 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 [6]
Small Basic Online: web browser
License MIT License [7]
Filename extensions .sb, .smallbasic
Website smallbasic-publicwebsite.azurewebsites.net
Influenced by
Logo, QBasic, Visual Basic .NET

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. [8] The associated IDE provides a simplified programming environment with functionality such as syntax highlighting, intelligent code completion, and in-editor documentation access. [9] The language has only 14 keywords. [10]

Contents

History

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

Microsoft announced Small Basic in October 2008, [3] and released the first stable version for distribution on July 12, 2011, [20] on a Microsoft Developer Network (MSDN) website, together with a teaching curriculum [22] and an introductory guide. [23] 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, [21] 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. [5] 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, [5] increased the number of languages supported by the included Dictionary object, and fixed a number of bugs. [6]

On February 19, 2019, Microsoft announced Small Basic Online (SBO). It is open source software released under MIT License on GitHub. [24] [25]

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 giventempunit=TextWindow.Read()' Temperature Definitions in Celsius:tempArray["hot"]=30' 30 °C equals 86 °FtempArray["pretty"]=20' 20 °C equals 68 °FtempArray["cold"]=15' 15 °C equals 59 °FIftempunit="C"ORtempunit="c"ThenTextWindow.WriteLine("Celsius selected!")tempunit="C"' Could be lowercase, thus make it uppercaseElseIftempunit="F"ORtempunit="f"ThenTextWindow.WriteLine("Fahrenheit selected!")' We calculate the temperature values for Fahrenheit based on the Celsius valuestempArray["hot"]=((tempArray["hot"]*9)/5)+32tempArray["pretty"]=((tempArray["pretty"]*9)/5)+32tempArray["cold"]=((tempArray["cold"]*9)/5)+32tempunit="F"' Could be lowercase, thus make it uppercaseElseGOTOquestion_temp' Wrong input, jump back to label "question_temp"EndIfTextWindow.Write("Enter the temperature today (in "+tempunit+"): ")temp=TextWindow.ReadNumber()Iftemp>=tempArray["hot"]ThenTextWindow.WriteLine("It is pretty hot.")ElseIftemp>=tempArray["pretty"]ThenTextWindow.WriteLine("It is pretty nice.")ElseIftemp>=tempArray["cold"]ThenTextWindow.WriteLine("Don't forget your coat.")ElseTextWindow.WriteLine("Stay home.")EndIf

Small Basic does not support an inline If statement as does Visual Basic, for example:

Iftemp>50ThenTextWindow.WriteLine("It is pretty nice.")

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")Fori=1To10TextWindow.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 2TextWindow.WriteLine("100"+"3000")' Prints 3100TextWindow.WriteLine("Windows "+8)' Prints Windows 8TextWindow.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. [26]

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:

Fori=1To10pic=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.

Fori=1to4Turtle.Move(100)' Forward 100 pixelsTurtle.Turn(90)' Turn 90 degrees rightEndFor

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]publicstaticclassExampleClass{publicstaticPrimitiveAdd(PrimitiveA,PrimitiveB)=>A+B;publicstaticPrimitiveSomeProperty{get;set;}publicstaticPrimitivePi=>(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. [27]

Related Research Articles

VBScript is a deprecated Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers without error handling and with subroutines and other advanced programming constructs. It can give the user complete control over many aspects of their computing environment.

Hungarian notation is an identifier naming convention in computer programming in which the name of a variable or function indicates its intention or kind, or in some dialects, its type. The original Hungarian notation uses only intention or kind in its naming convention and is sometimes called Apps Hungarian as it became popular in the Microsoft Apps division in the development of Microsoft Office applications. When the Microsoft Windows division adopted the naming convention, they based it on the actual data type, and this convention became widely spread through the Windows API; this is sometimes called Systems Hungarian notation.

Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware acceleration if it is available on the graphics card, allowing for hardware acceleration of the entire 3D rendering pipeline or even only partial acceleration. Direct3D exposes the advanced graphics capabilities of 3D graphics hardware, including Z-buffering, W-buffering, stencil buffering, spatial anti-aliasing, alpha blending, color blending, mipmapping, texture blending, clipping, culling, atmospheric effects, perspective-correct texture mapping, programmable HLSL shaders and effects. Integration with other DirectX technologies enables Direct3D to deliver such features as video mapping, hardware 3D rendering in 2D overlay planes, and even sprites, providing the use of 2D and 3D graphics in interactive media ties.

<span class="mw-page-title-main">Graphics Device Interface</span> Microsoft Windows API

The Graphics Device Interface (GDI) is a legacy component of Microsoft Windows responsible for representing graphical objects and transmitting them to output devices such as monitors and printers. It was superseded by DirectDraw API and later Direct2D API. Windows apps use Windows API to interact with GDI, for such tasks as drawing lines and curves, rendering fonts, and handling palettes. The Windows USER subsystem uses GDI to render such UI elements as window frames and menus. Other systems have components that are similar to GDI; for example: Mac OS has QuickDraw, and Linux and Unix have X Window System core protocol.

<span class="mw-page-title-main">Visual Basic (.NET)</span> Object-oriented computer programming language

Visual Basic (VB), originally called Visual Basic .NET (VB.NET), is a multi-paradigm, object-oriented programming language, implemented on .NET, Mono, and the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual Basic language, the last version of which was Visual Basic 6.0. Although the ".NET" portion of the name was dropped in 2005, this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages released since 2002, in order to distinguish between them and the classic Visual Basic. Along with C# and F#, it is one of the three main languages targeting the .NET ecosystem. Microsoft updated its VB language strategy on 6 February 2023, stating that VB is a stable language now and Microsoft will keep maintaining it.

The BMP file format or bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device, especially on Microsoft Windows and OS/2 operating systems.

<span class="mw-page-title-main">Defragmentation</span> Rearrangement of sectors on a hard disk into contiguous units

In the maintenance of file systems, defragmentation is a process that reduces the degree of fragmentation. It does this by physically organizing the contents of the mass storage device used to store files into the smallest number of contiguous regions. It also attempts to create larger regions of free space using compaction to impede the return of fragmentation. Some defragmentation utilities try to keep smaller files within a single directory together, as they are often accessed in sequence.

<span class="mw-page-title-main">DirectShow</span> Microsoft API

DirectShow, codename Quartz, is a multimedia framework and API produced by Microsoft for software developers to perform various operations with media files or streams. It is the replacement for Microsoft's earlier Video for Windows technology. Based on the Microsoft Windows Component Object Model (COM) framework, DirectShow provides a common interface for media across various programming languages, and is an extensible, filter-based framework that can render or record media files on demand at the request of the user or developer. The DirectShow development tools and documentation were originally distributed as part of the DirectX SDK. Currently, they are distributed as part of the Windows SDK.

<span class="mw-page-title-main">Microsoft Visual Studio Express</span> Integrated development environment

Microsoft Visual Studio Express is a set of integrated development environments (IDEs) that Microsoft developed and released free of charge. They are function-limited version of the non-free Visual Studio and require mandatory registration. Express editions started with Visual Studio 2005.

<span class="mw-page-title-main">WordPad</span> Basic word processor formerly included with Microsoft Windows

WordPad is a word processor software included with Windows 95 and later. Similarly to its predecessor Microsoft Write, it is a basic word processor, positioned as more advanced than the Notepad text editor by supporting rich text editing, but with a subset of the functionality of Microsoft Word.

<span class="mw-page-title-main">Windows Installer</span> Software

Windows Installer is a software component and application programming interface (API) of Microsoft Windows used for the installation, maintenance, and removal of software. The installation information, and optionally the files themselves, are packaged in installation packages, loosely relational databases structured as COM Structured Storages and commonly known as "MSI files", from their default filename extensions. The packages with the file extensions mst contain Windows Installer "Transformation Scripts", those with the msm extensions contain "Merge Modules" and the file extension pcp is used for "Patch Creation Properties". Windows Installer contains significant changes from its predecessor, Setup API. New features include a GUI framework and automatic generation of the uninstallation sequence. Windows Installer is positioned as an alternative to stand-alone executable installer frameworks such as older versions of InstallShield and NSIS.

<span class="mw-page-title-main">Font rasterization</span> Process of converting text from vector to raster

Font rasterization is the process of converting text from a vector description to a raster or bitmap description. This often involves some anti-aliasing on screen text to make it smoother and easier to read. It may also involve hinting—information embedded in the font data that optimizes rendering details for particular character sizes.

Windows Presentation Foundation (WPF) is a free and open-source graphical subsystem originally developed by Microsoft for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0 in 2006. WPF uses DirectX and attempts to provide a consistent programming model for building applications. It separates the user interface from business logic, and resembles similar XML-oriented object models, such as those implemented in XUL and SVG.

<span class="mw-page-title-main">C Sharp (programming language)</span> Programming language

C# is a general-purpose high-level programming language supporting multiple paradigms. C# encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines.

<span class="mw-page-title-main">Visual Basic (classic)</span> Microsofts programming language based on BASIC and COM

Visual Basic (VB) before .NET, sometimes referred to as Classic Visual Basic, is a third-generation programming language, based on BASIC, and an integrated development environment (IDE), from Microsoft for Windows known for supporting rapid application development (RAD) of graphical user interface (GUI) applications, event-driven programming and both consumption and development of components via the Component Object Model (COM) technology.

<span class="mw-page-title-main">Visual Studio</span> Code editor and IDE

Visual Studio is an integrated development environment (IDE) developed by Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms such as Windows API, Windows Forms, Windows Presentation Foundation (WPF), Windows Store and Microsoft Silverlight. It can produce both native code and managed code.

Direct2D is a 2D vector graphics application programming interface (API) designed by Microsoft and implemented in Windows 10, Windows 8, Windows 7 and Windows Server 2008 R2, and also Windows Vista and Windows Server 2008.

<span class="mw-page-title-main">Kinect</span> Motion-sensing input device for the Xbox 360 and Xbox One

Kinect is a line of motion sensing input devices produced by Microsoft and first released in 2010. The devices generally contain RGB cameras, and infrared projectors and detectors that map depth through either structured light or time of flight calculations, which can in turn be used to perform real-time gesture recognition and body skeletal detection, among other capabilities. They also contain microphones that can be used for speech recognition and voice control.

Windows Runtime (WinRT) is a platform-agnostic component and application architecture first introduced in Windows 8 and Windows Server 2012 in 2012. It is implemented in C++ and officially supports development in C++, Rust/WinRT, Python/WinRT, JavaScript-TypeScript, and the managed code languages C# and Visual Basic .NET (VB.NET).

<span class="mw-page-title-main">.NET</span> Free and open-source software platform developed by Microsoft

The .NET platform is a free and open-source, managed computer software framework for Windows, Linux, and macOS operating systems. The project is mainly developed by Microsoft employees by way of the .NET Foundation and is released under an MIT License.

References

  1. Conrod, Philip; Tylee, Lou (February 2013). Programming Games with Microsoft Small Basic. Kidware Software, LLC. ISBN   978-1-937161-56-9.
  2. "Featured Article: Interviews with Vijaye Raji, the creator of Small Basic". TECHCOMMUNITY.MICROSOFT.COM. 13 February 2019.
  3. 1 2 3 Raji, Vijaye (23 October 2008). "Hello World". Small Basic. MSDN Blogs. Microsoft. Retrieved 9 February 2014.
  4. 1 2 Raji, Vijaye (23 October 2009). "Happy Birthday Small Basic". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  5. 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.
  6. 1 2 "Download Microsoft Small Basic 1.2 from Official Microsoft Download Centre". Small Basic. Microsoft. 1 October 2015. Retrieved 2 October 2015.
  7. "SmallBasic". GitHub . 17 October 2021.
  8. "Small Basic" . Retrieved 6 September 2020.
  9. Price, Ed (22 October 2012). "The Unique Features of Small Basic". Small Basic. TechNet. Microsoft. Retrieved 22 April 2015.
  10. Price, Ed (8 October 2012). "What are the 14 Keywords of Small Basic?". Small Basic. MSDN Blogs. Microsoft. Retrieved 9 February 2014.
  11. Raji, Vijaye (17 December 2008). "Announcing Small Basic v0_2!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  12. Raji, Vijaye (10 February 2009). "Microsoft Small Basic v0.3 is here". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  13. Raji, Vijaye (14 April 2009). "v0.4 of Small Basic says "Bonjour"". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  14. Raji, Vijaye (16 June 2009). "The newest, leanest and the meanest is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  15. Raji, Vijaye (19 August 2009). "Now available: Small Basic v0.6". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  16. Raji, Vijaye (10 February 2010). "Small Basic v0.8". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  17. Raji, Vijaye (11 June 2010). "Small Basic V0.9 is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  18. Aldana, Sandra (17 November 2010). "Small Basic V0.91 is more international than ever!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  19. Aldana, Sandra (8 February 2011). "Small Basic v0.95 speaks another language!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  20. 1 2 Aldana, Sandra (12 July 2011). "Small Basic 1.0 is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  21. 1 2 Price, Ed (27 March 2015). "Small Basic 1.1 is here!". Small Basic. MSDN Blogs. Microsoft. Retrieved 27 September 2015.
  22. Price, Ed (29 April 2014). "Small Basic Curriculum". TechNet. Microsoft. Retrieved 9 February 2014.
  23. Price, Ed; Takahashi, Nonki (25 February 2014). "Small Basic Getting Started Guide". TechNet. Microsoft. Retrieved 12 February 2015.
  24. "Announcing Small Basic Online 1.0 – Public Preview". 20 February 2019.
  25. "TechNet Wiki".
  26. "System Requirements Kinect for Small Basic". ininet.org.
  27. Protalinski, Emil (17 November 2008). "Yet another programming language from Microsoft: Small Basic". Ars Technica.

Further reading