Preface

I like to build Internet Computer canisters without the use of artificial additives such as Motoko, Rust devkit, NPM, agent-js, and so on. I craft them from all-natural ingredients using traditional methods: the C compiler and the linker from a recent vintage of the LLVM project:

$ apt-get install clang lld

Why? While Motoko and friends are all great tools, staying close to the metal has benefits:

  • We gain a thorough understanding of the Internet Computer. Nothing is hidden in layers of wrappers.

  • Our apps run more efficiently, so cost fewer cycles.

  • We are free of any limits imposed by various tools. Our only limits are those of the IC itself.

  • We can design and implement our own high-level languages and tools.

Think of console game developers who pull out all the stops to squeeze as much as they can from a platform. An inspiring example is Crash Bandicoot on the Sony PlayStation.

Forgoing high-level tools may in fact be the best strategy for certain applications: visit the websites for tools and libraries geared for the Internet Computer. Why aren’t they themselves hosted on the Internet Computer? In contrast, we’ll see how easy it is to build the canister that you’re reading right now!

DFX

While it’s possible to build canisters solely with LLVM, we must install dfx to test them:

$ sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

Git Repo

This guide resides in a git repo:

$ git clone https://fxa77-fiaaa-aaaae-aaana-cai.raw.ic0.app/organic.git
$ cd organic

The simplest canisters can be built right away:

$ make hello.wasm

Others require one of my Haskell compilers, which is a submodule:

$ git submodule init
$ git submodule update
$ cd compiler
$ make precisely
$ cd ..

Then:

$ make counter.wasm

Some binaries depend on a modified version of Miracl:

$ sudo apt install llvm  # for llvm-ar
$ ./mkcore
$ make mock.wasm

The HTML files require AsciiDoc and GHC:

$ ghc public.hs
$ make

Ben Lynn 💡