MoonCake Script

A Swift like programming language that compiles to Lua

Github   Gitee


MoonCake Script, short in moocscript, is a swift like program language that compiles into Lua. For it's a pure Lua transpiler solution, so it support any environment that Lua support.

If you are using from command line, please visit lalawue/mooncake for more information.

Here examples live in browser, depends on Fengari, a Lua VM written in JavaScript. Other Lua VM requires some modification to the loader.


Try some language highlight?

You can change these examples's content, all running in your browser !

example 1: guard / continue / switch moocscript

example 2: defer moocscript

example 3: class/struct/extension moocscript

Here comes Fengari's examples, but in moocscript language, renders any interaction with JavaScript and the DOM transparent:

example 4: window.alert() moocscript version moocscript

example 5: change html tag innerHTML with document.title moocscript

example 5: coroutine moocscript

Try with REPL!

This REPL is stolen from Fengari's web-cli.lua, then modified to moocscript's web-cli.mooc.

Getting started

1. first download fengari and moocscript-web:

$ curl -L -O
$ curl -L -O

2. then you can include in you webpage

<script src="fengari-web.js"></script>
<script src="moocscript-web.js"></script>

3. now any script of type "application/mooc" will be running by moocscript-web.js

<script src="/mooc/hello.mooc" type="application/mooc"></script>

<script type="application/mooc">
    import Core from "moocscript.core"
    import Window from "js" { global }
    Window:alert("moocscript version is \(Core.version())")


Compiled Lua