Is Vyper a good alternative to Solidity?
Let’s see if Vyper is a viable alternative to Solidity and how much it’s being used these days.
What is Solidity?
Solidity is an object-oriented programming language for writing smart contracts. It is used for implementing smart contracts on Ethereum and other EVM compatible blockchains( such as Ethereum Classic and Quorum ).
Right now, Solidity main’s advantage is its widespread use amongst Ethereum developers and the big amount of beginner resources there are lots of tools available to make your life easier like Truffle and OpenZeppelin. Also, Solidity courses are available online and some of them are even free. Have a look at CryptoZombies.
What is Vyper?
Vyper is a general-purpose, experimental programming language that compiles down to EVM (Ethereum Virtual Machine) bytecode, as does Solidity. However, Vyper is designed to massively simplify the process in order to create easier-to-understand Smart Contracts that are more transparent for all parties involved, and have fewer points of entry for an attack.
Vyper is a newer language, and its developers learned from Solidity’s issues. They designed it to be more simple, secure, and easier to audit. As such, Vyper lacks modifiers, class inheritance, recursive calls, and a few other features that proved to be problematic in Solidity. Also, it adds overflow checking and strong typing.
What is the most used, Solidity or Vyper?
To compare which of them are most used, I used the GitHub search function to find how many contracts are written in Vyper and Solidity.
What I have done is basically to search all files that have a file extension which ends either by .vy or by .sol since those are the respective file extensions of Vyper and Solidity.
This search had a shocking result, as you can see by yourself:
At the time of writing only 160 contracts are written in Vyper against a whooping 311k contracts which are written in Solidity.
The reason for a low amount of contracts in Vyper is because it’s still an experimental language and even though it’s going to be used for ETH2.0 the community and resources aren’t there for beginners and the documentation is not as huge as the Solidity one.
Is Vyper Turing complete as Solidity?
First of all, let's head to what Turing complete means. A Turing Complete system means a system in which a program can be written that will find an answer (although with no guarantees regarding runtime or memory).
The Vyper language is NOT Turing complete, Solidity is. At the same time, a program written in Vyper will always have a predictable output. A program written in Solidity will not have a predictable output until and unless it is deployed and executed.
Vyper is intentionally not Turing-complete for security and overflow checking reasons which are one of the biggest flaws in Solidity.
So why should I switch to Vyper if the majority of developers use Solidity?
Even though most of the contracts are written in Solidity as I’ve outlined before, there are a lot of bonus points for Vyper and it’s doing a great job improving the security of Smart Contracts.
Striving for simplicity Vyper has eliminated class inheritance, function overloading, operator overloading, and recursion as none of these are technically necessary to create a Turing-complete language. Also eliminated as unnecessary are the less common constructs; modifiers, inline assembly and binary fixed point.
Things to be aware of when coming from Solidity
Since the documentation is not as big as the Solidity one which has been revised a lot of times, I recommend using this section of the documentation if you don’t find what you are searching for.
These are some of the things that developers who want to learn Vyper and already know solidity should be aware of:
- address(this) -> self
- address(0) -> ZERO_ADDRESS
- No reference variables in Vyper
- require -> assert
- assert -> assert .. UNREACHABLE
Is Vyper going to replace Solidity?
Vyper was NOT created to replace Solidity. It was created to be used alongside since it shares the same bytecode in order to boost security. A recent study found more than 3000 vulnerable contracts (written in Solidity)contain security flaws.
Vyper was created to be as similar to Python as possible, but is not yet a start to finish replacement for either Python or Solidity, but rather a language to use when they need for the highest level of security is required. Smart Contracts holding patient health metadata for instance.
Thoughts? Questions? Please drop a comment below.
If you’ve found this post helpful, please leave a Clap.
Hope you are smarter and you learned new things! Thanks for reading 👐