Skip to content

Instantly share code, notes, and snippets.

@liamzebedee
Created June 9, 2023 14:48
Show Gist options
  • Save liamzebedee/977450f359ed9585af8f0143e1067dfa to your computer and use it in GitHub Desktop.
Save liamzebedee/977450f359ed9585af8f0143e1067dfa to your computer and use it in GitHub Desktop.
StarkNet/Cairo vs. Solidity/EVM

Comparison

What's good about Starknet/Cairo eco?

  • Cairo has a working package manager https://github.com/lambda-0x/cairo-base64
  • Cairo actually allows you to "import" a single function. with solidity, you have to wrap it in a library. and then import the entire library. this makes the code a lot more cluttered
  • lower level customization of things like storage packing through traits is powerful (never liked solidities implicit behavior based on member ordering)
  • compiler plugins for code expansion etc
  • native support for volition
  • no stack too deep
  • linear type system (not an expert here but i believe will enable parallelism)
  • probably another point to reference - there isn't so much overhead here from gas optimizations. not a big thing but it's something I notice reading solidity, the logic is oftentimes expressed in a much less straightforward manner than cairo
  • not really a Cairo thing (but definitely a Solidity thing) is there's no need for payable and WETH as ETH is also a ERC20 asset
  • modularity in the language -> great for contracts and libraries -> but also great for testing those contracts and libraries
  • The testing apparatus Cairo gives us for free is stunning. No external dependencies, frameworks etc. No excuse not to have comprehensive tests

Overall points:

generally, i like that contracts are an extension of the base language rather than a core construct. complex code in cairo is typically using the base language, which is nice and modular and easily testable, and the contracts / starknet os wrap it. libraries in solidity always feel second class and their semantics are confusing.

Quotes

  • for me its the type system.
  • i haven't professionally written solidity so i don't think i would be able to provided good explanation but whenever i had to use solidity clunky to use. i think smart contract language should have strong type system like rust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment