Description #
MoonScript is a dynamic scripting language that compiles to Lua, offering cleaner syntax, object orientation, and functional programming features to Lua developers.
History #
MoonScript was created by Leah Neukirchen and released in 2011 to modernize Lua development. It simplifies Lua syntax while retaining full compatibility with the Lua ecosystem.
Hello World Code #
print "Hello, World!"
How to Run #
Option 1: Online
https://moonscript.org/compiler/
Option 2: Local
Install via LuaRocks:
luarocks install moonscript
Save as hello.moon
and run:
moon hello.moon
Key Concepts #
- Compiles to Lua
- Indentation-based syntax
- Supports classes and comprehensions
- Dynamically typed and interpreted
- Fully interoperable with Lua
- Lightweight and embeddable
- Functional programming friendly
- Syntactic sugar for cleaner code
- Used in game development and scripting
- REPL available via
moon
CLI
Try It Online #
https://moonscript.org/compiler
Fun Facts #
- MoonScript’s syntax is often compared to CoffeeScript but targets Lua instead of JavaScript.
- It’s used in projects like LÖVE (a popular 2D game engine).
- MoonScript supports class-based syntax even though Lua doesn’t natively.