MoonScript is a language that compiles to Lua, offering a more programmer-friendly syntax while targeting the fastest scripting language runtime.
The tool addresses the verbosity and syntactic friction of writing Lua directly. MoonScript compiles to Lua code, allowing developers to write in a higher-level language while retaining access to Lua's performance and ecosystem. The compiler itself is self-hosted, written in MoonScript and compiled to both C and Lua, ensuring it can bootstrap consistently. The parser uses a parsing expression grammar defined in a separate tool and generates both a native C module for performance and a pure Lua equivalent for portability.
MoonScript suits developers already committed to Lua who want cleaner syntax without sacrificing runtime performance or compatibility. It runs on Lua 5.1 and above, including LuaJIT, making it compatible with existing Lua environments. The project provides an online compiler for experimentation and editor support across Vim, Emacs, Sublime, and Textadept. Precompiled binaries are available for Windows, and installation via LuaRocks is supported for those wanting a separate working version alongside development.
The project maintains both source and generated files in the repository to allow users to install and use MoonScript without compilation while preserving the bootstrapping process. The parser grammar is regenerated from its specification using an external tool, with both C and Lua outputs checked in. Tests are written in MoonScript itself using Busted, creating a self-referential development environment where the compiler must work to verify itself. The project hosts a community Discord and provides detailed contribution guidelines emphasizing that only source `.moon` files should be edited directly, with generated `.lua` files updated through the build process.