←  Suggestions

ComputerCraft | Programmable Computers for Minecraft

»

MoonScript

toxicwolf's Photo toxicwolf 16 Oct 2012

So I've been playing around with the MoonScript online compiler for a couple of days now, and have really taken a liking to the language.
The best thing obviously is that it compiles into Lua.

As far as I can tell, there needs to be some modifications to CC to allow MoonScript to be added, which I believe are only possible Java-side (such as adding the LPeg module which MoonScript relies on).

It would be nice to have MoonScript in CC alongside Lua, so files with the .moon extension could be run with the moonscript compiler etc.
This could mean that there would be two compiler programs in CraftOS - type 'lua' to access the Lua compiler as normal, and type 'moon' to access the MoonScript compiler.

Overall, I think MoonScript is a nice 'addon' language for Lua as it merges the speed and simplicity of Lua with extra functions such as the ability to do OOP easily via classes, extra keywords/operators (switch statements, with, etc.) and the fact that some keywords like end's and then's can be omitted as the language is more indentation and whitespace aware.
Yes, some of the syntax is different so it may take some getting used to, but I think that it can be picked up by beginners just as quickly as Lua. It is also compatible with existing Lua libraries/functions/APIs etc.

Tell me what you think, because I would really love this to happen :D/>
Quote

Tiin57's Photo Tiin57 16 Oct 2012

I second this. Excellent idea!
Quote

toxicwolf's Photo toxicwolf 16 Oct 2012

View Posttiin57, on 16 October 2012 - 08:07 PM, said:

I second this. Excellent idea!
Thanks :D/> Another thing that I like is that programs can often be written better and/or in quite a few less lines than Lua itself, due to both it's syntax omittance and extra features. I suggest having a quick read through the MoonScript reference guide, it highlights some key features that are advantages over Lua.

EDIT: The creator of MoonScript replied to me on Twitter, and it seems that the only major hurdle to implementing MoonScript purely in Lua is the lpeg module. It is probably possible though (albeit by someone more experienced than me) https://twitter.com/...307515706662913
Edited by toxicwolf, 16 October 2012 - 09:15 PM.
Quote

Cloudy's Photo Cloudy 16 Oct 2012

Sorry, not gonna happen. We aren't going to implement lpeg into ComputerCraft - would require rewriting it into Java or Lua - neither of which I have any interest in.

I also think it would be confusing having two languages in the mod. If you want to write a Lua version of lpeg though be my guest :D/>
Quote

toxicwolf's Photo toxicwolf 17 Oct 2012

View PostCloudy, on 16 October 2012 - 11:35 PM, said:

Sorry, not gonna happen. We aren't going to implement lpeg into ComputerCraft - would require rewriting it into Java or Lua - neither of which I have any interest in.

I also think it would be confusing having two languages in the mod. If you want to write a Lua version of lpeg though be my guest :D/>
As much as this saddens me, I completely understand :P/> Well now I have the challenge of trying to learn how to write lpeg in Lua.
Quote

Tiin57's Photo Tiin57 17 Oct 2012

I might make a peripheral using this... Problem is that, while I'm decent with Java, I stink at Forge.
Edit: Cloudy, why don't you have an avatar on the forums? :D/>
Quote

Cranium's Photo Cranium 17 Oct 2012

View Posttiin57, on 17 October 2012 - 11:00 AM, said:

I might make a peripheral using this... Problem is that, while I'm decent with Java, I stink at Forge.
Edit: Cloudy, why don't you have an avatar on the forums? :D/>
He's too cool for avatars.
Quote