MoonScript

Posted by Twisol on Thu 18 Aug 2011 01:05 AM — 4 posts, 18,373 views.

USA #0
I found this compiles-to-Lua language recently called MoonScript [1], which is inspired by CoffeeScript [2]. I thought it would be pretty interesting to get it to work with MUSHclient, and it's really easy. If you just throw the "moonscript" directory from the project into MUSHclient/lua/, you can require("moonscript") from your script file or plugin and it'll make ".moon" versions of the package.path paths. Then you can require("foo") and if there's a foo.moon in scope it'll compile it to Lua on the fly. So it's extremely easy to use.

I figured I'd mention it here in case someone else wants to try it out. It might be nice to see MUSHclient ship with Moonscript one day, since it's not that large. Its only relevant dependency is lpeg, which we already have.


[1]: http://moonscript.org/
[2]: http://jashkenas.github.com/coffee-script/
USA Global Moderator #1
I've been following the MoonScript announcements on the lua-l mailing list, and I have to say I'm completely turned off by any language that cares significantly about white space. It's one of the aspects of Python that I'd remove if given the chance to beat the designers into submission.
Amended on Thu 18 Aug 2011 03:25 AM by Fiendish
USA #2
I tend to agree, but it -is- nice to have a slightly higher-level dialect of Lua. My only real gripe at this point is the choice of \ where normal Lua uses : .

As an aside: while the examples use module(), it's possible and easy to go for a straight return-this-table sort of module.

add = (a, b) -> a + b
subtract = (a, b) -> a - b

return {
  add: add,
  subtract: subtract
}


It's arguably even easier in MoonScript because everything's local by default. While this method ignores 'export', it was still useful for defining plugin callbacks in the global space.
Australia Forum Administrator #3
Your suggestion is noted, although I too am not a great fan of languages that depend on whitespace (eg. Make files are an example, which distinguish between tabs and spaces, which makes it hard to show them on a web page).