Draft:MiniScript

From Wikipedia, the free encyclopedia

MiniScript (programming language)[edit]

MiniScript
The MiniScript mascot "Minnie"
MiniScript shell in Mini Micro
ParadigmMulti-paradigm: scripting, structured, procedural, object-oriented (via prototype-based)
DeveloperJoe Strout
First appeared27 April 2017; 7 years ago (2017-04-27)
Stable release
1.6.1 / 29 June 2023; 10 months ago (2023-06-29)
Typing disciplineduck, dynamic
Scopedynamic; function / global
OSWindows, macOS, Linux/UNIX, Android (in development)
LicenseMIT License
Filename extensions.ms
Websiteminiscript.org
Major implementations
Official (C++/C#), Unity add-on; unofficial: Kotlin port, JavaMiniScript, TypeScript port, Rust port, Godot plug-in
Dialects
GreyScript, JavaScript port of GreyScript
Influenced by
Python, Lua, BASIC, C#[1]

MiniScript is a lightweight, high-level, general-purpose programming language. Its design philosophy emphasizes intuitiveness (i.e. “guessability”), expressiveness, extensibility and portability.[2].

MiniScript is dynamically-typed and supports procedural and object-oriented paradigms, the latter via prototype-based inheritance[3].

The MiniScript interpreter provides an interactive REPL (Read-Print-Eval Loop) to encourage experimentation and prototyping, and has been embedded into a number of environments.

History[edit]

MiniScript was conceived in 2016 by Joe Strout, and has been under continuous development since that time[4].

Version 1.0 of MiniScript was released on April 27, 2017, and was made open-source on June 2019 as of Version 1.4. The current version of MiniScript is 1.6[5].

MiniScript Release History
Version Number Release Date
Version 1.0 April 27, 2017 (initial release)
Version 1.1 September 15, 2017
Version 1.2 June 24, 2018
Version 1.3 March 1, 2019
Version 1.4 June 9, 2019 (open-sourced)
Version 1.5 November 23, 2019
Version 1.5.1 December 18, 2021
Version 1.6 February 6, 2023
Version 1.6.1 Jun 29, 2023 (current version)

Design philosophy[edit]

MiniScript derives its name from a design philosophy guided by simplicity and minimalism, with the end goal being an optimal language that inherits the best features of modern scripting languages, among them:

  • Elegant string, list and map / dictionary handling
  • Native Unicode support
  • Interactive REPL
  • Intuitive and orthogonal syntax
  • Compact implementation size
  • Support for object oriented programming/paradigms (OOP)
  • Cross-platform embedding capacity

As a side-effect, MiniScript eliminates common barriers to new coders, such as counterintuitive punctuation, indentation/white space significance or complex OOP implementations (e.g. multiple inheritance)[6]

MiniScript language features[edit]

Core Data Types[edit]

Type Description Example Code
Numbers Numbers are stored in full-precision format, and are also used to store true (1) and false (0) Boolean values. e = 2.71819
Strings Strings are immutable runs of Unicode characters, and support both iteration and slicing. s = "Hello World"
Lists Lists reference mutable, ordered sequences of arbitrary values. Like strings, lists support iteration and slicing, but (unlike strings) lists can be modified in place. seq = [1, 2, "three"]
Maps Maps reference mutable collections of key/value pairs. Keys within a map are unique; both keys and values may be any type. Maps also form the basis of the class/object system, and support single inheritance.

m = {“five":5}
m["six"] = 6
m.seven = 7

Functions Functions reference compiled subprograms. Functions in MiniScript are first-class objects and may be stored in variables, passed as parameters, used in lists and maps, etc. dist = function(x,y)
    return sqrt(x^2 + y^2)
end function
Null Null is a special data type with only one value. x = null

Object-Oriented Programming[edit]

Classes in MiniScript are a simple extension of Maps. This approach supports only single inheritance, but like Python, MiniScript uses duck typing to allow a class to adhere to any number of interfaces Additional keywords (new, self, and super) complete MiniScript’s OOP implementation[7].

Variables local by default[edit]

MiniScript variables are always local to the function it is in, unless explicitly referenced as a global. This approach eliminates many subtle logic errors arising from variable scope and lifespan.

Read-Evaluate-Print Loop (REPL)[edit]

Command-line MiniScript fully supports an interactive REPL. In cases where MiniScript is embedded in other software, support for a REPL is available in the code, but exposing this to the user is up to the host application.

In the Mini Micro virtual computer, the MiniScript REPL also serves as the shell, i.e. the means by which the user navigates the file system, loads and runs programs, etc. Thus in this environment, everything is done in MiniScript; there is no need to learn a separate shell syntax[8].

Minimalist core[edit]

The MiniScript core is constrained to provide only features and functions that are commonly needed in a programming language. As a result, the core can be concisely described in a one-page reference[9]

MiniScript Syntax and Semantics[edit]

General[edit]

  • MiniScript is case-sensitive
  • All variables are local by default
  • Semicolons can be used to join multiple statements on one line.
  • Code blocks are delimited by keywords (see next)
  • Indentation and white space is ignored, but encouraged for readability
  • Lines beginning with // are comments that are ignored by the interpreter

Core keywords and numeric operators[edit]

Branching If | Else If | Else | End If
Looping While | End While | For | End For
Assignment x = 3
Addition x = x + 3 or x += 3
Subtraction x = x - 3 or x -= 3
Multiplication x = x * 3 or x *= 3
Division x = x / 3 or x /= 3
Exponentation x = x ^ 3 or x ^= 3
Modular arithmetic x = x % 3 or x %= 3
Comparisons x == 3, x != 3, x >= 3, x <= 3

All keywords and operators for supported MiniScript data types can be found in the MiniScript syntax reference

Programming examples[edit]

Hello world program:

print "Hello world!"

Program to calculate the factorial of a positive integer:

factorial = function(x)
	if x < 2 then return 1
	return x * factorial(x - 1)
end function

print factorial(input("Type a number, and its factorial will be printed: ").val)

Command-line implementations[edit]

Official implementations: C# and C++ (see https://github.com/JoeStrout/miniscript)

Unofficial implementations: Kotlin and Java (see https://miniscript.org/wiki/Open-Source_Projects)

Host environments[edit]

Some notable applications that embedded MiniScript as a scripting language:

Mini Micro (all-in-one IDE and runtime environment)[edit]

Desktop demo in Mini Micro

Mini Micro is virtual computer built from scratch using MiniScript as its built in language[10]. Mini Micro emulates key elements of 1980s and early 1990s era personal computers that helped a generation of developers find an interest and sense of ownership as programmers. For example, it boots up to a command prompt, a blinking cursor that is a gateway to a built-in programming language (MiniScript). Interaction is primarily text based including editing and running programs with the built editor or creating simple graphics, sounds, and music, programmatically. Mini Micro has a 960x640 display with 8 customizable layers, supports modern image and sound formats such as png and wav, and complete documentation via the MiniScript Wiki.

Farmtronics[edit]

Farmtronics is a plug-in for “Stardew Valley” game that adds a home computer and farming bots programmable in MiniScript.

Soda[edit]

Soda is an open-source cross-platform game engine based on MiniScript and SDL2. It shares many APIs with Mini Micro, enabling some code to be easily transported between the two environments.

GreyHack[edit]

“GreyHack” is a hacking simulator game where players write code in GreyScript, a dialect of MiniScript.

References[edit]

  1. ^ "Luminary Apps : Blog".
  2. ^ "MiniScript Home Page". miniscript.org. Retrieved 2023-09-08.
  3. ^ Strout, Joe (June 15, 2022). MiniScript Manual (PDF) (Version 1.5.1 ed.). MiniScript Press. p. 21.
  4. ^ JoeStrout (2023-09-08), MiniScript, retrieved 2023-09-08
  5. ^ "miniscript/MiniScript-Release-Notes.txt at master · JoeStrout/miniscript". GitHub. Retrieved 2023-09-08.
  6. ^ "Neo-retro computing". DEV Community. 2021-11-20. Retrieved 2023-09-08.
  7. ^ Strout, Joe (June 15, 2021). MiniScript Manual (PDF) (1.5.1 ed.). MiniScript Press. pp. 21–23.
  8. ^ https://miniscript.org/files/MiniMicro-CheatSheet.pdf
  9. ^ https://miniscript.org/files/MiniScript-QuickRef.pdf
  10. ^ "Introducing Mini Micro – beanz Magazine". Retrieved 2023-09-08.

Category:Cross-platform free software Category:Cross-platform software Category:Dynamically typed programming languages Category:Educational programming languages Category:Embedded systems Category:Free compilers and interpreters Category:High-level programming languages Category:Multi-paradigm programming languages Category:Object-oriented programming languages Category:Programming languages Category:Prototype-based programming languages Category:Scripting languages Category:Software using the MIT license