Move programming language is a relatively new programming language that was developed to provide a secure and programmable foundation for the Libra Blockchain. Every transaction that occurs through the Libra Blockchain makes use of a transaction script that is written in Move to encode its logic. If you would like to learn more about Libra, you can read our article on Facebook’s Libra Coin: How to get started with Libra cryptocurrency.
Move programming language is based on Rust and was developed by Facebook to develop customizable transaction logic and smart contracts for the Libra digital currency. The highest priorities during the development of Move were safety and security. The language is designed such that assets cannot be cloned to ensure that digital resources can only have one owner at a time and only be spent once. It is a stack-based language and works similar to all the stack-based languages by pushing and popping as operations are performed. According to the execution model, each account (256-bit address) can have zero or more modules and one or more resource types.
Move programming language
Any variable declared as a resource will be associated with some built-in restrictions. Resources can only be moved and cannot be copied. They can only be created or destroyed within the modules that they are declared in. Once a resource is used up, it becomes available for second use later — this is a major factor to avoid double spending. Resources must be moved exactly once — this helps any dangling resources that have been forgotten by a developer to be recognized during verification.
Key features of Move programming language
Move transaction scripts enable programmable transactions
- Every single Libra transaction has a Move transaction script that is responsible for encoding the logic a validator should perform on the client’s behalf
- The transaction script connects with the Move resources that are present in the universal storage of the Libra Blockchain by calling the procedures of one or more Move modules.
- A transaction script is not stored in the global state, and it cannot be invoked by other transaction scripts.
Julia Vs Python
Benchmarking and performance analysis of Julia Vs Python
Read More
Move modules allow for composable smart contracts
Move modules lay out the regulations for the global state updation of the Libra Blockchain. These modules fill the same niche as smart contracts in other blockchain systems. Modules declare resource types that can be published under a user’s account. Each account in the blockchain is a container for several Move resources and Move modules.
- A module declares both struct types and procedures.
- The procedures of a Move module lay out the rules for creating, accessing, and destroying the types it declares.
- Modules can be reused. A struct type that is declared in one particular module can also use struct types that are declared in another module. Similarly, a procedure declared in one module can invoke public procedures declared in another module. Transaction scripts can invoke any public procedure of a published module.
Move Has First Class Resources
- One of the primary features of Move is its capability to define custom resource types. Resource types can encode safe digital assets with rich programmability.
- Resources are normal values in the language. They can be archived as data structures, passed as arguments to procedures, returned from procedures, etc.
- The Move type system provides special safety guarantees for resources. Move resources can never be duplicated, reused, or discarded. A resource type can only be created or destroyed by the module that defines the type. These guarantees are enforced statically by the Move virtual machine via bytecode verification. The Move virtual machine will refuse to run code that has not passed through the bytecode verifier.
- All Libra currencies are implemented using the generic Libra type. Libra has no special status in the language; every Move resource enjoys the same protections.
How is Move different from other programming languages?
We can observe a few primary differences that makes Move programming language stand apart from other existing blockchain languages-
- No type system enforced by default for digital assets. Ex: Bitcoin/Ether.
- Access control policies are also embedded in the language semantics.
- First-class resources: In this language, it is possible to declare a custom asset as a resource type, making it secure and access controlled. Resources are transparent within modules and are opaque to invocations external to the modules.
- Flexibility: Each Libra transaction has a transaction script. Transaction scripts are used to make calls and invoke procedures in a module. It is a single primary procedure that can contain customizable transactions and arbitrary code. A single script can invoke multiple procedures.
- Safety: To ensure security in this language three primary components have to be considered — types, resources and memory. Generally, two approaches are made use of- compile-time checking or runtime checking at the assembly level. With Move, a new approach has evolved which forms a middle ground between the above two approaches, i.e., typed bytecode which is at a higher level than assembly and lower-level than source language. A Bytecode Verifier, checks for safety properties on-chain before the modules are published. Once verified, Bytecode Interpreter executes the code. This is very similar to the process used with JVM (Java Virtual Machine) and CLR (Common Language Runtime).
- Verifiability: Even though Move enables on-chain verification of all the safety properties. This is not ideal for a highly utilized blockchain. Hence, off-chain static verification tools are also supported by Move which will reduce the complexity of on-chain verification. Under this assumption, there are three design decisions considered: No dynamic dispatch (avoid complex call graph construction and call site can be statically determined), Limited mutability (Usage of reference types similar to C++, which allows at most one mutable reference at a point) and Modularity (modules can be isolated for functional verification).
Components of Move programming language
- Types — Supports primitive types like boolean, address (256-bit), unsigned integer (64-bit) and fixed size byte arrays.
- Struct — Two types: kind(resource) and unrestricted(general structures).
- Procedures — Methods that can be public or internal. By default, module dependency is acyclic, which avoids the re-entrancy attacks.
- Bytecode Verifier — The critical component which checks for safety properties before modules get published. All Move programs have to pass through the verifier before getting deployed on the network. There are multiple phases in the process of verification: control graph construction, stack balance checking (ensuring the size of the stack is not modified after all the operations), type checking, kind or resource checking, reference checking and linking with the global state (checking declarations match their usage).
- Bytecode Interpreter — After verification is done, the programs are passed through an interpreter for execution. This flow is very similar to JVM and CLR as mentioned before and traditional programmers can relate to this process. Execution of programs is metered similar to Ethereum using “gas” parameter. This will warrant any infinite loop executions.
- Move Virtual Machine — The process of VM is similar to any other blockchain. This has been covered in detail as in another technical paper as mentioned. But to sum it up, blocks contain multiple transactions and each transaction is executed to create a transaction effect. The transaction effect is used to generate an updated global state. This creates a separation between effects and state transitions.
- The Language — In general, it is designed to support parallel execution.
Facetagging with Elasticsearch
How to do face tagging and clustering in videos with Elasticsearch
Read More
There are still a lot of doubts that surround Move programming language. Despite the provided information about the language, it is still in its infancy. However, the direction in which the language is heading is quite exciting and communities like LearnMove have started cropping up, allowing people to share knowledge and resources on the Libra Blockchain and the Move programming language.