Independent discussion of crypto, wallets, cards and markets
Forum Home > Learning & Discussion > Concepts & Explainers > Solidity in an hour: the language that writes the contracts
Solidity in an hour: the language that writes the contracts172 replies · 12,512 views
Thread ToolsShow Printable Version · Subscribe to this Thread · Search Thread
Where to open an account: Open a Trustee account.

Solidity in an hour: the language that writes the contracts

What Solidity is

Solidity is the programming language of smart contracts on EVM-compatible chains - the layer between human intent and bytecode. It is a statically typed, contract-oriented language: programs are collections of contracts - state variables, functions, events, and modifiers - that compile to EVM bytecode and execute on every node deterministically. The language's design priorities are unusual and explainable: gas efficiency shapes syntax and semantics, immutability shapes upgrade patterns, and the execution environment's constraints - no hidden threads, no external calls without cost, no unbounded loops - shape what programs can look like at all. Learning Solidity is learning a language designed for a machine that runs the same code everywhere and charges for every operation.

The language's core structure

  • Contracts as units: a Solidity program is a set of contract definitions - each with its own state, functions, and events - and deployment places one contract's bytecode at an address. Contracts call each other through interfaces, and the call structure is how protocols compose: token contracts, exchange contracts, and governance contracts interact through defined function signatures.
  • State and storage: state variables - balances, ownership records, configuration - live in persistent storage, and storage access is the most expensive operation contracts perform. The language's storage model is explicit: variables occupy storage slots in declaration order, and the layout is part of the contract's behavior - changing it changes what data means, which is why storage layout discipline is an upgrade-safety practice.
  • Functions and visibility: functions carry visibility - public, external, internal, private - that controls who can call them, and the visibility system is the contract's access-control surface. Public functions are the contract's API; internal functions are its plumbing; and the distinction is enforced at the bytecode level, not by convention.
  • Events and errors: contracts emit events for external observation and use require statements and custom errors for validation - the language's two reporting channels: events for the world's benefit, errors for the transaction's benefit. A failed require reverts the entire transaction and refunds unused gas, which is why validation is cheap for the sender and absolute for the contract.

The safety patterns the language enforces

  • Checks-effects-interactions: the canonical Solidity pattern - validate first, update state second, call external contracts last - exists because external calls can re-enter the calling contract, and the ordering prevents reentrancy exploits. The pattern is the language's most famous safety convention, and its absence is the most famous bug class in contract history.
  • Modifiers and inheritance: modifiers wrap function execution with precondition checks - only-owner, when-not-paused - and inheritance lets contracts extend each other with shared behavior. The systems are convenience features with security weight: modifier order and inheritance diamonds affect behavior, and the language's multiple-inheritance model requires explicit override declarations to keep semantics unambiguous.

What the language does not give you

The learning path that works

The takeaway

Solidity is a contract-oriented language shaped by its execution environment: persistent storage with explicit layouts, visibility-enforced APIs, event-based observation, revert-based validation, and gas-priced operations that make every design choice an economic one. Its safety culture - checks-effects-interactions, explicit overrides, checked arithmetic by default - is written in the language's history of failures and fixes, and its limits - no threads, no external data, no undo, no free loops - are the execution environment's constraints made lexical. Learning it means learning a language where compiling is necessary but not sufficient, where the compiler checks types and auditors check everything else, and where the canonical texts are deployed contracts rather than documentation. The language writes the contracts; the execution environment writes the language; and both are shaped by the same fact: the code runs everywhere at once, forever, and charges for every byte of it.

Thread Statistics172 replies · 12,512 views