Ethereum #54: Vyper
Vyper is an experimental, contract-oriented, pythonic programming language that targets the Ethereum Virtual Machine (EVM).
Vyper has a few principles and goals that aim to make it a language that is ideal for programming smart contracts.
- Security is a primary focus for any smart contract language and Vyper maintains that “it should be possible and natural to build secure smart contracts in Vyper.”
- Vyper code should be not just human readable, but make it difficult to write misleading code. This directive is aimed at making contract audits as successful as possible.
- Striving for language and compiler simplicity support the other goals by keeping confusing complexity under control.
To achieve these goals, Vyper implements the following features:
- Bounds and overflow checking
- Support for signed integers and decimal fixed point numbers
- Decidability - Reliably compute upper bounds for gas consumption of any function call
- Strong typing
- Small and understandable compiler code
- Limited support for pure functions
There is a notable lack of the following features that are present in Solidity:
- Modifiers - Modifiers make it easier to write misleading code. It encourages writing code where execution jumps around the source file, making audits more difficult. Vyper encourages inline checks in each function to improve clarity.
- Class Inheritance - Inheritance also makes it easier to write misleading code. Contracts’ logic is spread across multiple files, decreasing readability and requires additional understanding about how inheritance works in case of conflicts.
- Inline Assembly - Inline assembly makes it possible to manipulate variables without referencing it directly by name. This makes development and auditing more difficult and can obfuscate bugs.
- Function overloading - Contracts with overloaded functions can be confusing. It may not be clear which function is being called in specific situations.
- Operator overloading
- Recursive calling - It is not possible to set an upper bound on gas limits in contracts with recursive calling
- Infinite-length loops - It is not possible to set an upper bound on gas limits in contracts with infinite length loops
- Binary fixed point - In binary fixed point, approximations are required (e.g. in Python 0.3 + 0.3 + 0.3 + 0.1 != 1).
As you can see in the list of features that Vyper is lacking, writing clear, understandable code is of primary importance.
Vyper is not trying to be a replacement for Solidity. It is meant to be a more security focused smart contract programming language and will likely not be able to do everything that Solidity can.
You can view the latest documentation here: https://vyper.readthedocs.io/en/latest/index.html
Vyper is a subset of Python syntax, making the syntax familiar to many developers.
In Vyper, whitespace matters, so pay attention to spaces and tabs. Comment code using ‘#’.
Vyper compiles to LLL.
https://vyper.readthedocs.io/en/latest/index.html
https://vyper.online/
https://medium.com/@daniel.jozsef/why-i-learned-to-stop-worrying-and-love-viper-part-1-c6ba7bda02f5
https://medium.com/@daniel.jozsef/how-i-learned-to-stop-worrying-and-love-vyper-part-2-c5d4bb7dcc64
https://medium.com/@daniel.jozsef/how-i-learned-to-stop-worrying-and-love-vyper-part-3-4031a70a60d9
https://medium.com/@maurelian/an-early-look-at-vyper-d101e0c349c1
▶️ DTube
▶️ IPFS
