Skip to main content

0.4 Introduction to languages

Beginner
Tutorial

Many different programming languages can be used for canister development. However, a canister development kit (CDK) needs to be used. A CDK provides a programming language with the necessary features and tools required to create and manage canisters. The IC SDK natively supports the Motoko and Rust CDKs. Additionally, there are several community-created CDKs for additional languages, such as Python and TypeScript, that can be installed separately.

It is possible to write different canisters in a project in different languages. Canisters can communicate with one another using an interface description language (IDL) called Candid, enabling canisters in different languages to share and exchange information.

Motoko

Motoko is a language that has been specifically designed by DFINITY for ICP canister development. It supports the unique features and workflows on ICP while providing a robust yet familiar programming environment. Motoko is easy to learn and use for application development, as it has a familiar set of rules and syntax for developers that have a background in application-layer languages, such as JavaScript, Ruby, Python, or Solidity.

Since Motoko has been developed and designed for ICP, this Developer Liftoff series will use Motoko for all tutorials and code walkthroughs.

Rust

Rust is supported on ICP through the Rust CDK. Rust is a good choice for developers who are already familiar with Rust environments, come from a background in C or C++, or are developing large, complex projects that would benefit from having a mature library ecosystem.

Many of the tutorials in this Developer Liftoff series are available in a Rust variation that displays identical functionality. These will be linked where applicable for those that want to follow along with Rust, though not all tutorials will have a Rust version.

Candid

Candid is an interface description language with the primary purpose of describing the public interface of a service. In reference to ICP, a service is a program deployed in the form of a canister. Each canister has a Candid file that defines its public interfaces. Every interface has a sequence of argument and result types and can include annotations that are specific to ICP. Interface descriptions make it possible to interact with the service directly from the CLI, through a web-based frontend, or programmatically from another program or language.

Candid is language-agnostic, allowing for interoperability between frontends and services that are written in different languages, such as Motoko, Rust, or JavaScript. Additionally, Candid supports service interface evolution by specifying changes without breaking existing clients, such as safely adding new parameters to a service without losing compatibility from existing clients.

Candid has a variety of features that make it a particularly good choice for developing dapps on the Internet Computer. These features include:

  • Candid's implementations map the Candid value directly to the values and types of the host language, meaning developers do not construct or deconstruct some abstract Candid value.
  • Candid defines rules for how interfaces can be upgraded simply.
  • Candid is a higher-order language, meaning it can receive more than plain data, such as references to methods and services.
  • Candid has native support for specific ICP features, such as query annotation.

Community-developed CDKs

There are several CDKs that have been contributed by the ICP community.

Python

Python is a popular language for web development, AI functions, and data analysis. It is readable and versatile.

Python is available through the Kybra CDK developed by Demergent Labs.

TypeScript

TypeScript is available through the Azle CDK developed by Demergent Labs.

Solidity

Solidity is an object-oriented language used for writing and implementing smart contracts on blockchain platforms, with the most widely known being the Ethereum network.

Solidity is supported on ICP through Bitfinity, developed by the Bitfinity EVM team, which provides a way to create EVM-based smart contracts.

C++

C++ is available through the icpp-pro CDK developed by icpp World.

ICP AstronautNeed help?

Did you get stuck somewhere in this tutorial, or do you feel like you need additional help understanding some of the concepts? The ICP community has several resources available for developers, like working groups and bootcamps, along with our Discord community, forum, and events such as hackathons. Here are a few to check out: