Get Started
You can download one of the following pre-built min binaries:
Tip
A printable, self-contained guide containing more or less the same content of this web site can be downloaded from here.
Building from source
Alternatively, you can build min from source in one of the following ways:
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 for additional platforms
By default, min is released as a pre-built binary executable for Windows x64, macOS x64 and Linux x64. However, it should run without issues on any platform supported by the Nim programming language.
To build on a different operating system and architecture from the default ones, you also need to get or build the following static libraries:
- libssl (OpenSSL)
- libcrypto (OpenSSL)
- libpcre (PCRE)
and also specify the following additional flag when compiling:
--passL:"-static -L<dir> -lpcre -lssl -lcrypto"
Where <dir> is the directory containing the *.a files for the static libraries listed above.
Alternatively, if you can also opt out from OpenSSL and PCRE support by:
- Specifying -d:nossl
- Specifying -d:nopcre
Additional build options
-d:ssl
If the -d:ssl flag is specified when compiling, min will be built with SSL support, so it will be possible to:
- perform HTTPS requests with the http Module.
- use all the cryptographic symbols defined in the crypto Module.
If this flag is not specified:
- It will not be possible to perform HTTPS requests
Only the following symbols will be exposed by the crypto Module:
-d:nopcre
If the -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:
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.46.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:
- Run min eval "...program..." to execute a program inline.
- Run min myfile.min to execute a program contained in a file.
- Run min run <mmm> to execute the main symbol of the specified min managed module. If the managed module is not installed globally, it will be downloaded and installed automatically.
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
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:
- Generate a myfile.nim containing the equivalent Nim code of your min program.
- 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:refc"
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
- If you are using Visual Studio Code, you can install the official min extension which provides syntax highlighting support, code folding, and auto-indentation.
- If you are using Vim, a min.vim syntax definition file is available in the min repo.
- If you are using Sublime Text 3, Rafael Carrasco created a min syntax definition file that is available here.