A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Hello World in Moonscript page! Here, you'll find the source code for this program as well as a description of how the program works.
print "Hello, World!"
Hello World in Moonscript was written by:
This article was written by:
If you see anything you'd like to change or update, please consider contributing.
Hello World in MoonScript has a relatively simple implementation.
All we have to do is call the built-in Moonscript function print
, and that's it.
Behind the scenes, the code is compiled into Lua which is, in this case,
exactly the same.
In other cases, it could be different. For instance, we could have an implementation of some arithmetic which we print to the user:
x = 10
y = 15
z = x + y
print y
The code is then compiled into Lua like this:
local x = 10
local y = 15
local z = x + y
return print(y)
How cool is that?
If your feeling adventurous today, You can quickly install MoonScript using one of the following methods:
For Windows users, you can try installing the windows binaries.
For Linux users, install LuaRocks which is a package manager for Lua modules. Then run the following command:
luarocks install moonscript
With the moon executable and Lua modules on your device, run your .moon file with this command:
moon ./YOURFILE.moon
Also, you can compile your .moon file into Lua by using this command:
moonc ./YOURFILE.moon
Alternatively, you can always run MoonScript using an online compiler.