When You Do Not Need AI: Choosing Between an LLM and Plain Code
A pragmatic checklist for deciding whether a feature needs a language model, deterministic code, or a hybrid of both.
The fastest way to make an app slower, more expensive, and less predictable is to put an LLM where an if-statement belongs. The second fastest is to spend three weeks hand-coding heuristics for a problem a model solves in one prompt. Knowing which situation you are in is becoming a core engineering skill.
Here is the decision framework I use when a feature request lands and someone asks: "should we use AI for this?"
Use plain code when the rules are knowable
If you can write down the rules completely, write them down as code. Validation, pricing, routing, permissions, date math, anything with a spec, belongs in deterministic code. It is faster (microseconds vs seconds), free per call, testable, and it fails loudly instead of confidently making things up.
Use an LLM when the input is human
LLMs earn their cost where the input is unstructured language and the rules cannot be enumerated: summarizing a support thread, extracting fields from messy emails, drafting a reply, classifying free-text feedback. If your alternative is a pile of regexes that break weekly, the model is usually the simpler system.
The hybrid pattern that usually wins
The strongest designs use the model as a narrow translator at the boundary, and plain code everywhere else: the LLM turns unstructured input into a validated, structured object, and deterministic code makes every decision after that.
// 1. LLM: messy human input -> structured data (validated!)
const parsed = refundRequestSchema.parse(
await extractWithLLM(customerEmail)
);
// 2. Plain code: the actual business decision
const decision = evaluateRefundPolicy(parsed, order);Questions to ask before adding a model call
- Can I write the complete rules? If yes, use code.
- Is a wrong answer acceptable and recoverable? If no, the model can propose but code (or a human) must decide.
- Does this run on every request, or occasionally? Per-request model calls need a latency and cost budget.
- How will I test it? If you cannot build a small evaluation set, you cannot maintain it.
The takeaway
AI is not the feature; it is one more tool with an unusual trade-off profile: flexible but slow, capable but probabilistic, cheap to build with but easy to overspend on. Use it exactly where that profile fits, keep it behind validation, and let boring code do what boring code does best.
Want to talk about a project?
Get in touch