Published on

Better Solidity

Authors

I have been using solidity for around 1.5 years, it's really inspiring but a bit annoying.

Programming on EVM is pretty different. The environment is different. You have to learn a new language. You have to be awared of the difference between off-chain and on-chain. Fortunately your traditional off-chain programming knowledge applies here, but partially.

And solidity is also a bit annoying, code-wise.

Interface & Modules

Solidity does not have module. You have to organized the code by directories.

Also generally you have to split interfaces and the actual source code, implement the real code in separated file.

And remember interface doesn't implement any logic, which makes it hard to locate the actual implemetation. Due to the nature of EVM, code is compiled into EVM bytecode. In order to verify contract integrity, source code should be accessible to public for verify the bytecode and the actual implemetation.

No need to say it's also better to developer to make integration with the contract.

Standard Library

Solidity itself only provides a very few functionality (block, abi, etc.), less compared to Vyper. Vyper provides much more api and features.

For example, it has a immutable keyword which you generally have to replace the original variable (to save gas) in Solidity cause solc not always to identify the immutable variable.

Improvement

& syntax: inspired by Rust to provide a 'referrence' (to an address). It will assume the interface is compatibility with the contract.

fixed & ufixed: complete it.

Built-in Standard Library: Built-in Safe Math, Common Data Structure, etc.

Precompile support: add chain-specific precompile to enable smoother development experience.

Backward Compatibility

& is equivalent to call external functionality by interface.

&ERC20 <=> IERC20(address)

The other features won't break the backward compatibility as those are newly introduced features, and do not changes on previous built-in features. (But some library could be broken)

Other Notes

Some EVM languages also worth a look:

  • Vyper Pythonic language for the EVM (syntax like python, personally not very preferred)
  • Fe-lang The next generation smart contract language for Ethereum (personally prefer this cuz im also rust dev)