<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vanius Roberto Bittencourt on Medium]]></title>
        <description><![CDATA[Stories by Vanius Roberto Bittencourt on Medium]]></description>
        <link>https://medium.com/@vanius?source=rss-3ba69d7a33d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_Sv9yvJ_StLe14TqVHpNzw.jpeg</url>
            <title>Stories by Vanius Roberto Bittencourt on Medium</title>
            <link>https://medium.com/@vanius?source=rss-3ba69d7a33d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:31:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vanius/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Go Team Says AI Needs Guardrails. That’s an Argument for Rust.]]></title>
            <link>https://medium.com/@vanius/the-go-team-says-ai-needs-guardrails-thats-an-argument-for-rust-31a4d5382e7b?source=rss-3ba69d7a33d------2</link>
            <guid isPermaLink="false">https://medium.com/p/31a4d5382e7b</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vanius Roberto Bittencourt]]></dc:creator>
            <pubDate>Wed, 12 Aug 2026 18:09:52 GMT</pubDate>
            <atom:updated>2026-08-12T18:09:52.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r8y8gqu8kGrigUlhavCRiQ.jpeg" /></figure><p>Go’s compiler asks whether the code compiles. Rust’s asks whether it should be allowed to exist — and that is the loop an AI teammate actually needs.</p><p>Yesterday the official Go account posted:</p><blockquote><em>AI is your newest teammate — a hyper-productive contributor that requires strong guardrails to succeed. Read more on why this partnership makes your choice of programming language more important than ever, and why Go’s early focus on collaboration and reliability makes it an ideal choice for AI-assisted software engineering.</em></blockquote><p>The post points at a Google Developers Blog piece by Cameron Balahan and Richard Seroter: <a href="https://developers.googleblog.com/why-go-is-an-ideal-language-for-ai-assisted-software-engineering/"><em>Why Go is an Ideal Language for AI-Assisted Software Engineering</em></a>.</p><p>The diagnosis is right. The language they pick is the wrong one.</p><p>If AI is a hyper-productive junior who writes faster than you can think, you do not want the language whose compiler is famous for letting structural bugs through. You want the language whose compiler was built to refuse them.</p><p>That language is Rust. The rest of this piece is the proof, in code.</p><h3>Steal their premise. It does not help Go.</h3><p>The blog’s core claim is fair, and I agree with all of it:</p><ol><li>Humans now <strong>review</strong> more than they type.</li><li>The bottleneck is verification, not generation.</li><li>An agent that iterates without a tight feedback loop pollutes its own context.</li><li>You need <strong>deterministic guardrails</strong>: format, types, tests, supply-chain checks.</li><li>Language choice matters <em>more</em> when the author is a model.</li></ol><p>Then the article says Go’s static types, gofmt, the standard library, and a fast compiler are those guardrails.</p><p>Read that list again. Almost none of it is about the bugs AI actually ships.</p><p>A model does not struggle to run gofmt. It struggles to keep ownership straight, to treat absence as absence, to not ignore an error, to not mutate the same memory from two tasks, to not return a value that looks initialized and isn’t. Those are not style problems. They are <strong>structural</strong> problems. Go’s compiler is polite about them. Rust’s compiler is not.</p><p>The blog even writes this sentence:</p><blockquote><em>If an AI agent attempts to use a non-existent method, pass an incorrect type, or leave a variable uninitialized, the code simply will not compile.</em></blockquote><p>The first two are true in any static language. The third is the tell. <strong>Go does not reject uninitialized variables.</strong> It zero-fills them.</p><pre>package main</pre><pre>import &quot;net/http&quot;</pre><pre>func main() {<br>    var client *http.Client          // compiles: zero value is nil<br>    resp, err := client.Get(&quot;https://example.com&quot;) // panic at runtime<br>    _, _ = resp, err<br>}</pre><p>Rust is the language that actually refuses to let the agent leave a value unset.</p><pre>use reqwest::blocking::Client;</pre><pre>fn main() {<br>    let client: Client; // error: used binding `client` isn&#39;t initialized<br>    let _ = client.get(&quot;https://example.com&quot;).send();<br>}</pre><p>Miss a field and rustc names it:</p><pre>struct User {<br>    id: u64,<br>    email: String,<br>}</pre><pre>fn main() {<br>    // error: missing field `email` in initializer of `User`<br>    let _u = User { id: 1 };<br>}</pre><p>That is the whole essay in one example. Go markets the compiler as a safety net. Rust <em>is</em> the safety net.</p><h3>What an AI teammate is, mechanically</h3><p>An agent is a loop:</p><ol><li>Write code it is only mostly sure about.</li><li>Compile / lint / test.</li><li>Read the error.</li><li>Patch.</li><li>Repeat until green.</li></ol><p>Two properties dominate that loop.</p><p><strong>Signal.</strong> Does the toolchain reject the <em>class</em> of bug the model just invented, or only the typo? A type error on a missing method is cheap. A data race that compiles, a typed-nil error that compiles, a slice alias that compiles — those survive the loop and land in the PR.</p><p><strong>Cost of a turn.</strong> Faster compile wins more iterations per minute. Go is faster than rustc. That is real. It is also the weakest kind of guardrail: more chances to generate a program that is <em>well-typed and still wrong</em>.</p><p>Agentic development does not reward the language that is easiest to emit. It rewards the language that <strong>makes the wrong program unrepresentable</strong>, then yells in a way the model can parse. rustc error messages are long, local, and actionable. They are, accidentally, an outstanding agent API. clippy is a second agent that already knows the house style.</p><p>Go’s loop is: <em>does it compile?</em><br>Rust’s loop is: <em>is this allowed to exist?</em></p><p>Those are not the same question. The second is what “strong guardrails” actually means.</p><h3>The traps your AI teammate will write in Go</h3><p>These are not theoretical. They are the default shape of LLM-generated Go: nils, ignored err, shared slices, goroutines over a loop variable, an interface that “isn’t nil,” a mutex copied by value, a JSON false that meant “missing.” Rust’s type system deletes the category.</p><h3>1. Null pointer exceptions</h3><p><strong>The Go trap.</strong> nil is everywhere: pointers, slices, maps, channels, functions, interfaces. One missed check and you get:</p><pre>panic: runtime error: invalid memory address or nil pointer dereference</pre><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>type User struct {<br>    Name string<br>}</pre><pre>func display(u *User) {<br>    fmt.Println(u.Name) // panics if u == nil<br>}</pre><pre>func main() {<br>    var u *User<br>    display(u)<br>}</pre><p><strong>How Rust secures it.</strong> There is no null. Absence is Option&lt;T&gt;. You cannot touch the inner value without matching, if let, or an explicit unwrap() that panics on purpose.</p><pre>struct User {<br>    name: String,<br>}</pre><pre>fn display(u: Option&lt;&amp;User&gt;) {<br>    match u {<br>        Some(user) =&gt; println!(&quot;{}&quot;, user.name),<br>        None =&gt; println!(&quot;(no user)&quot;),<br>    }<br>}</pre><pre>fn main() {<br>    let u: Option&lt;User&gt; = None;<br>    display(u.as_ref()); // compiles, no panic<br>    // println!(&quot;{}&quot;, u.name); // error: `Option&lt;User&gt;` has no field `name`<br>}</pre><p>Raw pointers can still be null, but only inside unsafe. In safe Rust, “empty pointer” is not a silent state.</p><h3>2. Data races</h3><p><strong>The Go trap.</strong> Any goroutine can mutate shared memory. The race detector is excellent and still optional. A data race is undefined behavior that may pass tests for months.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>func main() {<br>    n := 0<br>    done := make(chan struct{})</pre><pre>    go func() {<br>        n++ // write<br>        close(done)<br>    }()</pre><pre>    fmt.Println(n) // concurrent read — compiles, race at runtime<br>    &lt;-done<br>}</pre><p>go run -race may catch this. go run will not. Agents do not reliably add -race to the loop.</p><p><strong>How Rust secures it.</strong> The borrow checker plus Send / Sync make shared mutable state a compile error unless you wrap it in a type that serializes access.</p><pre>use std::thread;</pre><pre>fn main() {<br>    let mut n = 0;</pre><pre>    thread::spawn(move || {<br>        n += 1;<br>    });</pre><pre>    // error: borrow of moved value: `n`<br>    println!(&quot;{n}&quot;);<br>}</pre><p>The legal version is explicit about sharing:</p><pre>use std::sync::{Arc, Mutex};<br>use std::thread;</pre><pre>fn main() {<br>    let n = Arc::new(Mutex::new(0));<br>    let n2 = Arc::clone(&amp;n);</pre><pre>    let h = thread::spawn(move || {<br>        *n2.lock().unwrap() += 1;<br>    });</pre><pre>    h.join().unwrap();<br>    println!(&quot;{}&quot;, *n.lock().unwrap());<br>}</pre><p>Precision matters: Rust prevents <strong>data races</strong>, not every logical race. Deadlocks still exist. What disappears is “two threads wrote this int at the same time and now memory is garbage.”</p><p>An agent that “just adds a goroutine” is the most common Go footgun I see in generated PRs. In Rust that patch often does not compile.</p><h3>3. Implicit zero-value initialization</h3><p><strong>The Go trap.</strong> Every type has a zero value. var u User is a valid User with empty strings, 0, and nil pointers. That looks initialized. It often isn’t.</p><pre>package main</pre><pre>import &quot;net/http&quot;</pre><pre>type Config struct {<br>    BaseURL string<br>    Client  *http.Client<br>}</pre><pre>func fetch(cfg Config) {<br>    // cfg.Client is nil unless the caller remembered to set it<br>    _, _ = cfg.Client.Get(cfg.BaseURL)<br>}</pre><pre>func main() {<br>    fetch(Config{BaseURL: &quot;https://example.com&quot;}) // compiles, panics<br>}</pre><p><strong>How Rust secures it.</strong> Nothing is used before it is initialized. Miss a struct field and the compiler stops you. Default exists, but you opt in.</p><pre>struct Config {<br>    base_url: String,<br>    client: reqwest::blocking::Client,<br>}</pre><pre>fn fetch(cfg: Config) {<br>    let _ = cfg.client.get(&amp;cfg.base_url).send();<br>}</pre><pre>fn main() {<br>    // error: missing field `client` in initializer of `Config`<br>    fetch(Config {<br>        base_url: &quot;https://example.com&quot;.into(),<br>    });<br>}</pre><p>If you <em>want</em> a default, you say so:</p><pre>#[derive(Default)]<br>struct Flags {<br>    verbose: bool,<br>    retries: u32,<br>}</pre><pre>let flags = Flags::default(); // explicit, not accidental</pre><h3>4. Ignored errors</h3><p><strong>The Go trap.</strong> f, err := os.Open(path) is a social contract. The compiler does not care if you write _ = err or reuse a previous err. Entire outages start with one unchecked err.</p><pre>package main</pre><pre>import (<br>    &quot;fmt&quot;<br>    &quot;os&quot;<br>)</pre><pre>func main() {<br>    f, err := os.Open(&quot;missing.txt&quot;)<br>    // agent &quot;handles&quot; it by printing, then uses f anyway<br>    if err != nil {<br>        fmt.Println(&quot;open failed:&quot;, err)<br>    }<br>    buf := make([]byte, 16)<br>    _, _ = f.Read(buf) // panic: invalid memory address or nil pointer dereference<br>}</pre><p>Worse, the compile-clean version that just drops the error:</p><pre>f, _ := os.Open(&quot;missing.txt&quot;)<br>stat, _ := f.Stat()<br>fmt.Println(stat.Size())</pre><p><strong>How Rust secures it.</strong> Recoverable failure is Result&lt;T, E&gt;. You cannot use T without handling E. Result is #[must_use].</p><pre>use std::fs::File;<br>use std::io::{self, Read};</pre><pre>fn read_head(path: &amp;str) -&gt; io::Result&lt;[u8; 16]&gt; {<br>    let mut f = File::open(path)?; // no File unless open succeeded<br>    let mut buf = [0u8; 16];<br>    f.read_exact(&amp;mut buf)?;<br>    Ok(buf)<br>}</pre><pre>fn main() {<br>    match read_head(&quot;missing.txt&quot;) {<br>        Ok(buf) =&gt; println!(&quot;{buf:?}&quot;),<br>        Err(e) =&gt; eprintln!(&quot;open/read failed: {e}&quot;),<br>    }</pre><pre>    // warning: unused `Result` that must be used<br>    // File::open(&quot;missing.txt&quot;);<br>}</pre><p>You can still write .unwrap() or let _ =. Those are visible, greppable choices — not the default shape of the language. Agents are <em>excellent</em> at forgetting Go’s second return value. A culture of if err != nil is not a guardrail. A type is.</p><h3>5. Weak enum type safety</h3><p><strong>The Go trap.</strong> iota constants are just integers. A Status of 4 compiles even if you only defined 0..3. switch is not exhaustive. A new variant is a silent fallthrough waiting to happen.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>type Status int</pre><pre>const (<br>    Ready Status = iota<br>    Failed<br>    Retrying<br>)</pre><pre>func label(s Status) string {<br>    switch s {<br>    case Ready:<br>        return &quot;ready&quot;<br>    case Failed:<br>        return &quot;failed&quot;<br>    // forgot Retrying — compiles, returns &quot;unknown&quot;<br>    default:<br>        return &quot;unknown&quot;<br>    }<br>}</pre><pre>func main() {<br>    fmt.Println(label(Status(99))) // compiles: 99 is a Status<br>}</pre><p><strong>How Rust secures it.</strong> Enums are algebraic data types. Each variant can carry different data. match must be exhaustive.</p><pre>enum Status {<br>    Ready,<br>    Failed(String),<br>    Retrying { attempt: u32 },<br>}</pre><pre>fn label(s: &amp;Status) -&gt; String {<br>    match s {<br>        Status::Ready =&gt; &quot;ready&quot;.into(),<br>        Status::Failed(msg) =&gt; format!(&quot;failed: {msg}&quot;),<br>        Status::Retrying { attempt } =&gt; format!(&quot;retry #{attempt}&quot;),<br>        // forget a variant and this function will not compile<br>    }<br>}</pre><pre>fn main() {<br>    // Status(99) is not a thing<br>    println!(&quot;{}&quot;, label(&amp;Status::Retrying { attempt: 3 }));<br>}</pre><p>Add a variant later and every match the agent forgot to update becomes a compile error — a task list, not a production surprise.</p><h3>6. Typed-nil interfaces — the “error that isn’t nil”</h3><p>This is the trap behind most “Go error nil dereference” searches, and the one agents reproduce constantly.</p><p><strong>The Go trap.</strong> Interfaces are a type plus a value. A nil concrete pointer boxed into an interface is a <strong>non-nil</strong> interface.</p><pre>package main</pre><pre>import (<br>    &quot;fmt&quot;<br>    &quot;os&quot;<br>)</pre><pre>func boom() error {<br>    var err *os.PathError = nil<br>    return err // err != nil is TRUE — the interface holds (*os.PathError, nil)<br>}</pre><pre>func main() {<br>    err := boom()<br>    if err != nil {<br>        fmt.Println(err.Error()) // panic: nil pointer dereference<br>    }<br>}</pre><p>The check passes. The method call panics. The stack looks insane until you remember the interface layout.</p><p><strong>How Rust secures it.</strong> There is no split “type word / value word” that can disagree. Result&lt;T, E&gt; has one meaning.</p><pre>use std::io;</pre><pre>fn boom() -&gt; Result&lt;(), io::Error&gt; {<br>    Ok(()) // missing failure is Ok, not &quot;an error whose payload is empty&quot;<br>}</pre><pre>fn main() {<br>    match boom() {<br>        Ok(()) =&gt; println!(&quot;ok&quot;),<br>        Err(e) =&gt; println!(&quot;{}&quot;, e),<br>    }<br>}</pre><p>If you need “maybe an error type,” you write Option&lt;io::Error&gt; or Result&lt;T, E&gt; — never a third state called “the wrapper says error, the payload says nothing.”</p><h3>7. Implicit interfaces (duck typing)</h3><p><strong>The Go trap.</strong> If a type has the right methods, it implements the interface. Convenient, and a refactor landmine. Change a method on the interface and the breakage shows up at some distant call site — or in a mock the agent invented — not at the type definition.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>type Greeter interface {<br>    Greet() string<br>}</pre><pre>type User struct{ Name string }</pre><pre>func (u User) Greet() string { return &quot;hi &quot; + u.Name }</pre><pre>func hello(g Greeter) { fmt.Println(g.Greet()) }</pre><pre>func main() {<br>    hello(User{Name: &quot;Ada&quot;}) // implicit: User has Greet, so it is a Greeter<br>}</pre><p>Rename Greet to Hello on the interface. User still compiles. The failure is wherever something <em>needed</em> a Greeter — often a test fake three packages away.</p><p><strong>How Rust secures it.</strong> Traits are implemented explicitly.</p><pre>trait Greeter {<br>    fn greet(&amp;self) -&gt; String;<br>}</pre><pre>struct User {<br>    name: String,<br>}</pre><pre>impl Greeter for User {<br>    fn greet(&amp;self) -&gt; String {<br>        format!(&quot;hi {}&quot;, self.name)<br>    }<br>}</pre><pre>fn hello&lt;G: Greeter&gt;(g: G) {<br>    println!(&quot;{}&quot;, g.greet());<br>}</pre><pre>fn main() {<br>    hello(User { name: &quot;Ada&quot;.into() });<br>}</pre><p>Change greet to hello on the trait and the compiler points at impl Greeter for User. For an agent rewriting an API, that list is the task queue. No structural surprise.</p><p>(Go’s implicit interfaces are a real productivity feature. The cost is exactly this nonlocal breakage.)</p><h3>8. Loop variable capture</h3><p><strong>The Go trap.</strong> Until Go 1.22, the loop variable was <strong>one</strong> variable reused every iteration. Closures and goroutines captured the same address and all saw the last value.</p><pre>package main</pre><pre>import (<br>    &quot;fmt&quot;<br>    &quot;sync&quot;<br>)</pre><pre>func main() {<br>    nums := []int{1, 2, 3}<br>    var wg sync.WaitGroup</pre><pre>    for _, n := range nums {<br>        wg.Add(1)<br>        go func() {<br>            defer wg.Done()<br>            fmt.Println(n) // pre-1.22: 3, 3, 3<br>        }()<br>    }<br>    wg.Wait()<br>}</pre><p>Go 1.22 fixed the language. Old modules, old tutorials, and a decade of training data still ship this bug. Agents copy the old pattern by default.</p><p><strong>How Rust secures it.</strong> Each iteration’s bindings are a new scope. Closures that need the value move or copy it.</p><pre>use std::thread;</pre><pre>fn main() {<br>    let nums = [1, 2, 3];<br>    let mut handles = vec![];</pre><pre>    for n in nums {<br>        handles.push(thread::spawn(move || {<br>            println!(&quot;{n}&quot;); // 1, 2, 3 — `n` is this iteration&#39;s value<br>        }));<br>    }</pre><pre>    for h in handles {<br>        h.join().unwrap();<br>    }<br>}</pre><p>There is no hidden shared cell behind for x in xs.</p><h3>9. Shared slice mutability</h3><p><strong>The Go trap.</strong> Slices are fat pointers into a backing array. Two slices can alias the same memory. append may or may not reallocate. Mutation through one slice silently changes the other.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>func main() {<br>    a := []int{1, 2, 3}<br>    b := a[:2]<br>    b = append(b, 99) // often overwrites a[2] — no realloc if cap(b) &gt; len(b)<br>    fmt.Println(a)    // [1 2 99]<br>    fmt.Println(b)    // [1 2 99]<br>}</pre><p>Agents love b := a[:n] followed by append. The program is well-typed. The data is not what the reviewer thinks it is.</p><p><strong>How Rust secures it.</strong> You may have many shared references (&amp;[T]) <strong>or</strong> one mutable reference (&amp;mut [T]), never both.</p><pre>fn main() {<br>    let mut a = vec![1, 2, 3];<br>    let b = &amp;a[..2];</pre><pre>    // a.push(99);<br>    // error: cannot borrow `a` as mutable because it is also borrowed as immutable</pre><pre>    println!(&quot;{b:?}&quot;);<br>    drop(b);    // read borrow ends<br>    a.push(99); // exclusive again — new allocation, old views gone<br>    println!(&quot;{a:?}&quot;);<br>}</pre><p>If you need two independent buffers, you copy. The type system will not let the agent pretend a view is a clone.</p><h3>10. Naked named returns</h3><p><strong>The Go trap.</strong> Named result parameters plus a bare return invent a second, invisible assignment path. Combine that with defer mutating err and you get functions nobody can review on Friday — exactly the kind of thing an agent produces because the training set is full of it.</p><pre>package main</pre><pre>import (<br>    &quot;io&quot;<br>    &quot;os&quot;<br>)</pre><pre>func load(path string) (data []byte, err error) {<br>    f, err := os.Open(path)<br>    if err != nil {<br>        return // returns named err — easy to miss what actually goes out<br>    }<br>    defer func() {<br>        if cerr := f.Close(); err == nil {<br>            err = cerr // silent rewrite of the return slot<br>        }<br>    }()<br>    data, err = io.ReadAll(f)<br>    return<br>}</pre><p><strong>How Rust secures it.</strong> There are no named return slots. You return a value: the last expression, or return expr. Cleanup is Drop, which cannot quietly rewrite a hidden result variable.</p><pre>use std::fs::File;<br>use std::io::{self, Read};</pre><pre>fn load(path: &amp;str) -&gt; io::Result&lt;Vec&lt;u8&gt;&gt; {<br>    let mut f = File::open(path)?;<br>    let mut data = Vec::new();<br>    f.read_to_end(&amp;mut data)?;<br>    Ok(data) // File is dropped here; no hidden err slot to mutate<br>}</pre><p>Rust <em>does</em> have a return keyword. What it does not have is Go’s bare return that means “stuff whatever is currently in the named outs.”</p><h3>11. Writing to a nil map</h3><p><strong>The Go trap.</strong> A map’s zero value is nil. Reads return the zero value. Writes panic. Agents declare var m map[K]V, forget make, and ship a landmine that only explodes on the first insert.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>func index(names []string) map[string]int {<br>    var out map[string]int // nil, not empty<br>    for i, n := range names {<br>        out[n] = i // panic: assignment to entry in nil map<br>    }<br>    return out<br>}</pre><pre>func main() {<br>    fmt.Println(index([]string{&quot;ada&quot;}))<br>}</pre><p><strong>How Rust secures it.</strong> There is no nil HashMap. HashMap::new() is empty and writable. You cannot have “a map that looks like a map and explodes when you use it.”</p><pre>use std::collections::HashMap;</pre><pre>fn index(names: &amp;[&amp;str]) -&gt; HashMap&lt;String, usize&gt; {<br>    let mut out = HashMap::new(); // always usable<br>    for (i, n) in names.iter().enumerate() {<br>        out.insert((*n).into(), i);<br>    }<br>    out<br>}</pre><pre>fn main() {<br>    println!(&quot;{:?}&quot;, index(&amp;[&quot;ada&quot;]));<br>}</pre><p>If you want a map you have not created yet, that is Option&lt;HashMap&lt;K, V&gt;&gt; — absence is a type, not a panic.</p><h3>12. Copying a mutex</h3><p><strong>The Go trap.</strong> sync.Mutex is a value. Embed it in a struct, pass the struct by value, or write a method on T instead of *T, and you lock a <strong>copy</strong>. The original is never released. The program compiles. Then it deadlocks, or the counter never increments.</p><pre>package main</pre><pre>import &quot;sync&quot;</pre><pre>type Counter struct {<br>    mu sync.Mutex<br>    n  int<br>}</pre><pre>func (c Counter) Inc() { // agent forgot the pointer receiver<br>    c.mu.Lock()<br>    c.n++<br>    c.mu.Unlock()<br>}</pre><pre>func main() {<br>    var c Counter<br>    c.Inc()<br>    c.Inc()<br>    // c.n is still 0 — we mutated a copy, including its mutex<br>}</pre><p>The same bug shows up as func worker(c Counter) or jobs := []Counter{c} — anything that copies the lock.</p><p><strong>How Rust secures it.</strong> Mutex&lt;T&gt; is not Copy. You cannot accidentally duplicate a lock. Sharing is Arc&lt;Mutex&lt;T&gt;&gt;. Moving is a transfer, not a clone.</p><pre>use std::sync::{Arc, Mutex};</pre><pre>struct Counter {<br>    n: Mutex&lt;i32&gt;,<br>}</pre><pre>impl Counter {<br>    fn inc(&amp;self) {<br>        *self.n.lock().unwrap() += 1;<br>    }<br>}</pre><pre>fn main() {<br>    let c = Arc::new(Counter { n: Mutex::new(0) });<br>    c.inc();<br>    c.inc();<br>    assert_eq!(*c.n.lock().unwrap(), 2);</pre><pre>    // let copy = *c;          // error: Mutex is not Copy<br>    // fn worker(c: Counter) {} // would take ownership, not a silent lock clone<br>}</pre><p>An agent that “just adds a mutex field” in Go has invented a new way to deadlock. In Rust that field does not copy unless someone writes .clone() on an Arc.</p><h3>13. defer in a loop vs RAII</h3><p><strong>The Go trap.</strong> defer runs when the <strong>function</strong> returns, not when the block ends. Agents put defer f.Close() inside a loop. Every file stays open until the function finishes. On a long list that is a leaked-fd outage.</p><pre>package main</pre><pre>import (<br>    &quot;io&quot;<br>    &quot;os&quot;<br>)</pre><pre>func slurpAll(paths []string) error {<br>    for _, p := range paths {<br>        f, err := os.Open(p)<br>        if err != nil {<br>            return err<br>        }<br>        defer f.Close() // closes at slurpAll return, not end of iteration<br>        if _, err := io.ReadAll(f); err != nil {<br>            return err<br>        }<br>    }<br>    return nil<br>}</pre><p>The correct Go is an inner function or an explicit Close() in each iteration. Agents rarely write that. Reviewers rarely notice.</p><p><strong>How Rust secures it.</strong> Resources implement Drop. The file is closed when the binding goes out of scope — the end of the loop body, every time.</p><pre>use std::fs::File;<br>use std::io::{self, Read};</pre><pre>fn slurp_all(paths: &amp;[&amp;str]) -&gt; io::Result&lt;()&gt; {<br>    for p in paths {<br>        let mut f = File::open(p)?;<br>        let mut buf = Vec::new();<br>        f.read_to_end(&amp;mut buf)?;<br>        // f dropped here, every iteration<br>    }<br>    Ok(())<br>}</pre><p>This is the same RAII story as trap 10, at the scope that actually matters for agents: loops, early continue, and “I’ll close it later.” Later is how you leak.</p><h3>14. Newtype IDs — arguments the agent cannot swap</h3><p><strong>The Go trap.</strong> IDs are int64 or string. A function that takes a user and an order compiles if you pass them backwards. Agents do this constantly. Tests that use 1, 2, 3 never catch it.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>func charge(userID, orderID int64) {<br>    fmt.Printf(&quot;charge user=%d order=%d\n&quot;, userID, orderID)<br>}</pre><pre>func main() {<br>    var userID, orderID int64 = 7, 99<br>    charge(orderID, userID) // compiles, bills the wrong account<br>}</pre><p><strong>How Rust secures it.</strong> Wrap each ID in its own type. Swapping them is a type error. Zero cost at runtime.</p><pre>struct UserId(u64);<br>struct OrderId(u64);</pre><pre>fn charge(user: UserId, order: OrderId) {<br>    println!(&quot;charge user={} order={}&quot;, user.0, order.0);<br>}</pre><pre>fn main() {<br>    let user = UserId(7);<br>    let order = OrderId(99);<br>    charge(user, order);<br>    // charge(order, user);<br>    // error: expected `UserId`, found `OrderId`<br>}</pre><p>This is one of the best anti-hallucination tools you can give an agent. The compiler becomes a reviewer that knows UserId is not OrderId, even when the model does not.</p><h3>15. JSON zero values vs Option</h3><p><strong>The Go trap.</strong> encoding/json cannot tell “field missing” from “field is the zero value” unless you use pointers. Agents generate structs with bool, int, and string, then treat false / 0 / &quot;&quot; as real input.</p><pre>package main</pre><pre>import (<br>    &quot;encoding/json&quot;<br>    &quot;fmt&quot;<br>)</pre><pre>type Settings struct {<br>    Enabled bool `json:&quot;enabled&quot;`<br>    Limit   int  `json:&quot;limit&quot;`<br>}</pre><pre>func main() {<br>    var s Settings<br>    _ = json.Unmarshal([]byte(`{}`), &amp;s)<br>    fmt.Printf(&quot;%+v\n&quot;, s) // {Enabled:false Limit:0}</pre><pre>    _ = json.Unmarshal([]byte(`{&quot;enabled&quot;:false,&quot;limit&quot;:0}`), &amp;s)<br>    fmt.Printf(&quot;%+v\n&quot;, s) // same — cannot tell these apart<br>}</pre><p>The “fix” is *bool / *int, which reintroduces nil (trap 1) and pointer noise the agent will dereference.</p><p><strong>How Rust secures it.</strong> Option&lt;T&gt; plus serde makes absent ≠ zero. The agent has to match on None.</p><pre>use serde::Deserialize;</pre><pre>#[derive(Debug, Deserialize)]<br>struct Settings {<br>    enabled: Option&lt;bool&gt;,<br>    limit: Option&lt;i32&gt;,<br>}</pre><pre>fn main() {<br>    let missing: Settings = serde_json::from_str(&quot;{}&quot;).unwrap();<br>    // Settings { enabled: None, limit: None }</pre><pre>    let explicit: Settings =<br>        serde_json::from_str(r#&quot;{&quot;enabled&quot;:false,&quot;limit&quot;:0}&quot;#).unwrap();<br>    // Settings { enabled: Some(false), limit: Some(0) }</pre><pre>    assert_ne!(<br>        format!(&quot;{:?}&quot;, missing),<br>        format!(&quot;{:?}&quot;, explicit)<br>    );<br>}</pre><p>Same family as traps 1 and 3, at the wire. If your AI teammate is generating APIs, this is how “the client omitted the flag” stops meaning “disable the feature.”</p><h3>“But Go is more readable for review”</h3><p>This is the blog’s strongest point and it is still only half true.</p><p>Yes: gofmt means one layout. Yes: a small language has fewer dialects. Yes: you can often tell what a 40-line Go function does in one pass.</p><p>Review is not “do I understand the syntax.” Review is “can this be wrong in a way I will not see.”</p><p>Every snippet in the left-hand column above <strong>compiles</strong>. That is the review problem. The human is asked to see:</p><ul><li>a nil the types did not mention</li><li>a typed-nil error whose != nil check is a lie</li><li>an ignored err</li><li>a race</li><li>a slice that aliases another slice</li><li>a zero http.Client / Time / mutex-in-a-copy</li><li>a nil map that panics on the first write</li><li>a mutex copied by value</li><li>a defer that will not run until the function ends</li><li>a userID and orderID swapped</li><li>a JSON false that only meant “the field was missing”</li></ul><p>A Rust function that compiles has already been through a reviewer that does not get tired, does not skim, and does not assume the model “probably handled the None case.”</p><p>The human still reviews architecture, naming, and whether the feature is the feature. They should not also be the last line of defense for memory aliasing.</p><p>Readability without exclusion is just a nicer way to ship the incident.</p><h3>“But Go compiles faster”</h3><p>It does. Use that as an argument for Go vs C++, not Go vs a correct agent loop.</p><p>A 200ms Go compile that accepts a data race is cheaper per turn and more expensive per week. A 3s rustc turn that rejects the race, the dangling borrow, and the unhandled Result is fewer turns to a program you can merge.</p><p>Agents are not billed on compile time. They are billed on <strong>retries until the suite is green and the bug is gone</strong>. A toolchain that fails earlier fails cheaper.</p><p>And the platform story is not unique to Go:</p><p>Need the blog namesGoRustOne formattergofmtrustfmtOne test runnergo testcargo testOne package toolgo modcargoLint as agent signalgo vetclippy (stricter)Language servergoplsrust-analyzerSupply chainchecksum DB, govulncheckcrates.io + cargo audit / cargo denyCompatGo 1 promiseeditions, tiny surface of breakageCompile speedwinsslower, richer errors</p><p>“We shipped a platform” is table stakes. The question is what the platform is willing to reject.</p><h3>“But the standard library keeps agents off npm”</h3><p>True, and it is a genuine Go advantage versus JavaScript and Python. It is not an advantage versus Rust.</p><p>Rust’s standard library is smaller. The crate ecosystem is larger and messier. That is a real cost. The counter is the same as the rest of this essay: when the agent <em>does</em> pull a crate, the type boundary around it is tighter, and unsafe inside that crate is at least marked.</p><p>If your threat model is “the model imported a hallucinated package,” both languages beat Python. If your threat model is “the model imported a real package and used it wrong,” Rust wins.</p><h3>The sentence they wrote is the case for Rust</h3><p>Take the blog’s last line seriously:</p><blockquote><em>AI is your newest teammate — a hyper-productive contributor that requires strong guardrails to succeed.</em></blockquote><p>A hyper-productive teammate who does not understand your production invariants will generate volume. Volume without exclusion is how you get a thousand-line PR that gofmt loves and production hates.</p><p>Go was designed to keep <strong>human</strong> collaborators in a narrow, uniform style. That was the right problem in 2009. The 2026 problem is a collaborator who will happily emit every legal program in the language, including the ones that panic on a typed nil, race on a map, copy a mutex by value, and treat a JSON zero as constructed.</p><p>Rust was designed for that collaborator. Not because the Rust team predicted LLMs. Because they predicted <em>you cannot trust every author to get aliasing, absence, and failure right</em>. The author is now a model. The bet got more correct, not less.</p><p>Language choice <em>is</em> more important than ever. Just not the way the tweet hoped.</p><p><em>The fifteen traps above are the review checklist I wish I did not need. In Rust, most of the list is a compiler error. That is the guardrail.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31a4d5382e7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>