Table of Contents
The web3 space is filled with new programming languages. Some grow a lot more popular, while some don’t. However, each language has an interesting story. The Move programming language also has one.
In this detailed Move programming language guide, we will learn about the history of Move Language, why Facebook developed it, its design language and structure, and how you, as a developer, can leverage it. If you are a developer interested to learn Move language and build Daaps on Sui, this is the right place for you.
🚨 New Course: Learn to Create a Fungible Token with Sui Move (Free and guided step-by-step course to learn to build on Sui blockchain).
What is Move?
The Move programming language is open-source tool for web3 developers to write blockchain applications. It is one of the more recent programming languages, with an executable bytecode language for smart contracts and custom transactions.
Why did Facebook develop Move?
One of the most exciting and important things about the Move programming language is that it was developed by Facebook. Just like Go was developed by Google itself.
All of this started in 2019 when one of the biggest social media giants, Facebook, came up with the idea of Libra, a stablecoin. Move was first introduced as a native language to Libra. Then in 2020, Libra became Diem due to some regulatory challenges. In 2022, it was eventually sold to Silvergate Capital Corporation because Diem was practically dead. Facebook’s stablecoin project did not work.
However, what remained was the Move programming language that was specifically designed for the Diem (then Libra blockchain).
What exactly are stablecoins?
Stablecoins are an equally investible but less volatile alternative to popular cryptocurrencies such as BTC, ETH, etc. They were first introduced in 2014. As of June 2020, there are some 200 stablecoins. There are two types of stablecoins; fiat-backed stablecoins and algorithmic stablecoins.
🌱 Check this guide: How to create a crypto coin
1. Fiat-backed stablecoins
These stablecoins are backed by a reserve of fiat currency, such as USD. For example, if there are USD 100,000 Coin (USDC) tokens in circulation, then there must also be USD 100,000 held in reserve. This way, the coins remain stable.
2. Algorithmic stablecoins
There is no currency backing involved here. In algorithmic stablecoins, there are algorithms that maintain the value of a stablecoin by minting and burning tokens. For example, if the price of a stablecoin starts to go up, the algorithm may automatically mint more tokens, which will increase the supply and drive the price down.
Facebook’s rationale and motive behind Libra
Launched as something that was expected to revolutionize and transform the global economy, Facebook wanted Libra to serve as an intermediary for transferring traditional currencies. It was also connected to WhatsApp and Facebook Messenger.
How it would have worked, had it not failed, is that users would convert their currencies to Libra and send it to anyone with a Libra-compatible wallet, Calibra (changed to Novi, later on). Libra initially served as a bridge between cryptocurrency and fiat currency. However, fate had some other plans and it did not work out.
Which blockchains use Move the most currently?
Blockchains that have been using the Move programming language frequently are Aptos and the Sui blockchain. Starcoin is also yet another project that uses Move. All three blockchains are L1s with an emphasis on writing smart contracts for DeFi, GameFi, and other blockchain applications.
How is Move different from other blockchain languages?
Move’s two big competitors are Solidity and Vyper. And there are some ways in which the Move programming is different from them and other blockchain programming languages.
Factors | Move | Others (Solidity, Vyper, etc.) |
---|---|---|
How it is typed | Statically typed and strongly typed which means there is generally less room for errors and the code is more readable | Dynamically typed which means the compiler tries to figure out the type of a variable or expression based on how it is used. |
Performance optimization | Has techniques such as inlining functions and avoiding unnecessary memory allocations, to optimize the performance of various blockchain applications such as smart contracts | Do not have such techniques to optimize the performance of blockchain applications |
Type system | Uses a linear type system meaning no one variable can be used for two different purposes | Use a non-linear type system meaning that one variable can be used for two different purposes |
Digital assets | Has an in-built type that represents digital assets | Do not have an in-built to represent digital assets |
What are the critical design goals undertaken by Move?
As a smart contract programming language, Move has undertaken a number of design goals with time. These design goals specifically help Move to grow and develop an infrastructure that could help further help establish efficient and secure blockchains.
1. First-class resources
The thing with blockchain languages is that they deal with virtual assets, unlike traditional assets that tend to be tangible. Now, digital assets have two important qualities; they tend to be scarce and they have access control, meaning only certain people can modify them. For programming languages, it is important that the developers are able to express these qualities. This is exactly what the first-class resources of the Move programming language do. They make it easier to write digital assets that are scarce in nature and have access control.
2. Flexibility
The Move programming language has modules that allow one to compose code with flexibility. Move is not an object-oriented programming language. However, its components – modules, procedures, resources, and the relationship between them – is similar to the components in an object-oriented language. Move also allows for declaring multiple resource types which makes it more expressive and flexible as a language.
3. Verifiability
The Move programming language is known for being capable enough to ensure on-chain verification for all the safety traits. But given that blockchains are utilized frequently, verification of all the safety traits will not be possible. This is why Move has off-chain static verification tools as well. Thus, the complexities with on-chain verification are addressed easily on Move and this is made possible by the three designs which include:
4. Lack of dynamic dispatch
This particular design helps Move easily identify the effects of a procedure call without diving into complexities.
5. Modularity
Move allows the isolation of modules for the sake of functional verification. This means that the code outside of the modules specified by Move can not violate the types of a module. In the long run, the modular design could also enable comprehensive functional verification for crucial module invariants by reviewing isolated modules.
6. Limitated mutability
Limited mutability in the Move programming language means that values can only be mutated through references. This means that there can only be one mutable reference to a value at any given time. This helps to prevent errors that can occur when multiple mutable references to a value are used.
☀️ Read more: What does immutable mean?
7. Safety
One more goal undertaken by the Move programming language is safety. Move language focuses on the on-chain checking of bytecode for memory safety, resource, and type. After the checking process, the bytecode goes for execution directly through a bytecode interpreter. As a result, Move could enable safety privileges that are commonly related to a specific source language.
Common concepts in the Move Programming Language
Data types
Like every programming language, each value that you see on Move belongs to a certain data type. This helps the language to determine which value is specified to which data type.
- Boolean: the boolean type has only two values. It can either be true or false.
- Unsigned integers: integers that can only hold non-negative values
- Fixed-size byte arrays: arrays of bytes that have a fixed length
- Address: unique identifiers that are used to refer to resources in the Move programming language
- Struct: a data type that can be used to group together related data
a) Kind – determines how a struct can be used
b) Unrestricted -procedures that can be called from any module
Procedures
Procedures in Move are methods that could be classified into public and and internal. Although they are similar to other functions within a programming language, they have some differences. Procedures are always named, can have parameters, and can return values.
- Public procedures: accessible to all other modules in the system. They can be called from any other module, and their results can be used by any other module.
- Internal procedures: only accessible to the module in which they are defined. They cannot be called from other modules, and their results cannot be used by other modules.
👀 Also see: Clarity Smart Contract Language 2023 Guide
Bytecode verifier
The bytecode verifier in Move is a tool that ensures that Move bytecode is valid and safe to execute. The bytecode verifier performs a number of checks on the bytecode, including:
- Type checking: checks that the types of values are correct
- Stack balance checking: checks that the stack is balanced at all times
- Reference checking: checks that references are used correctly
- Control graph development: develops the control graph of the bytecode
- Reference linking: links references together
- Resource checking: checks that resources are used correctly
Benefits of Move programming language
As a programming language designed specifically for blockchain development, most of its features are developer-centric. Some of its features are testament to the claim that it is a developer-centric language are like preventing security vulnerabilities, ensuring reliability, making it easy to learn and use, etc. These features are enabled by the following characteristics of the language:
1. Strongly-typed
Move is a strongly-typed language. This means that it greatly helps in preventing errors because a strongly-typed language must have the variable declared explicitly. Once the compiler agrees that the variable is uses correctly, it will help catch errors during the development process.
2. Resource-oriented programming
Unlike most of its counterparts, Move is not an object-oriented language. It is resource-oriented instead. This means that the security vulnerabilities in the Move programming language are easily preventable. This is because resources have a limited life, they can’t be copied and neither can they be dropped.
3. Verification
Move code can be verified, which means that it can be proven that the code will behave as intended. This is done using a formal verification tool, which checks the code for errors. Verification also ensures the safety and reliability of a code.
Move tools and libraries for development
1. Libraries
In programming, libraries greatly help to optimize a developer’s coding. Libraries have pre-written codes that developers can put into use.
- Move Std: a collection of standard modules that are used by many Move smart contracts.
- Move Account Library: helps in managing accounts on the Move blockchain
- Move Transaction Library: helps in managing transactions on the Move blockchain
2. Tools
In programming, tools help you provide an environment, help you streamline your instructions, and test and implement the program.
- Move Prover: used to check the correctness of the codes
- Move Compiler: used to compile a code into bytecode
- Move Playground: web-based IDE that is used to write, compile and debug Move code
📰 Also see: Solana Unveils Solang to Woo Ethereum Devs
How to write a smart contract in the Move programming language
Writing a simple smart contract in the Move programming language does not take much. All you have to do is follow these few simple steps mentioned below and you will have created a smart contract using Move.
1. Create a brand new file
Name it Counter.move
2. Define a module called Counter
It will be called Counter
, like this. 👇🏼
module Counter {
3. Define two public procedures called increment
and get
public fun increment(counter: &mut Counter): u64 {
// Increment the counter value.
counter.value = counter.value + 1;
// Return the new counter value.
return counter.value;
}
public fun get(counter: &Counter): u64 {
// Return the current counter value.
return counter.value;
}
}
4. Finally, compile the code
Use command movec Counter.move
FAQs
What is a move language?
Move programming language was came into existence at Facebook as it was used to build Diem blockchain. It was built by Diem Association based by Meta (Facebook). Although the Diem project didn’t take off, the Move programming language is widely used today.
Is move better than Solidity?
Each programming language has its own pros and cons. Also, different programming languages are built to serve specific use cases. If we company Move vs. Solidity vs. Rust: Move is relatively slower compared to compiled languages, since it is an interpreted language. But, Move gets memory efficiency and parallel processing (from Rust), making it a great choice for developers.
Who uses Move language?
Blockchain platforms like Aptos, Sui, and Starcoin uses Move language.
What are the advantages of move language?
The Move programming language is optimised for verifiability (to make it easy for developers to find and fix bugs). It scores high on safety, flexibility, and developer tooling for streamlined development
Can I learn move smart contract programming language for free?
Yes, there are many free hands-on courses on Metaschool that you can enroll for free and start developing NFTs, Dapps, and web3 projects in different blockchains. You’ll find courses that guide you on creating smart contracts in Ethereum, Solana, and many other web3 ecosystems.
In conclusion,
Move is a strongly-typed, resource-oriented and simple smart contract programming language. A number of features make it a developer-centric language. Once used as a native language to Diem blockchain, Move is mostly used to code in Sui blockchain. This guide contains the features and important components of the Move programming language, its syntax, how to write a simple smart contract using the language, and its goals and what it aims to achieve.