User:Marc Gurevitx/MiniScript

From Wikipedia, the free encyclopedia

Minnie, the MiniScript mascot chinchilla

MiniScript is a high-level programming language intended to be small and easy to learn for beginner programmers. It supports structured, procedural and object-oriented paradigms (the latter via prototypes). Its development and features are inspired by Python, Lua, REALbasic and C#..[1]

The first stable version was released at 2017 and it became open-source at 2019.

The official interpreter[2] can be embedded in other programs (written in C++ or C#) but one can also use it as an interactive shell (REPL) or standalone script executor. The official file extension of MiniScript's programs is .ms.

There are some unofficial ports of MiniScript to other languages which allow embedding it in programs written in Kotlin,[3] Java[4] and TypeScript[5]

Data types[edit]

MiniScript has a small number of intrinsic data types: numbers, strings, lists and maps.

There are also functions that organize code in a procedural way. As in many modern languages, the functions are “first-class citizens”.

There is a special null value that represents the absence of any useful value. It belongs to its own distinguished data type.

It's possible to create new types using maps as “prototypes”. The namespaces of functions and modules are also maps.

Control structures[edit]

MiniScript provides a few simple control structures:

Programming examples[edit]

Hello world program:

print "Hello world!"

Program to calculate the factorial:

// 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)

Working with objects:

Shape = {}
Shape.sides = 0

Square = new Shape
Square.sides = 4

x = new Square
print x.sides   // prints: 4

Shape.degrees = function()
    return 180 * (self.sides - 2)
end function

print x.degrees // prints: 360

Extending the built-in types:

string.capitalized = function()
    if self.len < 2 then return self.upper
    return self[0].upper + self[1:]
end function

print "miniScript".capitalized  // prints: MiniScript

Host programs[edit]

Some environments that embed or expose MiniScript:

  • Mini Micro[6] – a fantasy retro computer where MiniScript is both a programming language and the language of the command shell.
  • Farmtronics[7] – a game mod for Stardew Valley that lets the player obtain a home computer and farming robots and program them in MiniScript.
  • Grey Hack[8] – a hacking simulator game in which the MiniScript (rebranded as GreyScript) is used as a scripting language for the in-game computers.
  • Robo Reindeer Rumble[9] – a competitive multiplayer programming game where players program battle robots (that look like reindeer) with MiniScript.

Projects[edit]

Some projects that were written in MiniScript:

Notes[edit]

  1. ^ Essay about inception of MiniScript – https://luminaryapps.com/blog/miniscript-why/
  2. ^ Official implementation of MiniScript – https://github.com/JoeStrout/miniscript
  3. ^ Kotlin port – https://github.com/Arcnor/miniscript-kt
  4. ^ Java port – https://github.com/heatseeker0/JavaMiniScript
  5. ^ TypeScript port – https://github.com/sebnozzi/miniscript.ts
  6. ^ Mini Micro's home page – https://miniscript.org/MiniMicro/index.htmlhttps://miniscript.org/MiniMicro/index.html
  7. ^ Farmtronics's code repository – https://github.com/JoeStrout/Farmtronics
  8. ^ Grey Hack on Steam – https://store.steampowered.com/app/605230/Grey_Hack/
  9. ^ Robo Reindeer Rumble home page – https://miniscript.org/RoboReindeer/
  10. ^ Inversion Institute on Steam – https://store.steampowered.com/app/2145480/Inversion_Institute/
  11. ^ Mini Micro Sokoban code repository – https://github.com/sebnozzi/minimicro-sokoban
  12. ^ World Conquest code repository – https://github.com/JoeStrout/worldConquest
  13. ^ µ-hack code repository – https://github.com/treytomes/micro-hack

External links[edit]