Motoko

Motoko - what?

I know, I know, there are many programming languages around and steadily more being created. So why would I write about yet another one? Because even though Motoko really is shiny and brand new, it not only offers some interesting aspects to learn about but also comes with a complete cloud infrastructure behind it to amplify its growth. Curious? Next chapter, please!

A new one for the modern web

Here’s the mission briefing: Motoko is a completely new programming language (that is, no transpiling á la Typescript to Javascript) that gets compiled to WASM but looks and feels in large parts very familiar if you’ve ever used Javascript. If you don’t know, WASM stands for Web Assembly that can be used as a compilation target if a giving language supports it. Famous examples are C, C++ and Rust. Motoko uses Garbage Collection and its compiler is written in OCaml (yes, yet another language). Motoko can either be used as your generic programming language of choice for every platform that supports WASM, which are not only browsers but embedded systems and IoT as well - that’s important to note and we’ll come back to it in a minute, but also specifically the Internet Computer, more on that later, too.

Motoko uses a strong type system and was created with complete asynchrony in mind. Its architecture is built around the concept of Actors. Sounds familiar? Probably not, but if you’re craving for a really great rabbit hole, try searching for the Telescript language, something far ahead of its time. Links are available at the end of this blog entry, too. Discussing Actors is out of the text’s scope, but here’s a brief introduction: Actors look and behave very similar to classes in OOP, but they’re enhanced with the ability to send messages to other Actors. Each Actor uses a queue to automatically manage the ordering and processing of incoming messages.

Similar to ES6+’s Promises, Motoko uses Futures to represent the results of each Actor’s operations. The usage of Futures therefore allows sending messages concurrently, as the result can come at any later point in time after the operation has been called.

Dfinity and the Internet Computer

Remember when I promised to talk more about the usage of Motoko in embedded systems and IoT? Here we go: Motoko was developed by a foundation called Dfinity, which offers a solution for decentralized applications in the modern web called Internet Computer. The idea is to move the current web stack away from proprietary salutations (AWS, GCP, etc) to an “open” platform, a decentralized governance system defined in its protocol. Its architecture enables multiple computers to operate like one, very powerful, virtual machine.

Wrapping up

That’s about it for a quick overview of Motoko, a new programming language with some interesting features like Actors. To try it out, you need to install Dfinity’s Canister SDK. The whole project is still very young, but worth checking out - even if you just want to stay on the edge of the web.

- Tom


expressFlow is now Lean-Forge