The Countdown to Blast Off is on! 
Join the 400M $SUPRA token airdrop
Robot Image
Supra

MoveLang: A Rising Titan in Smart Contract Programming

August 26, 2022 - 6 min read

Move is a stack-based Web3 programming language that defines custom resource types, allowing for enhanced flexibility while shoring up some of the weaknesses of its predecessors like Solidity.

Introduction

In January 2022, Silvergate Bank announced paying nearly $200 million for Meta’s Diem blockchain IP, including the proprietary programming language Move. It is likely that the Diem (formerly Libra) project took longer than most expected in development due to the creation of Move as a novel smart contracts language for the blockchain project.

Though it is young, several projects are now connected to MoveLang besides Diem, like Sui and Aptos blockchains. Since it is quickly rising in popularity, it is useful to gather an understanding of what makes writing code in Move so exciting for developers. This article will thus summarize the highlights of Move, its applications as a virtual machine (VM), and the reasons to expect its use to proliferate in deploying smart contract protocols.

What is MoveLang?

First of all, Move is a stack-based language, and essentially works by making stack operations push and pop as computations are performed. According to its execution model, accounts are to have zero or more modules, and one or more resource types, but can only have one resource within a particular resource type. If needed, custom resource types containing multiple resource instances of the same type could be created. The customization of resource types is one of the primary reasons that Move is quickly becoming such a powerful addition to a developer’s skillset.

According to Diem’s whitepaper, 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.” It was designed to maximize safety without adding the cost of compilation to transactions, and thus minimizing transaction fees compared with existing networks.

Move also comes with a lot of built-in functions that allows developers to reference resource values or even destroy resources. The built-ins, however, can only be used on resources declared in a current module. Thus, if a developer forgot to declare procedures to reference resource values using built-ins, then viewing or altering that resource would subsequently be unavailable.

The following demonstrates the primary components of the Move language:

  • Primitive Types
    • boolean 
    • address (256-bit) 
    • unsigned integer (64-bit) 
    • fixed size byte arrays
  • Struct
    • kind (resource)
    • unrestricted (general structures)
  • Procedures
    • Acyclic module dependency to mitigate reentrancy attacks
      • public 
      • internal
  • Bytecode Verifier
    • Checks for code safety properties before running modules 
    • Programs pass through the verifier before deployment in phases:
      • Control graph construction 
      • Stack balance checking (ensure size of stack not modified after operations) 
      • Type checking 
      • Kind/Resource checking 
      • Reference checking & linking with global state
  • Bytecode Interpreter
    • Bytecode run through the interpreter before execution
      • Similar to JVM and CLR
    • Smart contract engagement metered by gas fee parameters
      • Mitigates reentrancy attacks and other infinite loop executions
Move-Prover-Formal-Verification-for-smart-contracts
Move has built-in safety features which verify the bytecode is safe before running any modules. Native formal verification is a hallmark of MoveLang, giving it first-class security guarantees from the most fundamental levels.
  • Move Virtual Machine (MVM)
    • Blocks contain multiple transactions, and transactions are executed to create transaction effects 
    • Manages invocations between modules via running the checks through its bytecode verifier
      • Cost of verification is halved since module only charges for on-chain interactions
    • Generates an updated global state
      • Creates a separation between effects and state transitions

MoveLang Defines Custom Resource Types

Move distinguishes itself from other smart contract programming languages via its use of resources, which is derived from linear logic. Linear logic formulas are treated as fundamental resources that may only be used once. With MoveLang, resources are never copied or discarded, but moved between program storage locations. In other words, there is an element of ‘air-tightness’ to the code which is inherently more secure via custom ‘first class’ resource types.

This is further enabled by Move’s static type system, meaning created variables must be defined as specific types. In Move, this system protects the first-class nature of resources since the code will be compiled before execution, preventing the delivery of failed programs. Nevertheless, resources in Move are still used similarly to other, less-protected elements, and are stored in data structures, or passed as arguments to procedures.

Fundamentally, Move’s resources possess advantages in terms of both expressivity as well as security guarantees. Since resources are guarded within the code by design, but can also be used freely for all sorts of operations, MoveLang is aimed at tackling the two aspects of the blockchain trilemma in which it can affect: security and scalability.

Move as a Natural Progression of Web3 Languages

As mentioned, Diem’s engineering team found issues with existing blockchain languages, particularly Bitcoin’s Script and Ethereum’s Solidity, noting several problems. First, other programming languages often represent elements as integers, making the programs awkward and error-prone, leading MoveLang’s designers to represent digital assets as first-class resources instead. This provides a strong foundation from the language level which protects the scarcity of any created digital assets using MoveLang.   

Aside from the digital assets themselves, MoveLang allows other elements and levels of access to be easily customized. That is, that access control is embedded into the language itself. Assets written in Move are therefore more sophisticated by default, giving developers functionality with which to work. Move’s customizability regarding its use of resources and modules arguably makes it more scalable than comparable smart contract languages, though it remains to be seen.

Disadvantages of MoveLang for Smart Contracts

MoveLang makes a tradeoff of speed and performance in return for its high security guarantees. That is, Move’s code is evaluated at runtime and shouldn’t suffer from compiler bugs as can be the case with Solidity and other languages. Other potential downsides include:

  1. Move’s code cannot be easily ported to other blockchains.
    1. Third-party tools can be developed to do this. 
  2. There are few resources and code libraries compared with other languages like Solidity.
  3. Again due to its young age, information, research reports, and developer training are all less commonly found than other languages.

Finally, since it’s a rather new language, some of its shortcomings may yet to be discovered. Once it has been in use for several years and has been battle-tested like its counterparts, it will have a track record with which we can gauge its proliferation and popularity amongst Web3 devs. Move has already demonstrated plenty of promise, and has a lot of developers buzzing to work with it. Expect to see and hear a lot more content about Move over the next few years.

Resources

  1. Dill, D. (2022, 7 Feb.). Fast and reliable formal verification of smart contracts with the Move Prover. International Conference on Tools and Algorithms for the Construction and Analysis of Systems.
  2. Kokoris-Kogias, E. et al. (2021, 31 July). CALYPSO: Private data management for decentralized ledgers. Meta Internal Conference on Very Large Data Bases.
  3. Iredale, G. (2021, 12 Aug.). An overview of Move programming language. 101 Blockchains.  
  4. Zhong, E. et al. (2020, 21 Oct.). The Move Prover. International Conference on Computer-Aided Verification.

Related Articles

Learn More

twitterlinkedinfacebookmail

RECENT POSTS

Get news, insights, and more

Sign up for the Supra newsletter for company news, industry insights, and more. You’ll also be the first to know when we come out of stealth mode.

PrivacyTerms of UseWebsite Data Usage & CookiesBug DisclosureBiometric Information Privacy Policy

©2024 Supra | Entropy Foundation (Switzerland: CHE.383.364.961). All Rights Reserved