Highlighter Stats× 1 total highlight 1 person highlighted Ethereum is planning to use Vyper for its future contracts Smart Contracts of the Future? Vyper and Plutus
As a developer, one thing that you should realize is the importance of constant education. The world of cryptocurrency and blockchain is in a constant state of motion. The norm a year back ago could be completely irrelevant months from now. So, in the spirit of this constant change, we are going to give you an idea of what Vyper and Plutus smart contracts and code will look like. Ethereum is planning to use Vyper for its future contracts, while Cardano has chosen Plutus as its choice of smart contract programming language.
Smart Contracts of the Future? Vyper and Plutus
Solidity is the Smart contract language of choice for Ethereum as of right now. Solidity was developed by Gavin Wood, Christian Reitwiessner, Alex Beregszaszi, Yoichi Hirai and several former Ethereum core contributors to enable writing smart contracts on blockchain platforms such as Ethereum.
It has been influenced by many popular programs and programming concepts. It has elements of object-oriented programming, web development, assembly language, etc. and covers a wide range of use cases. However, auditing solidity contracts can be really difficult since they can be extremely permissive and complicated.
Vyper is a Python-based language that is built solely for readability and simplicity. Since python itself is one of the most easily understood and widely-used programming languages, it is hoped that non-technical people will be able to hop on and start coding their own smart contracts. Vyper has been developed as a minimalistic, simple language which focuses on trivial use cases (eg. it can’t be used to code a complex Dapp) and is not as flexible as solidity.
So, while it may somewhat curb the flexibility of the contract, it provides a more
“a straightforward, pragmatic, and easily auditable regime for reading and writing smart contracts, which tries to clearly capture the intent of whoever writes the code.”
It looks like Ethereum and Ethereum Classic bigwigs are completely behind Vyper for two main reasons:
- The Ethereum Commonwealth which maintains and develops Ethereum Classic has also stated that they want to adopt Vyper as a default smart contract language.
Vyper’s minimalist approach does away with inheritance, state modifiers recursive calling, and Operator overloading which gives way to gas limit vector attacks. Plus, it also has tons of overflow checks for large arithmetic operations. Because of its approach, not only is Vyper resource efficient, it is also difficult to write malicious code without it being spotted during auditing.
Vyper Smart Contract
Let’s take a look at a Vyper smart contract courtesy CoinPupil. This is a simple and straightforward ERC-20 contract.
In this contract:
- The “self” method is used to show the instance variables of its class for clarification purposes.
- @public and @private are used to set the visibility and exposure of the contracts ABI (Application Binary Interface) interface which allows external actors (other contracts or wallet addresses) to call it.
Cardano has chosen Haskell and Plutus as their languages of choice. Haskell will be used to code Cardano, while Plutus will be used for the smart contract creation. Both of them are functional languages.
What do we mean by that?
The Two Families of Languages (A Slight Detour)
When it comes to programming languages, there are two families:
Imperative Programming Languages
In an imperative approach, the coder needs to put down all the steps that the computer needs to take in order to reach a goal. All of our traditional programming languages like C++, Java and even Solidity are imperative programming languages. This kind of programming approach is also called algorithmic programming.
Let’s take an example of what we mean by that. Let’s look at C++. Suppose we want to add 5 and 3.
int a = 5;
int b = 3;
c= a + b;
So, as you can see, the addition process takes over multiple steps and each step is constantly changing the state of the program as they are all being executed in turn individually.
An addition process took four steps and the steps are:
- Declaring an integer a and assigning the value 5 to it.
- Declaring an integer b and assigning the value 3 to it.
- Declaring an integer c.
- Adding the values of and b and storing them in c.
Functional Programming Languages
The second family of programming languages is Functional languages. This style of programming was created to build a functional approach to problem-solving. This kind of approach is called declarative programming.
So, how does functional programming work?
Suppose there is a function f(x) that we want to use to calculate a function g(x) and then we want to use that to work with a function h(x). Instead of solving all of those in a sequence, we can simply club all of them together in a single function like this:
This makes the functional approach easier to reason mathematically. This is why functional programs are supposed to be a more secure approach to smart contract creation. This also aids in simpler Formal Verification which pretty much means that it is easier to mathematically prove what a program does and how it acts out. This gives Cardano its “High Assurance Code” property.
This is precisely why the functional approach is so desirable.
And that is exactly what Cardano is using Haskell to code their ecosystem and Plutus for their smart contracts. Both Haskell and Plutus are functional languages.
Back to Plutus
Plutus is a higher level and simplified version of Haskell. This means, that like Haskell, it has more similarities to mathematics rather than programming. Plutus is intended for use by
“financial institutions, places that do electronic trading and other such financial operations with money at stake.”
So, let’s take a look at some basic Plutus programming. The following code has been taken from Cardano docs.
This simple Plutus program shows addition, multiplication, factorial, and Fibonacci:
You can see in the code itself the differences between a functional approach and an imperative approach.
The ever-changing world of crypto and blockchain means that we need to be on our toes constantly. Having knowledge of these new programming languages is absolutely critical for all bounty hunters and developers.