Gas exists so that a public network cannot be shut down by an infinite loop: execution is metered, and when the budget runs out the transaction stops and reverts. Since every user pays for the work their call performs, efficiency stops being a craft preference and becomes something the user feels directly.
It reshapes design in ways that surprise people. Storing data on-chain is expensive enough that most applications store a reference and keep the payload elsewhere; loops over unbounded arrays are a denial-of-service waiting to happen; and a function that is pleasant to read can cost several times one that is not. This is why gas reporting belongs in the test suite rather than in a review at the end.
Related terms
The bench this belongs to
BlockchainSolidity on Ethereum, Polygon, Base and Arbitrum. Anchor programs on Solana. Written with tests first, because a redeploy is not a hotfix once value is on the line.
