Should I learn Rust or Solidity to develop smart contracts?
Web3 and blockchain technology are going to the moon. At the heart of this technological revolution is the smart contract. Programming smart contracts is not done in the same way and with the same technologies that we code traditional apps and websites.
The two main blockchains that are competing for smart contracts developers are Solana and Ethereum. As a programming language for developing smart contracts (programs) in Solana you have Rust and for developing smart contracts in Ethereum you have Solidity.
You can compare each programming language according to its transferable skills, madurity, learning curve, target blockchain size, tooling and prospect salaries.
The motivations to learn a programming language vary from person to person.
Considerations may include previous background, tech stack, programming paradigm, documentation, community support, job opportunities, use cases and industry interest for just mentioning a few.
If you are interested in Web3 you may not escape Rust or Solidity.
With no more ado, let's get into some details.
This aspect is related to the range of blockchains (protocols), platforms, tech stacks, domains and industries supported by the language.
The smart contracts written by Solidity are intended to run on Ethereum Virtual Machine (EVM). Examples of blockchains that use Solidity are Ethereum, Avalanche, Polygon, Binance Smart Chain (BSC), Monax, Hyperledger and Burrow.
Rust is used to code many type of systems:
- Web browser engines (Servo and Gecko).
- Operating systems (Redox, Theseus).
- Game engines (Bevy, Amethyst).
- File system manager (Stratis).
- Apps (Figma, Dropbox).
Rust is used by Mozilla, Google, Microsoft, AWS, Meta, Discord, Cloudflare, etc.
Some general concepts about blockchain functioning and programming may be transferred, but Solana and Ethereum have different approaches about how to implement the smart contracts or programs, manage memory, security, etc. So there is some effort to put when transitioning from one network to the other.
Also it is possible to look for bridges that make possible interoperability between Solana and Ethereum.
Targeted platform (blockchain)
Assuming that the choosing of the platform (blockchain) was the first step, then select a language that supports coding smart contracts that will run on that protocol.
For Solana and Polkadot you have Rust.
For protocols compatible with the Ethereum Virtual Machine (EVM) you have Solidity.
Otherwise the priority changes from the language in itself to identify the platform that best supports your use cases by comparing attributes like ecosystem size, transaction speed, fees, number of validators, built in security, liquidity pool, L2, etc.
Learning curve, community support and resources.
Diving into a new language could be intimidating even for some curated programmers. For beginners it could be a headache to just get your environment running. The complexity of the blockchain technology and the size of the ecosystem increases the learning curve.
Having a coding partner, community support or quality resources to reach out when stuck could make or break your coding journey.
Start slow, with small projects for continuous feedback and self-rewarding goals but challenging enough to keep your interest alive. Increase complexity gradually, check the basis and deep dive when needed. Reevaluate what works for you and adjust accordingly. Learn by doing.
I consider that the learning curve is related to your previous programming experience: programming languages, paradigms or architecture exposure.
To simplify, the learning gets reduced to acquiring the language’s syntax, constructs and mental models.
Rust is associated with a steep learning curve and to be a very complicated language for getting started in Web3, in some way attributed to its mechanisms for increasing safety and performance, and because you are in charge of managing the lifetime of the variables.
In any case it is recommended to start by acquiring the fundamentals of blockchain technology and Web3. I have made a selection of resources to learn blockchain fundamentals that includes materials from MIT, Berkeley, a16z, and Web3 Foundation.
You may feel more at ease with Rust if you have been exposed to high-level and typed languages before. Rust supports structured, generic, imperative, concurrent and functional programming paradigms. It has been influenced by C++, C#, Ruby, Swift, Haskell, Scheme, etc., and is syntactically similar to C++.
Browse to the Rust website to find learning materials.
In the Solidity website you can find good resources to start your journey.
IDE, frameworks and libraries
IDEs and Editors
Rust has first-class editor support in many IDE and editors like VS Code, SublimeText3, Atom, Intellij Idea, Eclipse, Vim, Emacs and Geany.
Rust uses Cargo as a build tool, useful to install packages created by the community, to test and to deploy your code, and to create documentation for your code. With Rustfmt you get automatically formatted code, and coherence across the team. Clippy helps juniors and experienced developers write idiomatic code and enforce standards.
Rust also has an online playground ready for you to start your coding journey.
Solidity has plugins for Atom, Emacs, Intellij, Sublime, Vim and VS Code.
Solidity has an IDE called Remix with a web and a desktop version. It is open source, used to develop smart contracts with Solidity and as a playground to learn and teach Ethereum. It is extensible through plugins. It has modules for testing, debugging and deploying smart contracts, etc.
For the Solana ecosystem you can use Anchor when coding smart contracts with Rust.
Anchor is a framework that provides a few amenities:
Rust crates and eDSL, IDL specification, TypeScript packages for generating clients from IDL, and CLI and workspace management tools.
In the Ethereum ecosystem there are a few framework that facilitate your smart contract programming task:
Hardhat, self defined as the Ethereum development environment for professionals that will make you 10X faster, offers many features like:
Makes it easy to run Solidity locally, without dealing with live environments, when you debug, test or deploy your smart contracts. Designed as a debugging-first tool for Solidity, with stack traces, console.log and explicit error messages. Allows the customization of your tasks and environment, if you need something more specific than the default configuration. Facilitates the integration with other tools and is extensible using plugins.
Truffle with features that includes smart contract lifecycle management, automated contract testing, scriptable deployment and migrations, simple networking management, powerful interactive console, and external script runner.
The Solana tech stack includes (this could vary):
- NodeJS Version Manager: nvm or fnm.
- Solana Tool Suit: Install solana tools suit depending on your preferred workflow. Includes a CLI to interact with the Solana blockchain.
- Browser Wallet: Phantom as recommended but Solana supports other wallets.
- Smart Contract Language: Rust.
- Framework: Anchor.
- Client Library: solana/web3.js web3.js for Solana.
- Testing Library: Mocha.
- UI Library: ReactJS or your preferred.
- Front-End framework for ReactJS: Next.js.
The Ethereum tech stack includes (this could vary):
- NodeJS Version Manager: nvm or fnm.
- Browser Wallet: MetaMask.
- Smart Contract Language: Solidity.
- Frameworks / Dev Environment: Hardhat, Ganache or Truffle.
- Testing Library: Waffle.
- UI Library: ReactJS or your preferred.
- Front-End framework for ReactJS: Next.js.
- Client Libraries: ethers.js, web3.js.
- API Layer: The Graph Protocol.
Job opportunities and salaries
Rust developers earn an average of $144 208 according to Hired, over $180,000 according to 2021 O’reilly survey, an average yearly salary of $120 000 as reported by Web3 Jobs and a median yearly salary of $77 530 as discovered in the Stack Overflow 2021 survey.
Solidity has an average base salary for a remote position of $145 000 and an average base salary of $127 500 in the US as seeing in cryptocurrencyjobs, an average yearly salary of $100 000 according to Web3 Jobs and an average salary of $86 100 as reported by CryptoJobsList.
In general Web3 salaries are an average of $92 000 a year. The average yearly salary for Smart Contract Developer is $117 000, and Blockchain Developer is $74 000.
More traditional roles are also needed in the Web3 space. Based on data from Web3 Jobs the average yearly salary for different Web3 positions is:
- Mobile Developer $125 000.
- Senior Developer $120 000.
- Lead Developer $100 000.
- React Developer $100 000.
- Full Stack Developer $100 000.
- Back End Developer $100 000.
- Front End Developer $85 000.
Scalability, Speed and Ecosystem Size
The size of the chain may inform you about stability, madurity, etc. This could be interpreted and used in many ways.
For example, the fact that Solana is smaller and younger than Ethereum is an indication that there are opportunities, services to create, tools to build. But also indicates that there are unknowns that would impact your work.
On the other hand, seeing Ethereum as a bigger and more mature chain, could indicate that there are a lot of resources, and users to work with, with an increased influence radius.
Solana Scalability and Speed
Solana with more than 50 billions transactions to date, at a rate of 1679 transactions per second, and a cost of $0.00025 per transaction offert a lot of opportunities to scale. The value of SOL is $141.99. These values are updated frequently, to get the latest info visit its official website and messari’s website.
Solana Ecosystem Size
Solana has a total value locked of $9,8 billions according to the SolanaProject Index and Defi Llama, values are updated frequently. The total value locked includes the value of all the projects built around the Solana blockchain that were at over $5 million at the time of this writing. For a full list check Defi Llama Solana’s TVL ranking:
- DEXEX / DeFi: Raydium, Serum, Saber, Atrix, Orca, Aldrin, Mercurial Finance, Synthetify, Drift Protocol.
- STAKING: Marinade, Quarry, Lido, JPool, Socean, Arrow.
- LENDING: Solend, Apricot, Larix, Port Finance, Mango, Jet Protocol, Oxygen.
- YIELD: Tulip Protocol, Sunny, Almond, Francium, Pole.
- ASSETS: Invictus, Ren, Cashio, Allbridge, Allbridge.
- OPTIONS: Friktion, PsyOptions, Katana, Chest.
- MINTING: Parrot.
The Solana explorer also includes other projects at the top ranking:
- NTF marketplaces: Metaplex, Solanalysis, Solanart, Magic Eden, Solsea, DigitalEyes Market, etc.
- Web3 Apps: Audius, Bonfida, Grape Protocol, Squads, Wum.bo, Brave Browser, etc.
Ethereum Scalability and Speed
Ethereum has a total transactions of 1,429.18 million, at a rate of 12.9 transactions per second, a gas price of $5.6, and the value of ETH is $3177.05 by the Etherscan data.
Sometimes you have to reach for scaling layers (L2) to sidestep scalability limitations in the main chain (L1) like the speed and cost of transactions. In this scenario you may consider some tradeoffs: roll up transactions (Arbitrum), decentralization (Polygon), block size (BSC), consensus algorithm (Avalanche).
The transition from proof-of-work to proof-of-stake, as Ethereum's consensus mechanism, is expected to increase transaction speed and lower the gas fee.
Ethereum Ecosystem Size
Ethereum has a total value locked of $145.01 billion according to Defi Llama. These examples are projects that were at over 1 billion at the time of this writing. For a full list check Defi Llama Ethereum’s TVL ranking
- DEXES: Curve, Uniswap, Sushi, Balancer, Bancor.
- YIELD: Convex Finance, yearn.finance, Tokemak, Alchemix, Rari Capital.
- MINTING: Maker DAO, Frax, Liquity.
- LENDING: AAVE, Compound, Abracadabra, Cream.
- BRIDGE: WBTC.
- SERVICES: Instadapp.
- STAKING: Lido.
- ASSETS: Olympus, H-Tokens.
- DERIVATIVES: synthetix.
- COLLATERAL: Amp.
I tried to put together some information and ideas to help you make a decision.
If I have to choose, I would pick Rust. What I like about Rust is its speed, safety and how it makes it easy to find what is going wrong with the code. Also that Rust is used to code different types of systems, and it is used to code smart contracts on the Solana blockchain. The apps coded on top of Solana can benefit from its high transaction per second speed and low fees, which gives a lot of room to scale and mass adoption.
Thinking a little bit outside of the box, I would pick both, having time to spend. The exposure to a different programming environment and style is invaluable. Plus learning how things are implemented in other blockchain would add to your blockchain fundamentals.
Any way YAGMI.
6 free resources to learn Rust for beginners.
Updated February-16-2022 | 5 min read
7 free resources to learn blockchain fundamentals.
Updated February-21-2022 | 4 min read
The gig crypto-economy is coming to the console, phone, tablet or PC. Earn while you learn, play, create and socialize.
Updated December-26-2021 | 5 min read