Skip to main content
Back

Motoko update February 6, 2023

by Kento Sugama

Header image

Hi Motoko devs!

Welcome to the latest Motoko update post. Note that we will be making these posts on a biweekly schedule going forward.

If you missed the last update post from the Motoko team, check it out here! Last time we talked about ongoing efforts with improving package management in the Motoko ecosystem, and a review of code blocks as a language feature.

Today we’ll be talking about a new language feature that lets you catch send errors, and a beta release of Candid! Bonus section about a podcast on designing languages for smart contract development.

Catch your errors from message sends: Motoko 0.8.0!

Last week, we released a new version of Motoko, including a new language feature that lets you catch message send failures.

Previously, when you sent a canister message that failed, your program would trap without giving you a chance to recover from the failure. These failures can happen from a lack of canister resources, typically because the incoming message queue for the destination canister is full, or because the calling canister does not have enough cycles to pay for the call. (There are a few more cases where such an error can occur: see details here).

Instead of trapping, these errors are now thrown as an Error! Specifically, they are thrown with new ErrorCode #call_error { err_code = n }, where n is the error code returned.

Thus, these errors can be caught and handled with try catch expressions, letting you recover or gracefully fail from these messages as you see fit!

New Candid: Beta release

The languages team also just released a new beta release for Candid! Shoutout to @chenyan for taking point on this project.

The new version contains several new features, including some breaking changes:

First, Candid now lets you decode optional variant types, even if the variant tags are not the same, allowing upgrading variant types without breaking the client code.

The deserializer also now only performs subtype checks for reference types, which brings it into full conformity to Candid spec 1.4. The same spec is also implemented in Motoko version 0.8.0, which we released last week.

For any Rust developers out there, the Rust Candid implementation also included major improvements, including major optimizations in deserialization time and canister binary size.

The beta release is up on crates.io. Please let us know of any bugs you come across before the full release!

Bonus: a16z Podcast - smart contract language design

Last week, there was a podcast episode released by Andreessen Horowitz about designing languages to write smart contracts: a very relevant topic for this audience!

You can find it here: https://open.spotify.com/episode/20pTy6Y344MKNySYJZov27

The episode talks about the differences in challenges between Web2 and Web3 programming, and how to design languages that accommodate those differences. Personally, I found it insightful so I thought I’d share it here :) Shoutout to @diegop for sharing this podcast with our team.

Till next time!

– DFINITY Languages team