Rule of Least Power
A design principle from the W3C: when you have a choice, use the least powerful language that can do the job, so the result stays easy to analyze, reuse and transform.
Also known as: Principle of Least Power, Least Power Principle
Category: Principles
Tags: software-design, software-architecture, web, standards, simplicity, principles
Explanation
In 2006, the W3C Technical Architecture Group (TAG) published a finding called "The Rule of Least Power", written by Tim Berners-Lee and Noah Mendelsohn. The idea goes back to the "Principle of Least Power" in Berners-Lee's 1998 notes on web design principles. The finding puts it simply: when publishing on the web, choose the least powerful language suitable for a given purpose.
That sounds backwards at first. Why would you choose LESS power?
**Why less power is often better**:
A powerful language (e.g., a general-purpose programming language) can express anything. The price is that nobody can know what a program does without running it. A less powerful language (e.g., HTML, JSON, CSS, a configuration format) can express much less, but what it does express can be read, searched, validated, transformed and reused by other tools.
Consider a weather forecast:
- **As a JavaScript program** that draws the forecast on screen: only a browser running the code can see the data
- **As a table in HTML**: search engines, screen readers and scrapers can read it
- **As structured data (JSON, RDF)**: any program can extract the temperature for Tuesday
The less powerful the format, the more ways other people and programs can use it.
**Where you see the rule**:
- **Declarative over imperative**: SQL describes the data you want, HTML describes a document, CSS describes styles
- **Data over code**: configuration in JSON or YAML instead of executable scripts
- **Plain text and Markdown** for notes and documentation, instead of proprietary formats only one app can open (see file over app)
- **Regular expressions or parsers** for structured input, instead of arbitrary code
- **Templates with limited logic** (e.g., Mustache) instead of templates that can run anything
**The benefits**:
- **Analyzable**: Tools can check, lint and validate the content without executing it
- **Safer**: Less power means less room for malicious or buggy behavior
- **Reusable**: Other programs can consume the data for purposes the author never imagined
- **Durable**: Simple formats outlive the tools that created them
**Keep in mind**:
The rule says "least powerful language SUITABLE for the purpose". When a simple format can't express what you need, people start encoding logic in strings and comments, and you end up with the worst of both worlds. Choose the simplest option that fits, then stop.
The rule is a cousin of the KISS principle and Make Simple Things Simple, applied to the choice of languages and formats.
Related Concepts
← Back to all concepts