Get Started

Tip

A printable, self-contained guide containing more or less the same content of this web site can be downloaded from here.

Installing min

You can install min either by using Nimble or by cloning the repository and building from source.

Using nimble

If you already installed Nim, you probably already have the Nimble package manager installed.

If that’s the case, simply run nimble install min.

Building from source

By default, min should run without issues on any platform supported by the Nim programming language.

To build min, you can clone the git repository and compile it using Nim, like this:

nim c -d:release

Additional build options

-d:ssl / -d:nossl

By default, this build option will be on by default so that min is built with SSL support, so it will be possible to:

If this flag is not specified (by setting -d:nossl):

-d:nopcre

If -d:nopcre is specified when compiling, min will be built without PCRE support, so it will not be possible to use regular expressions and the following symbols will not be exposed by the global Module:

-d:static

If -d:static is specified, min will attempt to statically link the following libraries:

Note that for this to work, the relevant .a file must be placed in the appropriate vendor/<library>/<os>/<arch> subdirectory. For some architectures and operating systems, the correct files are versioned along with the source code — if your architecture is not listed, you need to place your libraries in a vendor/<library>/unknown subdirectory.

Running the min shell

To start the min shell, run min with no arguments. You will be presented with a prompt displaying the path to the current directory:

min shell v0.48.0 [/Users/h3rald/test]$

You can type min code and press ENTER to evaluate it immediately:

[/Users/h3rald/test]$ 2 2 + 4 [/Users/h3rald/test]$

The result of each operation will be placed on top of the stack, and it will be available to subsequent operation

[/Users/h3rald/test]$ stack.dup * 16 [/Users/h3rald/test]$

To exit min shell, press CTRL+C or type 0 exit and press ENTER.

Tip

By default, the min shell provides advanced features like tab-completion, history, etc. If however, you run into problems, you can disable these features by running min -j instead, and run min shell with a bare-bones REPL.

Executing a min program

To execute a min script, you can:

min also supports running programs from standard input, so the following command can also be used (on Unix-like system) to run a program saved in myfile.min:

$ cat myfile.min | min

Tip

You can enable development mode (runtime checks and validations) by specifying -d (--dev) when running a min program. If development mode is not enabled, min programs run faster.

Compiling a min program

min programs can be compiled to a single executable simply by using the built-in compile command:

$ min compile myfile.min

Essentially, this will:

  1. Generate a myfile.nim containing the equivalent Nim code of your min program.
  2. Call the Nim compiler to do the rest ;)

If you want to pass any options to the Nim compiler (like -d:release for example) you can do so by using the -n (or --passN) option:

$ min compile myfile.min -n:"-d:release –threadAnalysis:off –mm:orc"

Additionally, you can also use -m:<path> (or --module-path) to specify one path containing .min files which will be compiled as well (but not executed) along with the specified file. Whenever a load or a require symbol is used to load/require an external .min file, it will attempt to retrieve its contents from the pre-loaded files first before searching the filesystem.

For example, the following command executed in the root folder of the min project will compile run.min along with all .min files included in the tasks folder and its subfolders:

$ min compile run.min -m:tasks

Similarly, you can also bundle additional files in the executable by specifying the -a:<path> (or --asset-path) option. At runtime, the compiled min program will attempt to lookup bundled asset files before checking the filesystem.

Note

In order to successfully compile .min files, Nim must be installed on your system and min must be installed via nimble.

Getting help on a min symbol

min comes with a built-in help command that can be used to print information on a specific symbol. Essentially, this is equivalent to use the help symbol within the min REPL.

$ min help stack.dup

Syntax highlighting