Important

The DFINITY Canister SDK is alpha software from our final development branch that will make it into production. Please be aware that at this time it is less developed than previously-demonstrated prototypes and you should check back regularly to try new features.

Until the production release of the SDK, the Motoko language is under constant development and all features are subject to final security review.

Enjoy!

Building next generation software

The DFINITY Canister SDK can be used to create software systems and services that run on the Internet Computer. Over time, many different SDKs targeting canister development will be created by different organizations. The Motoko programming language being developed by DFINITY is designed to support the Internet Computer and to provide a productive and robust platform for developers building next generation systems. The Motoko compiler and language will soon become open source. Rust support for the Internet Computer is also in the works and coming soon.

For more information, see the Motoko and SDK documentation:

Programming language highlights

The Motoko programming language is a modern, type-sound language designed for developers who want to build the next generation of systems and services to run directly on the internet.

Native canister support

actor Counter {
  var value = 0;
  public func inc() : async Nat {
    value += 1;
    return value;
  };
}

Motoko has native support for Internet Computer software canisters, which are expressed as actors, autonomous objects that encapsulate their state and communicate through asynchronous messages.

Code sequentially in direct style

actor Factorial {
  var last = 1;
  public func next() : async Nat {
    last *= (await Counter.inc());
    return last;
  }
}

On the Internet Computer, software canisters call into other canisters asynchronously, but Motoko enables you to program your systems sequentially in direct style. Asynchronous messages are function calls that return a future, and the await constructs allows chaining calls as if they were synchronous.

Modern type system

type Tree<T> = {
  #leaf : T;
  #branch : {left : Tree<T>; right : Tree<T>};
};

func iterTree<T>(tree : Tree<T>, f : T -> ()) {
  switch (tree) {
    case (#leaf(x)) { f(x) };
    case (#branch{left; right}) {
      iterTree<T>(left, f);
      iterTree<T>(right, f);
    };
  }
}

Motoko has been designed to be intuitive to those familiar with Javascript and other popular languages, but offers modern features such as sound structural types, generics, variant types, and checked pattern matching.

Autogenerated IDL files

service Counter : {
  inc : () -> (nat);
  reset : () -> ();
}

The SDK exports your interface definition, so other canisters, browser resident code and smart phone apps that have permission can call into your functions. The Motoko compiler can also read and write interface definition files, allowing Motoko to seamlessly interact with canisters programmed in other languages.

Orthogonal persistence

import Dict = "mo:dict";

actor Registry {
  type Id = Nat64;
  let dict = Dict<Id>();
  public func register(name : Text, id : Id) {
    dict.insert<Id>(name, id);
  };
  public func lookup(name : Text, id : Id) : async ?Id {
    dict.lookup<Id>(name);
  };
}

The Internet Computer persists the memory pages in which your canister runs. Thus the state of an actor and all its memory data structures survive indefinitely, they do not need to be “saved” explicitly. Motoko provides numerous features to help you leverage this environment, including language features that allow your heap to self-migrate when you upgrade the software of a canister.

Motoko provides many other cool features, including deep support for WebAssembly that allows modules written in other languages to be linked into your canisters. We are also working on adding Rust support to the SDK.

Learn more and check for updates

Both Motoko and the DFINITY Canister SDK are in development and constantly evolving. Keep checking back for updates to the code and documentation.