Hackle's blog
between the abstractions we want and the abstractions we get.
Do programming languages still matter? And is software design an outdated pursuit? From the perspective of agentic-coding enthusiasts, the answer to both questions is a resounding "no." They would claim that agents can unfailingly produce working code in any language, and that humans need not "micromanage" them with judgement about design or review. Ironically, if you ask the agents themselves, they will very likely answer in sensibly modest and restrained ways. No matter: the enthusiasts must be enthusiastic.
For the sake of sanity, we can be old-fashioned and try to assess the claims by producing and observing evidence. What follows is an exercise in giving coding agents unsophisticated instructions to produce a simple program in C#, TypeScript, and Rust, then giving them increasingly opinionated instructions in Rust. We can observe the differences in the output and use them to form an opinion about the role of programming languages and software design.
I gave a coding agent (running on a well-known, non-cheap model) the following instruction, once each for C#, TypeScript, and Rust:
create a small calculator in C# that can add, subtract, divide and multiply numbers from strings.
Below is the sensible C# implementation, in the spirit of EAFP — "Easier to Ask for Forgiveness than Permission." In other words, don't obsess over errors: throw exceptions freely, because someone will handle them (TM).
enum Operation
{
Add,
Subtract,
Multiply,
Divide
}
class Calculator
{
static double Calculate(string a, string b, Operation op)
{
double x = double.Parse(a);
double y = double.Parse(b);
return op switch
{
Operation.Add => x + y,
Operation.Subtract => x - y,
Operation.Multiply => x * y,
Operation.Divide when y != 0 => x / y,
Operation.Divide => throw new DivideByZeroException()
};
}
}
The TypeScript implementation looks equally plausible, with the subtlety of JavaScript where an empty or blank string leads to Number("") == 0. Assuming forgiveness is in generous existence, in fact, trust is in the plentiful from the enthusiasts, one must not be counter-revolutionary to nitpick.
type Operation = "add" | "subtract" | "multiply" | "divide";
function calculate(a: string, b: string, op: Operation): number {
const x = Number(a);
const y = Number(b);
if (!Number.isFinite(x) || !Number.isFinite(y)) {
throw new Error("Invalid numeric input");
}
switch (op) {
case "add": return x + y;
case "subtract": return x - y;
case "multiply": return x * y;
case "divide":
if (y === 0) throw new Error("Division by zero");
return x / y;
}
}
The Rust implementation shows a step-up in soundness: errors are encoded in the return type Result<f64, String>, so errors from either parsing or division by zero are communicated to the caller. (Admittedly, poorly, as the error is "notoriously" stringly-typed. What if the caller wants to highlight the first number in an UI? The best chance with a string is to find if "first" is in the error message. Awkward.)
#[derive(Debug)]
enum Operation {
Add,
Subtract,
Multiply,
Divide,
}
fn calculate(a: &str, b: &str, op: Operation) -> Result<f64, String> {
let x: f64 = a.parse()
.map_err(|_| "Invalid first number".to_string())?;
let y: f64 = b.parse()
.map_err(|_| "Invalid second number".to_string())?;
match op {
Operation::Add => Ok(x + y),
Operation::Subtract => Ok(x - y),
Operation::Multiply => Ok(x * y),
Operation::Divide => {
if y == 0.0 {
Err("Division by zero".to_string())
} else {
Ok(x / y)
}
}
}
}
The takeaway from this round of output, is that the paradigm of Rust as the language, or the culture of its community, is intrinsically different from that of C# or TypeScript. In the specific case of error handling, an unsophisticated "prompter" will get the "sensible" default, and knowingly or unknowingly accept the impossibility of exhaustive error handling, which is an accepted baseline for any decent Rust codebase.
Is it possible to instruct agents to produce equally sound solutions in C# or TypeScript? After seeing the comparison, someone without design literacy might prompt them to "catch and handle all exceptions," perhaps pointing to specific function names or line numbers, with some yelling sprinkled in for good measure.
However, one with sufficient literacy in design would simply ask,
make the code total
That brings us to the updated TypeScript implementation:
enum Operation {
Add = "add",
Subtract = "subtract",
Multiply = "multiply",
Divide = "divide"
}
type CalculationError =
| "InvalidFirstNumber"
| "InvalidSecondNumber"
| "DivisionByZero"
| "InvalidOperation";
type Result<T, E> =
| { ok: true; value: T }
| { ok: false; error: E };
function calculate(
a: string,
b: string,
op: Operation | string
): Result<number, CalculationError> {
const x = Number(a);
const y = Number(b);
if (a.trim() === "" || !Number.isFinite(x)) {
return { ok: false, error: "InvalidFirstNumber" };
}
if (b.trim() === "" || !Number.isFinite(y)) {
return { ok: false, error: "InvalidSecondNumber" };
}
switch (op) {
case Operation.Add:
return { ok: true, value: x + y };
case Operation.Subtract:
return { ok: true, value: x - y };
case Operation.Multiply:
return { ok: true, value: x * y };
case Operation.Divide:
return y === 0
? { ok: false, error: "DivisionByZero" }
: { ok: true, value: x / y };
default:
return { ok: false, error: "InvalidOperation" };
}
}
Alas, the word "total" seems to have worked wonders: the agent adds a union of errors and prevents empty or blank strings from entering the calculation. A sharp reader might also spot sillinesses, such as checking the input strings after converting them to numbers and using an enum instead of a union of string literals. But one mustn't get too riled up in this age of relaxation. "Serenity now!"
The takeaway from this round: not all prompts or prompters are equal. A prompter with greater design literacy (and if you think design is just about aesthetics, take note) who also cares about the work can write a more effective prompt and get more resilient software.
Rust is having its moment, with euphoric headlines like "Rewrite to Rust!" One-shot agentic rewrites are also flooding the industry, giving the impression that Rust cures all of software's problems. Not exactly.
Suppose we need to add a requirement to track illegal operations in the calculator. A spec-driven enthusiast (pretend, obviously) might ask:
support the scenario of invalid operations.
That brings us to the updated solution:
#[derive(Debug)]
enum Operation {
Add,
Subtract,
Multiply,
Divide,
Invalid,
}
#[derive(Debug)]
enum CalculationError {
InvalidFirstNumber,
InvalidSecondNumber,
DivisionByZero,
InvalidOperation,
}
fn calculate(
a: &str,
b: &str,
op: Operation,
) -> Result<f64, CalculationError> {
let x: f64 = a.parse()
.map_err(|_| CalculationError::InvalidFirstNumber)?;
let y: f64 = b.parse()
.map_err(|_| CalculationError::InvalidSecondNumber)?;
match op {
Operation::Add => Ok(x + y),
Operation::Subtract => Ok(x - y),
Operation::Multiply => Ok(x * y),
Operation::Divide if y != 0.0 => Ok(x / y),
Operation::Divide => Err(CalculationError::DivisionByZero),
Operation::Invalid => Err(CalculationError::InvalidOperation),
}
}
(You may question my integrity and accuse me of being disingenuous for giving such obviously problematic prompts. But this is a close approximation of a pattern I've seen twice in the last two weeks, in both Rust and Kotlin, almost certainly with more sophisticated prompting and planning on more powerful models.)
Surprisingly (not really; these are probabilistic machines), the same agent became more vigilant and created tagged error cases. However, that doesn't free it from the bad decision to group the invalid operation with the existing operations instead of tying the new error to the Operation type.
We can rightly blame the vague, ambiguous prompt and promise to be more vigilant next time. But the takeaway from this final round is that even powerful models cannot save us from bad judgement—or from wishful prompters who can't specify requirements accurately, trust too naively, lack motivation, or simply can't be arsed to review the output.
I will understand if the enthusiasts view this as a feeble or ill-advised attempt at nitpicking the unstoppable take-over by the new omni-potent. That would be mistaken. The intended message is to not throw away good judgement or any attempts at it; in the end, when it matters most, judgement is all we have.