A Glimpse into Motoko and AgorApp embeddable IDE

Riccardo Biosas
The Internet Computer Review
6 min readJun 23, 2023

Curious how to get started with building on the Internet Computer? In this article, we will review some of the reasons why Motoko came to be, its trade-offs compared to the alternative ICP smart contract languages and, finally, how to dive into the syntax of Motoko right away on AgorApp — the go-to online interactive coding platform.

Introduction to Domain-Specific Languages

The landscape of domain-specific languages (DSL) specifically dedicated to smart contract development is growing. The reasons why the blockchain ecosystem has fueled the research and development of so many new domain-specific languages are plentiful.

A DSL offers many attractive features and trade-offs, especially in the context of Blockchain systems — where financial assets are a first-class citizen and, subsequently, the need for security and correctness is paramount.

However, let’s first define what a DSL is: a domain-specific language is a programming language that is designed to address very specific problems, platforms or domains. While languages like Javascript, Python and Golang are general-purpose and can seamlessly be used for almost anything, the design of a DSL is tightly coupled with the domain and challenges it is meant to be used for. The domain-specific design allows to achieve several benefits, such as:

  • Enhanced security: by narrowing their scope, domain-specific languages can more easily integrate compile-time checks, safe type-systems and various forms of runtime protection and formal verification.
  • Enhanced developer experience: similarly to the previous point, the narrow scope of DSLs allows to create abstractions and built-in that provide first-class access to the domain-specific features and functionalities.
  • Enhanced performance: lastly, the highly specialized nature of DSLs allows to fine-tune the language for specific tasks in order to achieve better performance than its general-purpose counterparts.

The domain-specific language of choice in the Internet Computer ecosystem is Motoko.

Motoko is a statically typed language that compiles into WebAssembly. Its design leans towards the functional paradigm, but it equally emphasizes ease of use and smooth developer experience.

Some of its language features like pattern matching might already be familiar to those who played around with languages like Haskell, nevertheless the overall syntax is much more approachable than its functional counterparts.

The other main smart contract language in the Internet Computer landscape is Rust: unlike Motoko, Rust is obviously a general-purpose language.

Building on the Internet Computer is a decidedly different experience compared to developing on Ethereum. While the Ethereum’s EVM is a sandboxed deterministic execution environment, the ICP architecture is made of canisters — computational units that execute code and store data — which can host full-fledged web-applications, make outbound HTTP requests and so on.

In the context of ICP app development, Motoko offers some notable advantages over Rust. In this article we will go through them and you will also get to practice some Motoko right away on the AgorApp embeddable IDE.

But first, an interesting tidbit for all the cyberpunk and anime enthusiasts out there: the name Motoko is likely a reference to the main character of the Ghost in the Shell series, Motoko Kusanagi — highly recommended if you haven’t watched it yet!

Comparison between Rust and Motoko

The design of the Motoko programming language was tailored to easing up the asynchronous communication between different entities on the Internet Computer network.

The model upon which the Internet Computer is built is that of a distributed network of memory-isolated entities that communicate asynchronously with each other. These asynchronous messages use a lingua franca called Candid.
Candid is a language-agnostic interface description language (IDL) that allows different services to interface with each other without worrying about their respective implementation details — i.e.: a frontend is written in Typescript, another service is written in Golang and an ICP application is written in Motoko.

Now, asynchronous communication in a distributed system is a notoriously daunting engineering arena. As such, the Motoko language was designed using the Actor model, which is a computational framework/paradigm that allows to easily reason about different entities in a distributed asynchronous setting.
The main actor entity on the Internet Computer is the canister.

A canister is a memory-isolated entity that holds both compiled code and storage.

After being compiled into WebAssembly bytecode, Motoko programs are deployed to canisters, which then act as computational units that can be invoked by other canisters or by users via the Internet Computer’s IC SDK.

If you want to start dipping your toes into the Actor model and Motoko’s language features, you can check out the Learn Motoko course — it is geared towards beginners, but the last lesson Introduction to Actors touches upon the very concept.
Stay tuned and subscribe to the mailing list to be the first to know when we will roll out more advanced courses!

As powerful as Rust is, it is not designed with the Actor model and the ICP architecture in mind: Motoko provides native support for Candid, a strong type system which statically ensures the absence of dynamic type errors and, lastly, more intuitive abstractions for inter-canister communication.

Enough benchmarks for now, we will revisit the topic in a future article. Let’s jump right into the IDE.

Your First Motoko Coding Challenge & AgorApp embeddable editor

Want to try out your first Motoko coding challenge in our embeddable editor? Then click here to check the original blog article!

In the upcoming weeks, we will gradually roll out our web3 embeddable editor feature to various platforms (maybe medium? reach out to tell us which platforms you’d like us to support!) and partners — such as bootcamps, DeFi/blockchain protocols that want make their technical documentation interactive and selected content creators. Then, after the end of the triage, it will be made available to all our users.

if you are a tech/web3 content creator — Udemy, Youtube, blogger- and you’d be interested in integrating our embeddable IDE in your coding tutorials or creating a custom IDE instance for your audience so that they can better follow along your video courses, we’d love to hear from you. Our goal is to provide new ways with which you can engage your audience with the technical content you are creating.

You can contact us on AgorApp Discord or just touch base with us on Twitter or Linkedin.

About AgorApp

AgorApp is an online interactive coding platform that offers courses and challenges focused on all-things-web3 engineering: from web3 domain-specific languages to building on top of DeFi and NFT protocols, solving smart contract auditing challenges in a browser-based IDE or participating to gas golfing competitions.

With DFINITY and ICP, our core mission is to onboard the next wave of engineers into the developer ecosystem: from fast-tracking their programming training in Motoko and understanding of the ICP architecture to immediately recommending our users opportunities to monetize their newly learned ICP development skills right off the bat with grants and available job openings available in the Internet Computer ecosystem via our workspace dashboard.

Would you like to dig deeper into the product we are building at AgorApp? Check out our introduction article and sign up to the blog mailing list to not miss our next technical deep dives into smart contract engineering, Motoko, Internet Computer development & get notified about fresh job and grant opportunities before everyone else.

--

--

Riccardo Biosas
The Internet Computer Review

Principal Security Engineer @Procore | Founder @AgorApp | prev. Protocol Engineer@LivepeerOrg & Fullstack/Lead Smart Contract Dev @Opium_Network