How the Move Programming Language Works
Table of Contents
Understanding the software behind Diem
Last month, Meta announced the sale of its Diem stablecoin to Silvergate, the premier bank in the cryptocurrency space. (For a detailed look at this sale and Silvergate, check out our recent report.) Silvergate operates the Silvergate Exchange Network (SEN), a 24/7 asset transfer system used by many top crypto exchanges. Silvergate has plans to use the Diem infrastructure they acquired to introduce a dollar-backed stablecoin for the SEN.
A crucial part of the Diem package Silvergate paid nearly $200 million for is the Move programming language. Much of the reason why the Diem (formerly Libra) project took so long at Meta was the creation of a proprietary programming language for the cryptocurrency. In this article, we will take a look at the highlights of Move and its future uses as Silvergate maps out the future of Diem.
Before we go any farther, we need to define some key vocabulary. Be aware, this article gets pretty technical.
Programming Language - “A set of commands, instructions, and other syntax use to create a software program.” Move is the programming language for Diem, which enables both the basic functionality of the cryptocurrency as well as building future applications for Diem.
Blockchain - “A digital database containing information (such as records of financial transactions) that can be simultaneously used and shared within a large decentralized, publicly accessible network.” Blockchains power cryptocurrencies, creating immutable ledgers of the transactions which take place. Consensus must be reached before transactions are entered into the record.
Blockchain Trilemma - The difficulty in achieving security (resistance to attacks), scalability (ability to grow), and decentralization (distributed across geography and users) for blockchain networks. So far, blockchains have struggled to achieve all three of these goals. Many of the top blockchains today, such as Ethereum, are secure and decentralized. However, this causes slow speeds and high transaction fees, which negatively affects their scalability. Diem, like most blockchains, aims to solve the trilemma. Move is a large part of that solution
Linear Logic - A mathematical logic system created by Jean-Yves Girad in 1987 which emphasizes formulas as resources, rather than complete truths or needing complete proofs. The key change is that resources can only be used once, rather than treated as permanently true. (i.e. “If you give me A once, I’ll give you B once,” instead of “A can be exchanged for B.”) This makes linear logic useful in computer science, where confining a formula to a resource instead of treating it as a universal truth enables more versatile systems.
Resource - The base unit of linear logic systems. In Move, “a resource can never be copied or implicitly discarded, only moved between program storage locations.” The need for tokens, ledgers, and other blockchain elements to be permanent is why linear logic, particularly resources, was used to build the Move language.
What is Move?
Move is the programming language designed for the Diem Blockchain. Both Move and Diem were created by the Diem Association, a tech consortium backed by Meta. Recently, the Diem project, including the Move language, was sold to Silvergate.
The executable format of Move is “bytecode that is higher-level than assembly yet lower-level than a source language. The bytecode is checked on-chain for resource, type, and memory safety by a bytecode verifier and then executed directly by a bytecode interpreter.” This mechanism was designed to maximize safety, without adding the cost of compilation to transactions, minimizing gas fees as compared to Ethereum. This is an example of Move attempting to solve the trilemma through its design.
Resources: What Makes Move Move
The major factor that separates Move from other programming languages is its use of resources, which is drawn from the mathematical idea of linear logic. In linear logic, formulas are treated as fundamental resources that can only be used once. Following that, in Move, “a resource can never be copied or implicitly discarded, only moved between program storage locations.” Move allows developers to encode custom resource types which are treated as “first-class” and unable to be duplicated or erased.
This is enabled by Move’s static type system. This means that variables in the programming language must be defined as a certain type (i.e. a number or a word). In Move, this system protects the first-class nature of resources. However, resources can still be used similarly to any other, less-protected element. They can be stored in data structures or passed as arguments to procedures (supplied as the values to be used for a calculation).
This all means that resources in Move enjoy a high level of both security and expressivity. They are protected within the code, but can also be used freely for all sorts of operations. This combination is perfect for blockchain programming, as it addresses both the security and scalability aspects of the trilemma. Currently, the “Diem coin, transaction processing, and validator management” are all encoded as resources with Move.
The Move whitepaper sets out a clear list of motivations for the language which informed its design. They also note the challenges of creating public blockchain systems, which affect not only Move, but all blockchain programming languages.
They note chiefly that Diem (Libra) must be an “open system,” where anyone can view the state of the blockchain and submit transactions. This is radically different from traditional software for managing assets, like a digital banking service, as those are deeply closed systems. Access is only possible with special permissions (of which there are many levels) and there is highly limited transparency with regard to other users.
But in a blockchain, “all participants are on equal footing.” This introduces a number of challenges. A major one is preventing the submission of invalid transactions, such as one user attempting to transfer another’s assets. In addition, blockchains must capture two aspects of traditional currency which are difficult to execute in software. First is scarcity; duplicating assets must be prohibited and creating new assets should be privileged. (Implementing this privilege in an egalitarian, open system is especially difficult, and greatly limits such a system’s decentralization.) Second is access; a user’s ability to control and protect their assets is of paramount importance. The use of protected, first-class resources in Move is in large part an attempt to solve these scarcity and access issues.
The engineering team listed three key issues which they found with existing blockchain languages, particularly Bitcoin Script and the Ethereum Virtual Machine (the main programming languages for Bitcoin and Ethereum respectively).
- Indirect Encoding of Assets
Since programming is executed mathematically, many different elements are represented as integers. This includes blockchain assets like a cryptocurrency, which is the case in Bitcoin and Ethereum. Move’s engineers felt this made it “awkward and error-prone” to write programs based on crypto assets. This is why Move represents Diem as a resource.
- Inextensible Scarcity
Bitcoin and Ethereum’s language do a good job of protecting the scarcity of their main cryptocurrency. However, the languages are not well-built for creating new assets with scarce qualities. This is particular issue for the Ethereum Virtual Machine, which allows for the creation of ERC-20 tokens based on the Ethereum blockchain. In these cases, developers must engineer scarcity on their own without support from the languae. Move sought to change that.
- Inflexible Access Control
Like with scarcity, Bitcoin and Ethereum keep a tight grip on the access of their main cryptocurrencies, so that ownership and transfer can not be tampered with. However, this is not easily expanded to other elements, nor can the level or means of access be customized. Like with scarcity, Move’s engineers sought to make these features more extensible and customizable to make the language more versatile and scalable.
Pontem Network is the best experimentation platform for Diem, the permissioned blockchain backed by Meta and owned by Silvergate. Our incentivized testnet, Move VM smart contract platform, and Pontem Blocks, our low-code development tool, make it possible to start building for Diem. Pontem offers a head start to developers looking to design projects for the Silvergate Exchange Network and Meta’s metaverse.