Hacker News new | ask | show | jobs
by leafo 2325 days ago
My strategy is typically store MoonScript in separate files, then have build process that generates Lua and bundles that inside of whatever else. I wouldn't typically put it in a C file, but I might have the build system generate a hex encoded string as a header file. (This is actually how I build the MoonScript source into a single exe for Windows builds)

I recommend doing the MoonScript compile time at program build time to avoid any unnecessary compilation during runtime.

1 comments

Thanks. I wonder if this would be any different if the VM executed MoonScript code directly, rather than first requiring translation to Lua.

I’ve been thinking about the syntax of an embeddable language myself, and have ruled out significant indentation because of the difficulty of writing such code inline inside C files. If that’s not a common use case, maybe I should reconsider...

There is no MoonScript VM, if you use the "execute moonscript" function provided by the moonscript library it internally compiles the moon code to lua, loads the lua code, then runs the lua code.

This means that MoonScript compiled ahead of time will have the same exact result as running it on the fly.