HOME

TheInfoList



OR:

Microsoft Small Basic is a
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
, interpreter and associated IDE.
Microsoft Microsoft Corporation is an American multinational corporation and technology company, technology conglomerate headquartered in Redmond, Washington. Founded in 1975, the company became influential in the History of personal computers#The ear ...
's simplified variant of
BASIC Basic or BASIC may refer to: Science and technology * BASIC, a computer programming language * Basic (chemistry), having the properties of a base * Basic access authentication, in HTTP Entertainment * Basic (film), ''Basic'' (film), a 2003 film ...
, it is designed to help students who have learnt visual programming languages 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 is used for programming language, programming, scripting language, scripting, or markup language, markup languages, such as HTML. The feature displays text, especially source code, in differe ...
, 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 (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 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 released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct successor to Windows 2000 for high-end and business users a ...
. 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 discontinued line of motion sensing input devices produced by Microsoft and first released in 2010. The devices generally contain RGB color model, RGB cameras, and Thermographic camera, infrared projectors and detectors that map dep ...
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 and view the source code, design documents, or content of the product. The open source model is a decentrali ...
software released under
MIT License The MIT License is a permissive software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts very few restrictions on reuse and therefore has high license compatibility. Unl ...
on
GitHub GitHub () is a Proprietary software, proprietary developer platform that allows developers to create, store, manage, and share their code. It uses Git to provide distributed version control and GitHub itself provides access control, bug trackin ...
.


Language

In Small Basic, one writes the illustrative
"Hello, World!" program A "Hello, World!" program is usually a simple computer program that emits (or displays) to the screen (often the Console application, console) a message similar to "Hello, World!". A small piece of code in most general-purpose programming languag ...
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. He was highly influential in the development of theoretical comput ...
. It supports conditional branching, loop structures, and
subroutine In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times. Callable units provide a ...
s 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 The degree Celsius is the unit of temperature on the Celsius temperature scale "Celsius temperature scale, also called centigrade temperature scale, scale based on 0 ° for the melting point of water and 100 ° for the boiling point ...
or
Fahrenheit The Fahrenheit scale () is a scale of temperature, temperature scale based on one proposed in 1724 by the German-Polish physicist Daniel Gabriel Fahrenheit (1686–1736). It uses the degree Fahrenheit (symbol: °F) as the unit. Several accou ...
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 Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic (.NET), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic (classic), the original Visual Basic suppo ...
, 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 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 collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
s, like strings,
integers An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
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 formalizations of concatenati ...
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 (computing), library made available across Programming language implementation, implementations of a programming language. Often, a standard library is specified by its associated program ...
includes basic classes for mathematics, string handling, and
input/output In computing, input/output (I/O, i/o, or informally io or IO) is the communication between an information processing system, such as a computer, and the outside world, such as another computer system, peripherals, or a human operator. Inputs a ...
, 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 Flickr ( ) is an image hosting service, image and Online video platform, 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 previously a co ...
, 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 that it represents, as in ...
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 is de ...
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#. 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 data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
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) 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 ...
and MonoDevelop.


References


Further reading

* *
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

* * {{Integrated development environments Small Basic BASIC programming language family Educational programming languages .NET programming languages 2008 software Small Basic Small Basic Programming languages created in 2008 Articles with example C Sharp code Software using the MIT license Pedagogic integrated development environments Windows-only free software Free integrated development environments