Solidity vs Vyper, which Smart Contract Language Is Right?

These languages change all the time, and you could easily cherry-pick smart contracts and data to make different languages seem better or worse. Keep this in mind when we get to the gas optimization comparisons. We’ve chosen a minimal contract for comparison, if you think you have a better example, we’d love to see it!  Now, if you’re a veteran of this space, let’s go deep under the hood of these languages. Prepare to geek out.

Comparing the Same Contract

Now let’s get into what each language looks like and then compare their gas performance. 

Here are four nearly identical contracts written in each language. They all do approximately the same thing, They all:

  1. Have a private number (uint256) at storage slot 0.
  2. Have a function with the readNumber() function signature that reads what’s at storage slot 0.
  3. Allow you to update that number with a storeNumber(uint256) function signature.

That’s it. Here are those contracts. 

All the code we’ve used to compare languages is located in this GitHub repo.

🐉 Solidity

Example of a Solidity Contract

🐍 Vyper

An Example of a Vyper Contract

♞ Huff

An Example of a Huff Contract

🧮 Yul

An Example of a Yul Contract

Just by looking at these four images, we can start to see a picture of how each language feels to write. As far as developer experience goes, it’s substantially quicker to write Solidity and Vyper code. This makes a lot of sense: those languages are higher level, while Yul and Huff are meant to be low-level code. For this reason alone, it’s easy to see why so many people have adopted Vyper and Solidity (as well as the fact that they have each been around much longer). 

Join us on Telegram

Follow us on Twitter

Follow us on Facebook

You might also like

LATEST NEWS

LASTEST NEWS