← All posts

What ty 1.0 says about Python, Rust, and Go in production

The 1.0 release of Astral's `ty` is a useful prompt to inspect where dynamic code ends and stricter systems code should begin. For AI and blockchain teams, the key issue is boundary design, typed contracts, and state ownership across Python, Go, and Rust services.

Simon Willison notes the 1.0 release of ty, a Python type checker from Astral, and highlights a basic point worth attention: it is written in Rust and aimed at speed. For practitioners, the release matters less as a Python tooling story and more as a pattern for systems work. Teams keep moving hot paths out of dynamic runtimes and into compiled code, while keeping the original language at the edges.

If you build AI or blockchain systems, you face this trade-off often. Model orchestration, agent logic, and data shaping often start in Python. Throughput-sensitive parts, cryptographic code, state transition logic, and network services do better in a language with tighter control over memory and concurrency. Go sits in the middle of this discussion. It gives you a simpler operational model than many systems languages, with enough performance for a large share of production workloads.

The useful question is not whether Rust beats Python, or whether Go beats Rust. The question is where your system needs stronger guarantees, lower latency, and simpler deployment. A new type checker is a prompt to inspect boundaries in your own stack.

Put dynamic code at the edge, strict code in the core

A common failure pattern starts with convenience. A team prototypes in Python, then keeps adding work to the same process. Soon, the service handling user requests is also parsing large payloads, batching model calls, retrying network traffic, and enforcing business rules. It works until load rises.

You get three kinds of problems.

  • Latency spikes from CPU-bound work inside request handlers
  • Weak interface contracts between modules
  • Hard-to-reproduce runtime failures under concurrency

A stricter core helps. In AI systems, this often means:

  • Keep prompt assembly, evaluation scripts, and notebooks in Python
  • Move inference serving, request fan-out, and queue workers into Go or Rust
  • Define narrow interfaces between them, over gRPC, HTTP, or message queues

In blockchain systems, the line is even clearer.

  • Keep exploratory analysis and incident response scripts in Python
  • Keep signing, transaction construction, mempool services, and indexers in Go or Rust
  • Treat serialization code as critical infrastructure, not glue code

The core idea is simple. Dynamic languages help you learn. Statically typed services help you hold the line once traffic, money, or keys are involved.

Inspect the boundary, not the language choice alone

Teams often frame this as a language debate. That misses the part that breaks first, the handoff between components.

Inspect four things.

First, data contracts. If a Python service sends partially validated JSON into a Go worker, your type safety starts too late. Define schemas at the boundary. Use Protobuf, JSON Schema, or a small versioned internal format. Reject unknown or malformed fields early.

Second, failure semantics. Your boundary should state what happens on timeout, duplicate delivery, partial writes, and retry. In AI pipelines, this matters for idempotent job execution. In blockchain backends, it matters for nonce handling, replay protection, and duplicate broadcasts.

Third, ownership of state. If two runtimes share responsibility for sequencing or deduplication, you have created a race. Put one service in charge of the authoritative state transition.

Fourth, observability. Cross-language systems fail in cross-language ways. Use request IDs, stable error codes, and per-hop timing. If your Python API times out because a Go worker waited on a lock, you need traces that show both sides.

Where this commonly goes wrong:

  • Validation lives only in the UI or only in the first service
  • Retries happen in multiple layers with no shared idempotency key
  • Message formats drift because there is no versioning rule
  • Metrics names differ by service, making incident review slow

The language choice matters. The interface matters more.

For AI systems, type discipline reduces silent failure

AI application code often looks healthy while producing weak output. The problem is not always the model. It is often poor structure around the model.

Three examples show up often.

Tool invocation payloads

An agent calls a tool with a malformed argument shape. The tool coerces fields, drops unknown values, or defaults missing ones. The request succeeds, but the result is wrong. Strong typing at the tool boundary cuts this down.

Retrieval and ranking pipelines

Documents pass through chunking, embedding, filtering, and ranking stages. If one stage changes a field name or score type, your final output degrades with no crash. Typed internal structs and explicit conversion layers make these changes visible.

Evaluation datasets

Benchmarks drift. A dataset field once called expected becomes answer, and part of your harness silently skips scoring. Static analysis and stricter schemas catch this before you trust the chart.

Go works well here because it pushes you toward explicit interfaces and simple deployment. A Go service for retrieval, reranking orchestration, or high-volume inference gateways is easy to ship as a single binary. You also get straightforward profiling and memory inspection, which matters once embedding pipelines or rerankers start saturating CPU and RAM.

Rust earns attention where memory layout, zero-copy parsing, or tight loops dominate. Tokenization libraries, protocol parsers, and performance-critical validation paths fit this profile. The cost is higher implementation complexity. For many teams, Go is the better default and Rust is the narrower tool for the hardest edges.

For blockchain systems, the strict parts are easy to name

Blockchain infrastructure leaves less room for ambiguity. Small mistakes in encoding, signing, or concurrency lead to lost funds, stuck transactions, or corrupted indexes.

The strict parts usually include:

  • Key handling and signing flows
  • Binary serialization and deserialization
  • Nonce or sequence management
  • Mempool listeners and block ingestion workers
  • Merkle proofs, witness handling, and state verification

These components benefit from static typing and tight control over resource use. Go has long been a strong fit for node software, indexers, and RPC infrastructure because it handles concurrency and networking cleanly. Rust stands out in cryptographic libraries and places where memory safety under hostile input matters most.

What to inspect in your own codebase:

  • Are transaction structs versioned explicitly
  • Do signing services accept only canonical payloads
  • Is chain-specific encoding tested against cross-client vectors
  • Do concurrent workers share mutable state around account sequencing
  • Are reorgs modeled as a first-class event in indexer design

A common mistake is to treat blockchain data as ordinary JSON too early. Once you flatten binary protocol details into loosely typed maps, you lose invariants you need later. Preserve structure as long as possible. Convert at the edges for display or external APIs.

Migration paths that do not stall delivery

Teams often know where strict code belongs, but fear a rewrite. A full rewrite is rarely the right move.

Use a staged path.

  1. Measure the hot path. Find CPU-heavy functions, tail-latency sources, allocation churn, and retry storms.
  2. Isolate one boundary. Pull out a worker, parser, signer, or ingestion loop behind a narrow interface.
  3. Freeze the contract. Add schema checks, fixtures, and cross-language test vectors.
  4. Move the state owner. If the extracted component controls ordering or deduplication, make that ownership explicit.
  5. Keep the old path during rollout. Mirror requests or run shadow traffic before switching fully.

This pattern works well in AI and blockchain stacks alike. For an AI service, the first extracted component is often retrieval or batch inference dispatch. For a blockchain backend, it is often transaction assembly, block decoding, or an event indexer.

Two metrics matter during the move:

  • Error-rate change at the interface
  • P95 and P99 latency under realistic concurrency

A third metric is often missed, operator time. If the new service is harder to observe, deploy, or recover, the migration has not improved the system enough.

What to watch next

The ty release is one more signal in a broader shift. Dynamic languages remain useful for fast iteration. Compiled, typed services keep taking over the paths where correctness and throughput matter most.

Watch for stronger tooling around cross-language contracts, typed model interfaces, and better FFI layers between Python and systems languages. Also watch Go’s place in this mix. It keeps winning where teams need clear concurrency, simple deployment, and enough speed without the implementation cost of lower-level systems work.

Your best next step is not a language switch. It is an audit of boundaries, state ownership, and the parts of your stack where a runtime surprise costs the most.