pulumi/docs/design/mujs.md
joeduffy 037f117303 Start a MuJS design document
This is admittedly very light at the moment, however, I had it on my
enlistment and want to checkpoint *something*, however minimal it is.
2017-01-17 11:42:49 -08:00

989 B

Mu JavaScript (MuJS)

MuJS is a superset of a JavaScript (ECMAScript) subset. First, take a subset of JavaScript, and then superset it with optional typing annotations (using TypeScript's syntax and semantics for them).

Modules

MuJS uses ES6-style modules.

An ES6 module is a special kind of script, which is just a file containing a list of top-level statements. MuIL modules have a bit more structure to them to facilitate analysis and determinism. As a result, there is a mapping from MuJS to MuIL module structure.

The mapping simply records all declarations -- variables and functions -- and then moves all other statements into the special module initializer (.init) function. In the case of blueprints, the special entrypoint function .main is devoid of logic, because in Node.js-style of programming, the module initializer takes care of entrypoint functionality.

TODO: document more