Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.
Version 104 (modified by JarrettBillingsley, 15 years ago)
--
Thanks to Andrzej Rutkowski for designing this logo.

Welcome to MiniD!

Table of Contents

What is MiniD?

MiniD is a scripting language which was conceived, written, and is maintained by Jarrett Billingsley. It is most closely related to Lua, with other influences from D, Squirrel, and Io and is dynamically typed with a C-style syntax and D-like (though not identical to D) semantics.

MiniD is not an "interpreted version of D" or anything like that, despite what the ill-fitting name implies. It's a language all on its own, with its own grammar and semantics. If you're familiar with D, though, there should be a lot here that will seem familiar to you.

The reference implementation is written in D and is designed with D's featureset in mind, in order to make integration of MiniD into a host application seamless and easy.

Announcements and Communication

MiniD 2 is nearing completion! The spec is, as far as I know, done (though one or two more little things might make it in, who knows). The new implementation is mostly finished and just needs some testing and some more development on a few areas. You can track the progress of MiniD 2 here.

You can find announcements and status updates, ask questions, and discuss the language over on the forums. Please feel free to start your own topics!

There's also an IRC channel for MiniD on Freenode, called #d.minid. You can access that link if your browser understands irc:// links. I (Jarrett) try to be on as much as possible.

If you have a suggestion or bug report, please use the "New Ticket" button at the top right.

Language Documentation

MiniD as a language is not tied to any specific implementation. The reference implementation is written in D, but anyone is free to implement the language any way they choose.

This is the specification for version 2 of MiniD. This specification is still under development and is not yet complete in some areas. Differences from MiniD 1 are noted throughout the spec in green boxes. I'll probably aggregate all the changes into a single page come the release of MiniD 2.

MiniD 2 is my main focus of development. The spec is pretty much complete; I don't really plan on changing much and I think I'm out of ideas to add. The new MiniD 2 implementation is very nearly complete as of the middle of November and I really really hope to have a release candidate out by December. But I can't make any promises.

Green Boxes

You'll see these green boxes throughout the specification. These are put under sections of the specification and standard libraries that have changed from MiniD 1.

  • MiniD 2 Specification
    • Compilation - Describes the process of compiling source text into an executable form.
    • Execution - How the compiled MiniD code is actually run.
    • Lexical - The very basic textual bits that the language is made up of.
    • Expressions - The algebraic language syntax of MiniD.
    • Statements - Various language constructs.
    • Types - A description of the various data types in MiniD.
    • Declarations - How one declares and initializes variables.
    • Functions - How to declare functions and what they can do.
    • Classes - The object-oriented aspects of MiniD.
    • Modules - The largest blocks of organization in MiniD, and how to work with them.
    • Metamethods - How to customize the behavior of objects and perform operator overloading.
    • Grammar - The (mostly-correct) EBNF grammar for MiniD.
  • Standard Library - A library of common operations that accompanies MiniD.
    • Base Library - A set of simple/common functionality that doesn't fit anywhere else.
      • Modules Library - A subset of the base library that holds the functions and structures necessary for the MiniD module system.
      • Thread Library - A subset of the base library that has to do with threading and thread objects.
    • Array Library - A library of common array functions.
    • Character Library - Character classification and modification.
    • Hash Library - Operations that are mostly applicable to both hash types: tables and namespaces.
    • IO Library - File system manipulations and file access.
    • Math Library - Regular old math functions.
    • OS Library - Access to some lower-level OS functionality, like spawning processes.
    • RegExp Library - String manipulation and matching with regular expressions.
    • Stream Library - Classes for performing streamed input and output.
    • String Library - Functions for manipulating strings.
    • Time Library - For timing things and getting the system time.

You can also access the MiniD 1 Language Specification. This was the first version of the language but is no longer being supported.

Language Tutorial

This is an informal introduction to the language, bit by bit, based on MiniD 2. It assumes that you already know a good bit about programming and are comfortable using command-line programs.

  • Getting Started - Obligatory programs and such.
  • Types - Many of the MiniD types and what you can do with them.
  • Expressions - The various value-yielding language constructs.
  • Statements - Control flow, assignment, and variable declarations.
  • Functions - Breaking up your program into individual reusable bits.
  • Classes - Defining your own types.
  • Metamethods - Making your types work like built-in types.
  • Exceptions - How MiniD handles errors - neatly.
  • Modules - Organizing larger programs.
  • Coroutines - Fun with collaborative multithreading!
  • Advanced Topics - Weak references, custom module loaders, iteration fun, applications...
  • Standard Library? - A broad overview of some of the more important parts of the standard library.

Library Documentation

This is the documentation for the reference library implementation of MiniD.

The MiniD library is based on Tango, the alternative standard library for D. For those of you using Phobos, you're just out of luck.

MiniD is, right now, only compatible with D1. MiniD will probably not support D2 until D2 gets out of alpha at least. MiniD probably doesn't even compile under D2; it hasn't been tried to my knowledge.

As for which D1 compilers support MiniD, GDC is, unfortunately, too out-of-date to compile it. Even the trunk revision of GDC is only up to DMD 1.030, and MiniD needs at least 1.034 or equivalent. LDC, however, does compile MiniD (usually). DMD 1.034 or newer seems to compile MiniD on both Windows and Linux.

Mac users: erm, well, sorry but you're kind of out of luck. DMD doesn't work there, and as far as I know neither does LDC. GDC is still too old. Unless one of those three things changes, you'll just have to, uh, dual boot or run Parallels or something.

To use MiniD, just check it out from the repository, either using a Subversion client or by using the "Zip Archive" link at the bottom-center of the Trac SVN browser. There is currently no "stable" release as the new implementation is still beta quality. You can get it by checking out the 'trunk' folder of the subversion repository. MiniD currently has no stable release version, and what is in trunk uses revision 4048 of Tango.

MiniD is built (on Windows at least) with Build, and it also works fine with DSSS. Note, however, that using "dsss net install" will always install the head revision, which may or may not be stable. Because of this, it's probably best to download/checkout the stable repo revision, and do a "dsss build" and then "dsss install" in its directory instead.

The MiniD 2 Library Reference follows:

  • Compilation Options - Customize your build of MiniD for different restrictions and capabilities.
  • minid.alloc - No real public interface, but it does define and explain the memory allocation function type that MiniD uses to perform all its memory allocation. See minid.api for where it's used.
  • minid.api - The main file you should import when using MiniD, this defines a few core functions and publicly imports most of the rest of the public API.
  • minid.ast - This module holds the definitions of all the abstract syntax tree (AST) nodes used by the MiniD compiler. When the compiler gets the ability to provide you with an AST of some code, you'll be able to access all the members of these nodes.
  • minid.bind - The binding library, which allows you to quickly exposts native D types and functions to MiniD (not complete yet).
  • minid.commandline - A MiniD command-line interpreter which contains all the logic needed to embed a simple CLI in your app. MDCL basically just wraps this.
  • minid.compiler - This module holds the public interface to the compiler. Most of the time you won't need to deal with this.
  • minid.ex - The "extension" library, a collection of non-essential but useful functionality to automate many common native API tasks such as building strings, checking parameters, and looking up dotted names.
  • minid.interpreter - The vast majority of the MiniD API lies in here.
  • minid.serialization - The APIs for serializing and deserializing compiled MiniD functions.
  • minid.types - Type declarations used by the API, as well as some other variables and constants.
  • minid.utils - A utility library with a bunch of non-MiniD-specific functionality.
  • minid.vm - A module with a few VM-related functions.

You can also access the MiniD 1 library documentation. This was for the first version and implementation of the language but is no longer being supported.

Library Tutorial

This is an informal introduction to using the native API. It assumes that you more or less know how to program in MiniD.

  • Introduction - An overview of the basic concepts used throughout the native API.
  • Part 1 - Setting up the host app and compiling and running code.
  • Part 2 - Exchanging basic values between native and script code.
  • Part 3 - Calling things from native code, creating closures, and handling errors.
  • Part 4 - Making a native class object.
  • Part 5 - Using coroutines.
  • Part 6? - Making a native module.
  • Part 7? - Using the binding library.

Try it out!

The MiniD distribution comes with a command-line interpreter called MDCL. MDCL can be run in interactive mode (type the code in and it's run immediately), or it can be just run to execute a script file. Because MiniD allows for the Unix-style shebang (#!) at the beginning of scripts, you can use MDCL as the scripting host for MiniD scripts (by putting "#!/path/to/mdcl" as the first line).

Both Windows and Linux users can download the Windows EXE of MDCL here. mdcl.exe works pretty well under Wine in Linux, for Linux users who want to try out the language right away. Otherwise you can check out the MiniD source and compile it yourself.

Other Downloads

Here are some syntax highlighters for code editors:

  • MiniD 1/2 Highlighter for vim. Installation: copy the file to ~/.vim/syntax (if those dirs don't exist, create them). Then in ~/.vim/filetype.vim (again, if it doesn't exist, create it), add:
    augroup filetypedetect
    au BufNewFile,BufRead *.md setf minid
    augroup END
    
  • MiniD 1 Highlighter for gedit. Installation: copy the file to /usr/share/gtksourceview-2.0/language-specs/ as root to use it. Gedit must be restarted for the change to take effect. Then, the MiniD option will appear under View > Highlight Mode > Scripts. It has to be manually selected because Gedit wants to determine highlight according to "mimetype" instead of file extension, it seems.
  • MiniD 1 Highlighter for ConTEXT. Installation: place in \YourConTEXTDir\Highlighters and restart ConTEXT. It is registered with the .md extension.
  • MiniD 2 Highlighter for ConTEXT. Same installation as above. Note that if you have both the v1 and v2 highlighters installed, opening an .md file will cause ConTEXT to default to the v1 highlighter.