Learning Solana development by building the same programs twice. Once with Pinocchio and once with Anchor.
A collection of Solana programs implemented in both Pinocchio and Anchor to understand what frameworks abstract away. Ideally, to understand what Anchor is doing under the hood and how things actually work.
Goal: Deep understanding through dual implementation.
- Working code - Both implementations fully functional and tested (when marked as done)
- Side-by-side comparisons - Same logic, different approaches
- Real performance data - Compute units, binary sizes, development time
- Honest reflections - What's hard, what's easy, what surprised me
- Testing examples - Using LiteSVM, Mollusk, and Surfpool for fast, isolated tests
1. Vault Program
- Pinocchio (with LiteSVM tests)
- Anchor (in progress)
solana-programs/
├── vault/
│ ├── pinocchio-vault/
│ ├── anchor-vault/
│ └── README.md
├── escrow/
│ ├── pinocchio-escrow/
│ ├── anchor-escrow/
│ └── README.md
├── ...
└── README.md # This file
Each program folder contains:
- Pinocchio implementation - Manual validation, zero-copy, no-std
- Anchor implementation - Macros, automatic validation, IDL
- Comparison README - Side-by-side analysis, learnings, benchmarks
| Aspect | Pinocchio | Anchor |
|---|---|---|
| Learning | How Solana actually works | How to ship fast |
| Control | Complete | Framework-guided |
| Development | Slower, explicit | Faster, implicit |
| Use Case | Core infrastructure, learning | Applications, production |
Building both reveals the trade-offs and teaches the fundamental concepts that frameworks abstract away.
solana --version
rustc --version
anchor --version Pinocchio:
cd <program>/pinocchio-<program>
cargo build-sbf
cargo test -- --show-outputAnchor:
cd <program>/anchor-<program>
anchor build
anchor test- Manual account validation = security fundamentals
- Zero-copy patterns (
&'a AccountInfo) - Explicit CPI mechanics (
invoke_signed) - PDA derivation and signing
- Instruction data parsing (discriminators, serialization)
- Productivity vs control trade-offs
- When abstraction helps vs hurts
- Framework patterns and conventions
- Rapid iteration workflows
All programs use modern, fast testing frameworks:
- LiteSVM: https://www.litesvm.com/docs/getting-started
- Mollusk: https://github.com/anza-xyz/mollusk
- Surfpool:https://surfpool.run/
- Vault (deposit/withdraw SOL)
- Escrow (atomic token swaps)
- AMM (constant product)
- Voting DAO (proposal & voting)
- NFT Staking
- Prediction Market
Part of my learning journey (just weekend and fun stuff). Each program deepens understanding of:
- Account model & ownership
- Deeper understanding of Rust
- Key standard procedures for building performant programs
- Transaction processing
- Runtime mechanics
- Gaining vast knowledge and experience
This is a learning repository, so it'll be filled with lots of comments. Feedback, questions, and corrections are welcome!
- Suggest improvements or corrections
- Please help me test it and comment on improvements
- Ask questions about implementation choices