Key takeaways
- If you can write the rule down clearly, write it as code: it is cheaper, faster and predictable.
- Language models shine with messy natural language, documents and images, and with generating text.
- Hybrid designs work best: let AI interpret input and let code validate and act on it.
- Consider correctness tolerance, explainability, latency, volume, cost and privacy before choosing.
Once a team has seen what a large language model can do, every problem starts to look like an AI problem. Some are. Many are better solved with a few lines of ordinary code, a database query or a well-tested library. Choosing wrongly costs money, slows the product down and can make it less reliable.
This guide gives you a simple way to decide, written for founders and product owners rather than engineers.
The four options
- Rules and regular code: explicit logic that always gives the same answer for the same input. Tax calculations, discounts, permissions, form validation.
- Existing libraries and services: well-tested tools for common problems, such as address autocomplete, date parsing, spell checking or full-text search.
- Classic machine learning: smaller models trained on your own labelled data for one narrow job, such as predicting churn or flagging likely fraud.
- Large language models (LLMs): general-purpose models that read and write natural language and can handle a wide range of tasks from instructions alone.
Start with one question: can you write the rule?
If a domain expert can explain the decision as clear steps (if this, then that), implement it as code. Code is effectively free to run, returns results in milliseconds, behaves the same way every time and can be tested exhaustively. An LLM asked to apply the same rule will usually get it right, and occasionally get it wrong in ways that are hard to predict.
If the honest answer is “it depends on how the customer phrased it” or “you just have to read it”, you are in the territory where AI helps.
Where language models are the right tool
- Understanding free text: support emails, reviews, chat messages, search queries written in everyday language.
- Reading documents: extracting fields from invoices, contracts, CVs or forms in many layouts.
- Generating text: drafts, summaries, translations, product descriptions.
- Fuzzy matching and ranking: finding similar items or answers based on meaning rather than exact words.
- Handling the long tail: inputs too varied to anticipate with rules.
The criteria that decide it
| Question | Points toward code | Points toward AI |
|---|---|---|
| How structured is the input? | Forms, numbers, fixed options | Free text, documents, images |
| How much error can you tolerate? | None; must always be right | Some, if mistakes are caught |
| Must you explain the decision? | Yes, to customers or regulators | Not in detail |
| How fast must it respond? | Instantly, at high volume | A second or two is fine |
| How often does it run? | Millions of times a day | Occasionally or on demand |
| How sensitive is the data? | Highly sensitive, cannot leave your systems | Can be processed under suitable terms |
No single row decides the matter, but if most answers fall in the left column, AI is probably the wrong tool.
Hybrid designs usually win
The most reliable products combine both approaches, with each doing what it is best at:
- AI interprets, code validates. A model extracts an amount and date from an invoice; code checks the amount is positive, the date is plausible and the supplier exists before saving.
- Code filters, AI ranks. A database query finds all available rentals in the right area and budget; an AI model ranks them against the customer’s free-text description.
- AI suggests, a person confirms. A model drafts a reply or proposes a category, and a staff member accepts or edits it with one click.
- Rules first, AI for the rest. Handle the 80% of cases that follow clear rules in code, and send only the unusual remainder to a model.
When classic machine learning beats an LLM
If you have a narrow, high-volume prediction task and plenty of historical examples with known outcomes, a small trained model can be faster, cheaper and more accurate than a general-purpose LLM. Fraud scoring, demand forecasting and spam filtering are classic examples. The trade-off is that you need good labelled data and some effort to train and monitor the model.
Worked examples
| Feature | Best approach | Why |
|---|---|---|
| VAT and price calculation | Code | Exact rules, must always be correct |
| Sorting support emails by topic | LLM or small classifier | Free text with varied wording |
| Address entry | Existing address library or service | Solved problem, better accuracy |
| Search across listings | Database filters plus semantic ranking | Hybrid: hard filters, fuzzy relevance |
| Product description drafts | LLM with human review | Generation task, quality checked by staff |
| Login and permissions | Code | Security-critical, must be deterministic |
| Spotting duplicate listings | Code for exact matches, embeddings for near-duplicates | Hybrid |
Do not forget the hidden costs
AI features carry costs that rule-based code does not: per-request fees, slower responses, the need for evaluation test sets, monitoring for quality drift when models are updated, and extra privacy review because data leaves your system. These are all manageable, but they should be part of the decision rather than a surprise later.
A quick checklist
- Can a person describe the logic as clear rules? If yes, write code.
- Is there a well-tested library or service for this? If yes, use it.
- Is the input messy language, documents or images? Consider AI.
- Can mistakes be detected and corrected before they cause harm? If not, add review or use code.
- Will it run at very high volume? Check cost and latency, or consider a small trained model.
- Can you combine approaches so code handles the guarantees and AI handles the ambiguity?
If you are weighing up an AI feature for your product, we are happy to talk it through and suggest the simplest design that will work reliably.
Sources and further reading
Written by the Prestigious Software team
We design, build and run web platforms, SaaS products and mobile apps. About us
Our team reviews each article. Claims based on standards or research link to primary sources; examples are illustrative unless identified as client work.



