Blog / AI and automation

When to use AI and when plain code is better

/2 min read/Trill Codes

AI is powerful but probabilistic. Plain code is predictable and cheap. A practical way to decide which one each step of a workflow should use.

AI and automation

When a new tool is exciting, it is tempting to use it for everything. AI is no exception. But many steps in a workflow are better handled by ordinary code, and knowing the difference is one of the most useful skills in building automation.

What each is good at

Plain code does exactly what it is told, the same way every time. It is fast, cheap to run, easy to test, and easy to explain. It is ideal for anything with clear rules: arithmetic, formatting, sorting, checking a value against a limit, moving data between systems.

AI models are good at work that is fuzzy: reading text written by people, summarizing, drafting, classifying things that do not fit neat categories, and making a reasonable guess when the rules are unclear. In exchange, they are slower, cost more per step, and can be wrong in ways that are hard to predict.

A simple test

For each step, ask: could I write down the rule?

  • If yes, write the rule as code. "Reject any order over the credit limit" does not need AI.
  • If the rule exists but has endless exceptions, AI can help with the exceptions while code handles the clear cases.
  • If there is no rule, only judgment, such as "is this email a complaint?", AI is a good fit, ideally with a way to check or review its answer.

Use code to check AI

The strongest designs combine the two. Let AI do the fuzzy part, then use plain code to check the result before it moves on. If an AI step extracts a price from a document, code can confirm it is a number in a sensible range. If an AI writes a product title, code can check its length and that it contains the required words. Each check catches a class of mistakes for almost no cost.

Cost and speed add up

A single AI call is cheap. A workflow that makes thousands of them a day is not. Every step that can be plain code instead saves money and time, and makes the whole system easier to debug. We think of AI as the expensive specialist on a team: you bring it in for the parts that need it, not to sort the mail.

That is a principle we hold ourselves to at Trill Codes. As we put it on our about page: AI is a tool, not the point.

Trill Codes

Useful software for complicated work.

See what Trill Codes has launched and what is in development, or get in touch.