Fast-Anything: Don't rewrite it in Rust. Rewrite the 5% that's slow

A GitHub project promoting the idea of rewriting only the performance‑critical 5% of a Python or Node.js codebase in Rust sparks broader debate about when language choice actually matters for speed, memory use, and scalability. Commenters weigh partial Rust rewrites against alternatives like better algorithms, data structures, or offloading hot paths to existing C/C++ libraries, noting that real bottlenecks are often architectural or spread “like sand” across a system. Many see Rust’s safety guarantees and strong type system as valuable—especially in an era of LLM‑generated code—but others warn that FFI boundaries, added complexity, and slow compile times can offset the gains unless profiling shows a clear hotspot.

Scope of “rewrite the slow 5%”

  • Many agree that moving clear hotspots (e.g., route matching, JSON encoding, parsing, compression) into Rust or C can yield good wins while keeping most code in Python/Node/etc.
  • Others argue this only helps when there really is a tight hotspot; often performance issues are “like sand,” spread across many parts of the system, making Amdahl’s law bite.

Language choice and performance

  • Several posters report Python being 10–100× slower than C/C++/Rust for CPU‑bound workloads, with pure-Python object allocation and dynamic features eventually becoming the bottleneck.
  • In I/O‑bound or CRUD apps, language choice is seen as less critical; network/DB and architecture dominate.
  • Examples:
    • Python → Rust migrations for backends and pipelines yielding 10–100× speedups and big reductions in CPU/memory and hosting costs.
    • Others note that careful algorithm/data-structure choices in the same language can offer 50%+ speedups.

Partial rewrites, FFI, and alternatives

  • Common pattern: libraries keep hot loops in C/C++/Rust and expose bindings to Python (numpy, PyTorch, DB drivers).
  • Some warn FFI boundaries and data marshaling can erode Rust’s gains; others counter that Python data is already in C structs and can be efficient.
  • Alternatives raised: Numba or similar JIT tools for Python, or rewriting in other fast languages (Go, C, Zig, Swift, C#).

Rust: benefits, costs, and “virtue signaling” debate

  • Pro‑Rust arguments:
    • Memory safety and elimination of entire bug classes.
    • Strong type system aiding logical correctness.
    • High performance with good parallelism support.
    • Compiler as a “guardrail” that pairs well with LLM-generated code.
  • Skeptical views:
    • Some claim Rust is often chosen for fashion/virtue signaling over C or other safe languages.
    • Complaints about slow, resource‑hungry compiles on large Rust codebases; build costs should factor into decisions.
    • Concerns about maintainers having to own a Rust dependency they can’t read.

AI/LLMs and rewrites

  • Multiple comments note that LLMs make large rewrites cheaper and faster, weakening the classic “never rewrite” argument.
  • Rust is seen as especially compatible with AI agents because its strict compiler and verifiability help catch AI mistakes.

Concurrency, async, and architecture

  • Reports that proper threading/parallelism in Rust (or Go) can drastically improve throughput vs. multi‑process Python/Node.
  • Counterexamples where misused async runtimes (e.g., excessive task hopping in Rust) destroy performance, with big gains from simplifying or switching languages.
  • Broader theme: architecture, data layout, and observability tools often matter as much as language choice.