- Mastering Ethereum
- Merunas Grincalaitis
- 414字
- 2021-06-24 15:01:07
Vyper
Vyper is a new programming language for smart contracts that has a syntax similar to Python. It was created by Vitalik himself and it's one of the most interesting choices for new decentralized applications, given that it provides a different approach to traditional Solidity smart contracts.
Its goal is to be a simple programming language that has increased security based on simplicity, where the code should be easily understandable, even by non-developers. That's why the syntax is so minimalistic. They also wanted it to be a programming language where it's increasingly hard to write buggy or vulnerable code, so that developers don't spend countless hours analyzing the security of every single application while avoiding unexpected vulnerabilities by default.
That's the main reason Vyper added several interesting features, such as the following:
- Knowing how much gas each function call will cost every time: Having a precise indication of gas costs is important, because you want users to be able to calculate precisely how much Ether they will invest per transaction. It saves people's money while making the program predictable.
- Automatic vulnerability checking: Overflows, underflows, reentrancy attacks, and many other well-known vulnerabilities are automatically fixed in Vyper, without having to manually pay attention to every single function of your smart contracts.
On the other hand, they removed important characteristics found in other smart contract programming languages, such as Solidity:
- No more modifiers: Modifiers are not allowed in Vyper, because they make code confusing to read, given that you have to jump back and forth between the modifier definition and its use. Also, they can be used maliciously by executing code unexpectedly; for instance, creating a modifier called onlyOwner but then executing a transfer() function totally unrelated to what's expected from its name.
- No more assembly: Assembly code is hard to understand, even to experienced developers, because you're dealing with very low-level functions that can be misleading. This means that you won't be able to create smart contracts that use signatures, state channels, and similar applications relying on assembly.
- No more recursive functions: To avoid reentrancy attacks while guaranteeing a precise calculation of gas costs, they removed recursive functionality where functions can call themselves an uncertain amount of times.
In general, Vyper is a powerful language that's great for smaller projects and won't require advanced functionality, such as assembly. You can quickly create an easy-to-maintain smart contract that your users will be able to understand within a few minutes for its light syntax and minimalistic code.