Stopwatch - Moonscript Typing CST Test
Loading…
Stopwatch — Moonscript Code
Simulates a stopwatch with start, stop, and reset functionality.
time = 0
running = false
updateUI = ->
print "Stopwatch: #{time} seconds"
start = ->
running = true
print 'Stopwatch started'
stop = ->
running = false
print 'Stopwatch stopped'
reset = ->
time = 0
updateUI!
# Simulate actions
updateUI!
start!
time += 5
updateUI!
stop!
reset!Moonscript Language Guide
MoonScript is a high-level, dynamic programming language that compiles to Lua. It provides syntactic sugar, cleaner syntax, and modern language features like classes, comprehensions, and pattern matching, while maintaining full compatibility with Lua runtime.
Primary Use Cases
- ▸Scripting for games (Love2D, Roblox)
- ▸Writing concise Lua programs
- ▸Rapid prototyping in Lua environments
- ▸Embedding in applications with Lua runtime
- ▸Creating libraries compatible with Lua
Notable Features
- ▸Class-based object system
- ▸Function comprehensions and expressions
- ▸Destructuring assignments
- ▸Cleaner control flow syntax
- ▸Direct interop with Lua code
Origin & Creator
Created by Leaf Corcoran in 2012 as a way to make Lua programming more ergonomic and expressive.
Industrial Note
MoonScript is used in gaming, embedded scripting, and applications where Lua is standard but developers want a more modern syntax and workflow.