Microsoft Small Basic
   HOME

TheInfoList



OR:

Microsoft Small Basic is a
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
, interpreter and associated IDE.
Microsoft Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washi ...
's simplified variant of
BASIC BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
, it is designed to help students who have learnt
visual programming language In computing, a visual programming language (visual programming system, VPL, or, VPS) is any programming language that lets users create programs by manipulating program elements ''graphically'' rather than by specifying them ''textually''. A VPL ...
s such as Scratch learn text-based programming. The associated IDE provides a simplified programming environment with functionality such as
syntax highlighting Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms ...
, intelligent code completion, and in-editor documentation access. The language has only 14 keywords.


History

Microsoft announced Small Basic in October 2008, and released the first stable version for distribution on July 12, 2011, on a
Microsoft Developer Network Microsoft Developer Network (MSDN) was the division of Microsoft responsible for managing the firm's relationship with developers and testers, such as hardware developers interested in the operating system (OS), and software developers developing ...
(MSDN) website, together with a teaching curriculum and an introductory guide. 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 The .NET Framework (pronounced as "''dot net"'') is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until bein ...
version from version 3.5 to version 4.5, making it the first version incompatible with
Windows XP Windows XP is a major release of Microsoft's Windows NT operating system. It was release to manufacturing, released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Wind ...
. 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 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 fli ...
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 Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized so ...
software released under
MIT License The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license comp ...
on
GitHub GitHub, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, cont ...
.


Language

In Small Basic, one writes the illustrative
"Hello, World!" program A "Hello, World!" program is generally a computer program that ignores any input and outputs or displays a message similar to "Hello, World!". A small piece of code in most general-purpose programming languages, this program is used to illustr ...
as follows: TextWindow.WriteLine("Hello, World!") Microsoft Small Basic is
Turing complete Alan Mathison Turing (; 23 June 1912 – 7 June 1954) was an English mathematician, computer scientist, logician, cryptanalyst, philosopher, and theoretical biologist. Turing was highly influential in the development of theoretical ...
. It supports conditional branching,
loop Loop or LOOP may refer to: Brands and enterprises * Loop (mobile), a Bulgarian virtual network operator and co-founder of Loop Live * Loop, clothing, a company founded by Carlos Vasquez in the 1990s and worn by Digable Planets * Loop Mobile, an ...
structures, and
subroutine In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed. Functions may ...
s for
event Event may refer to: Gatherings of people * Ceremony, an event of ritual significance, performed on a special occasion * Convention (meeting), a gathering of individuals engaged in some common interest * Event management, the organization of ev ...
handling. Variables are
weakly typed In computer programming, one of the many ways that programming languages are colloquially classified is whether the language's type system makes it strongly typed or weakly typed (loosely typed). However, there is no precise technical definitio ...
and
dynamic Dynamics (from Greek δυναμικός ''dynamikos'' "powerful", from δύναμις ''dynamis'' "power") or dynamic may refer to: Physics and engineering * Dynamics (mechanics) ** Aerodynamics, the study of the motion of air ** Analytical dyn ...
with no scoping rules.


Conditional branching

The following example demonstrates conditional branching. It requests the current temperature in
Fahrenheit The Fahrenheit scale () is a temperature scale based on one proposed in 1724 by the physicist Daniel Gabriel Fahrenheit (1686–1736). It uses the degree Fahrenheit (symbol: °F) as the unit. Several accounts of how he originally defined hi ...
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 Small Basic does not support an inline If statement as does
Visual Basic Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic .NET (now simply referred to as "Visual Basic"), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic ( ...
, for example: If temp > 50 Then TextWindow.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") For i = 1 To 10 TextWindow.Write(i * 4) EndFor While loops are also supported, and the demonstrated For
loop Loop or LOOP may refer to: Brands and enterprises * Loop (mobile), a Bulgarian virtual network operator and co-founder of Loop Live * Loop, clothing, a company founded by Carlos Vasquez in the 1990s and worn by Digable Planets * Loop Mobile, an ...
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 type In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
s, like strings,
integers An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
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 In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball". In certain formalisations of concatenat ...
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 In computer programming, a standard library is the library made available across implementations of a programming language. These libraries are conventionally described in programming language specifications; however, contents of a language's a ...
includes basic classes for mathematics,
string handling In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed (after creation) ...
, and
input/output In computing, input/output (I/O, or informally io or IO) is the communication between an information processing system, such as a computer, and the outside world, possibly a human or another information processing system. Inputs are the signals ...
, 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 In computer graphics, turtle graphics are vector graphics using a relative cursor (the "turtle") upon a Cartesian plane (x and y axis). Turtle graphics is a key feature of the Logo programming language. Overview The turtle has three attribut ...
class, a class for retrieving photos from
Flickr Flickr ( ; ) is an American image hosting and video hosting service, as well as an online community, founded in Canada and headquartered in the United States. It was created by Ludicorp in 2004 and was a popular way for amateur and profession ...
, 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 A logo (abbreviation of logotype; ) is a graphic mark, emblem, or symbol used to aid and promote public identification and recognition. It may be of an abstract or figurative design or include the text of the name it represents as in a wo ...
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 In geometry, a hexagon (from Greek , , meaning "six", and , , meaning "corner, angle") is a six-sided polygon. The total of the internal angles of any simple (non-self-intersecting) hexagon is 720°. Regular hexagon A '' regular hexagon'' has ...
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 Static may refer to: Places *Static Nunatak, a nunatak in Antarctica United States * Static, Kentucky and Tennessee *Static Peak, a mountain in Wyoming **Static Peak Divide, a mountain pass near the peak Science and technology Physics *Static el ...
, 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#. mallBasicTypepublic static class ExampleClass 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 Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
file, which can be automatically generated from source code comments by tools such as
Microsoft Visual Studio Visual Studio is an integrated development environment (IDE) from 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 ...
and MonoDevelop.


References


Further reading


Small Basic Programming Tutorials
by Kidware Software
Learn to Program with Small Basic
by No Starch
The Basics of Small Basic
discussion with Vijaye Raji and Erik Meijer on SmallBasic
Introduction to Small Basic
discussion with Vijaye Raji and Robert Hess on SmallBasic
Microsoft Small Basic for .NET
Review of Microsoft Small Basic, with sample application
Microsoft Small Basic
Tasks implemented in Microsoft Small Basic o
rosettacode.org


External links

* {{Microsoft FOSS
Small Basic 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 ...
BASIC programming language family Educational programming languages .NET programming languages Computer-related introductions in 2008 Microsoft free software
Small Basic 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 ...
Programming languages created in 2008 Articles with example C Sharp code Software using the MIT license Pedagogic integrated development environments Windows-only free software