<wrapper> How to Move Library Language Bugs Try it ↑ </wrapper>
<wrapper>
Here is a simple Move program which outputs “Hello John” three times:

    hello = ^(name){ "Hello "+name }
    repeat {times: 3} ^{
      print hello {name: "John"}
    }

v0.0.0

Use move.js or get the source from github.com/rsms/move

Special versions of the library:

- move-rt.js — runtime only
- move-debug.js — human-readable
- move-rt-debug.js — runtime only, human-readable

## Learn how to Move

Move has been designed with humans in mind and is very suitable as a first programming language. Learn how to Move and you will be able to write rich websites, server programs, etc -- Move runs everywhere and it's fun!

Get started with "How to Move" →

## Features & Highlights

- Simplistic with few types
- Functions are first class and light-weight
- Normalized environment means you don’t have to feature-test
- Compiles to optimized, strict JavaScript

For a more complete list of features and differences compared to JavaScript, see README.md →

## Usage

Move can run in web browsers and “interpreters” like Node.js. Move has been designed so that your code can be run in web browsers and “interpreters” without any changes – your code is always running in an ES5 environment with a CommonJS module system.

Jump to:

- Using Move in web browsers
- Using Move in Node.js
- Using Move from the command line

### Using Move in web browsers

To run Move in a web browser, you simply include move.js:

    <script src="http://movelang.org/move.js"></script>

Move code can then be embedded, which will execute directly after the DOM has loaded:

    <script type="text/move">
    print 'Hello worlds!'
    </script>

If you specify the `module` attribute, the code defines a module rather than execute the code:

    <script type="text/move" module="foo">
    export sayHello = ^{ print 'Hello worlds!' }
    </script>

It’s then possible to `import` that module from other code:

    <script type="text/move">
    import foo
    foo.sayHello()
    </script>

Modules can also be remotely imported:

    <script type="text/move" src="foo.mv"></script>

You don’t have to care about the order in which you define your modules. The only thing you need to think about is where you execute embedded code.

#### Complete example

    <script src="http://movelang.org/move.js"></script>
    <script type="text/move" module="bar">
    import foo, capitalize
    export sayHello = ^(name) {
      print foo.makeHello capitalize name
    }
    </script>
    <script type="text/move" src="capitalize.mv"></script>
    <script type="text/move" module="foo">
    export makeHello = ^(name) { 'Hello '+name+'!' }
    </script>
    <script type="text/move">
    import bar
    bar.sayHello 'worlds'
    </script>

When the DOM loads, “Hello Worlds!” is printed to the console.

The Move module itself is available as the global variable `Move` (technically a property of `window`). This module provides access to preprocessors, the parser & compiler and version info. It also houses the Move runtime library (`Move.runtime`) which can be manipulated. An example of evaluating some Move code: `“function () { return print("Hello”); }“`

    Move.eval '^{ print "Hello" }'

This is available in both Move-land and JavaScript-land:

    Move.eval('^{ print "Hello" }');

### Using Move in Node.js

First up; install Move through NPM:

    npm install move

Then, `require('move');` and simply write any module you wish in Move and name the file with a “.mv” extension. From there everything behaves as normal in Node.js (e.g. defining a foo.mv module and later doing `var foo = require('foo');` works as expected).

To run Move code directly from the command line, use the `move` program:

    move hello.mv

Note that you can not load Move code directly through `node` since Node has no knowledge about how to compile Move code. The `move` program simply registers the Move compiler with Node’s module loading system and then loads your module.

### Using Move from the command line

When you install move for Node.js, you will have access to a `move` command line client program.

To see a list of available commands, run `move --help`:

    $ move --help
    Usage: move [global options] <command> [command arguments ..]
           move [global options] <filename>
    Global options:
      --help, -h       Show this help message.
    Commands:
      build            Build a Move web app.
      build-weblib     Build the Move library for web browsers
      compile          Parse and compile Move code.
      run              Run a Move program.
      version          Print version and exit.
      help             Display help for a command.

To show help for a specific command, run `move command --help`:

    $ move run --help
    Usage: move run [options] <filename> [..]
    Options:
      --optimization-level, -O <i>       Optimization level. Defaults to 0 (basic).
      --help, -h                         Show this message

Execute a move program:

    move foo/bar.mv
    move run foo/bar.mv

Compile move code to JavaScript:

    move compile foo/bar.mv
    move compile --output foo/bar.js foo/bar.mv

The compile command can do a lot more than just compiling Move code. One of the most useful features is the ability to “bundle” a source tree of Move and JavaScript into a name-spaced (CommonJS modules), single JavaScript file. Imagine the following source tree:

    main.mv
    lib/bar.js
    lib/scrap.txt
    src/index.mv
    src/foo.mv
    src/cat/index.mv
    src/cat/zelda.js

Now, we’ll bundle these files:

    move compile --bundle --output bundle.js --basedir src main.mv src lib/*.js

Which will write something like this to `bundle.js`:

    Move.require.define("main","main.mv",function(require,module,exports) {
      // code generated from main.mv
    });
    Move.require.define("lib/bar","lib/bar.js",function(require,module,exports) {
      // code generated from lib/bar.js
    });
    Move.require.define("","src/index.mv",function(require,module,exports) {
      // code generated from src/index.mv
    });
    Move.require.define("foo","src/foo.mv",function(require,module,exports) {
      // code generated from src/foo.mv
    });
    Move.require.define("cat","src/cat/index.mv",function(require,module,exports) {
      // code generated from src/cat/index.mv
    });
    Move.require.define("cat/zelda","src/cat/zelda.js",function(require,module,exports) {
      // code generated from src/cat/zelda.js
    });
    (function(){
      // code that executes the "" module when the DOM is ready
    })();

The generated file can now be imported into a document and run with the support of the runtime library:

    <head>
      <script src="http://movelang.org/move-rt.js"></script>
      <script src="bundle.js"></script>
      ...

</wrapper>