Ethereum + Swarm + λ = Moon, a universal code-interchange format

I just published the first version of moon-lang. I’ve still not written a proper introduction to it, but, before I do, I’ll talk a little bit about one of its coolest features: decentralized imports.

Moon doesn’t have a “package manager” like most languages, and Moon apps aren’t meant to be hosted in normal servers. Instead, whenever you want to publish a library, program or application, you use the Ethereum/Swarm network. Here is how it works:

You create a cool program and name it coolProgram.moon . You go to the terminal and type moon publish coolProgram.moon . The source of coolProgram is sent to Swarm, a decentralized storage. Tha SwarmHash is registered on Ethereum using the coolProgram name. Someone attempts to use coolProgram inside their own Moon code. Moon follows the reverse path and recovers your source code. …? Decentralized imports!

This is cool for many reasons. Not only it allows people to share code and apps as frictionless as ever, but it also gives those codes/apps the same great properties of decentralized networks. If coolProgram is, for example, a web-application, people will immediately be able to access it on DApp browsers such as Mist. No need to worry about hosting costs, DDOS attacks, censure and so on: as long as there are people using coolProgram , it will be kept alive on the network!

Example

Suppose you've written a Moon program that computes someone's Body Mass Index. You name it personBMI.moon:

(Don't mind the syntax for now, that is still being thought.)

Now you’re very proud of your creation and wants the world to see it, but you know nothing about hosting. No worries, Moon is here for you. But, first, you need to check if your CLI has Ether:

If its balance is zero, don’t worry. Publishing is very cheap, so you can just ask a friend to send a few cents to your CLI’s address:

Once you have it, you can publish your code with moon publish :

You’ll see a few hacky messages detailing the process:

And done! Now, anyone else in the world can use personBMI by either referencing it inside a Moon program, or by calling it directly on the terminal:

Now, suppose a friend has just called you to ask if he is overweight. You could be downright honest about it… or you could write a (terminal) DApp for that!

Save it as whatsMyBMI.moon and type moon publish whatMyBMI . Now you can just tell him to ask Moon directly:

Your (terminal) DApp will be resolved on Ethereum, downloaded from Swarm and then run on your friend's console. Cool, isn't it? Try running it!