From: aidotengineer

Rust as the Language of AGI

The speaker, Michael Yu, proposes that Rust is the language of Artificial General Intelligence (AGI) because it is well-suited for AI coders and their human assistants [00:00:03]. He believes the future will be “AI first, human second” in terms of code generation [00:00:13].

Why Rust is Suited for AI

Rust is a programming language that recently celebrated its 10th anniversary [00:00:50]. It has consistently been ranked as the “most beloved” programming language in Stack Overflow’s developer survey for the past decade [00:01:09]. While admired (82% admiration rate) [00:01:44], its “desired to use” rate is lower, indicating a hesitation among human developers [00:02:01].

Challenges and Benefits for Humans

For humans, Rust has a very steep learning curve [00:02:34]. Its powerful compiler forces developers to write correct and optimized code from the outset, which can be difficult for beginners [00:02:48]. Unlike languages like C++, Python, or JavaScript (which may not even have compilers), Rust prevents bug-prone practices [00:02:57]. Once mastered, however, it becomes easier to write correct code in Rust than in other languages [00:03:28]. This human-centric preference often leads to the use of languages like Python or JavaScript for quicker results, despite potential bugs or maintenance issues [00:03:41].

Benefits for AI

OpenAI Chairman Brett Taylor noted that while humans prefer Python, Rust is better suited for machines [00:04:07]. It is more efficient and structurally oriented due to its strong compiler checking and type system, making it more rigorous [00:04:27]. A significant advantage is the tight feedback loop provided by the Rust compiler [00:04:41]. Once a Rust project compiles, there’s a high likelihood it will run correctly as intended, which is not true for many other languages [00:04:55].

This property makes Rust ideal for AI [00:05:11]:

  • Reward Function: The compiler’s acceptance of code acts as a strong reward function for large language models (LLMs), similar to reinforcement learning in AlphaGo or AlphaZero [00:05:23]. It forces AI to generate correct code [00:05:19].
  • AI Code Generation: If AI will write most code in the future, Rust is preferred over human-comprehensible but less rigorous languages like Python or JavaScript [00:06:06]. Rust is friendly to AI and reasonably friendly to humans for verification [00:06:38].

The Rust Coder Project

The Rust Coder project was initiated with the goal of teaching Rust to AI and enabling AI to generate better Rust code [00:06:47]. The project is sponsored by Linux Foundation internship grants and uses educational materials from the Rust Foundation [00:07:03].

Its goals include:

  • For Humans: Making it easier to learn Rust, write code, and work with Rust in IDEs using AI assistants [00:07:23].
  • For Machines: Enabling the generation of Rust code on the fly [00:07:39]. The path to AGI may involve code generators, where an LLM can either call APIs or generate code to perform tasks [00:07:43]. The project aims to make it easier for machines to generate correct Rust code and verify its correctness with the compiler [00:08:02].

Demos of Rust Coder

1. Helping Humans Learn Rust

This demo showcases an AI agent that assists in learning Rust [00:08:23]. The process involves:

  • Taking Rust educational materials.
  • Generating hundreds of common Rust development tasks.
  • Building a knowledge base using embeddings and a vector database.
  • Allowing users to ask programming questions or tasks to the AI agent, which provides a Rust answer [00:08:31].

In a demonstration, the Chemcoder model running on the Gaia network within the Cursor IDE successfully writes a Rust program to convert numbers to different bases, including explanations of the code’s structure and functions [00:09:08]. This system has been used by over a thousand developers in a university-based Rust boot camp, consistently solving exam questions in one shot [00:11:08].

2. Helping Humans Code Rust in an IDE

The Rust Coder project integrated an MCP (Machine Code Programming) server into the Cursor IDE [00:11:58]. This local Rust Coder MCP server (running on localhost:3000) provides two key tools:

  • generate: Given a description and requirements, this tool generates an entire Rust project, leveraging a vector database with common algorithms and Rust use cases as templates [00:12:43].
  • compile and fix: This tool takes Rust project files, sends them to the MCP server for compilation with its own Rust compiler [00:13:28]. If errors are encountered, it uses its own large language model to identify and fix the source code, repeating the process until compilation is successful [00:13:51].

A demo illustrates compile and fix correcting a simple syntax error (missing closing bracket) in a “Hello, world!” program [00:14:29]. The tool’s advantage lies in its fully integrated solution with a knowledge base of Rust compiler error messages and their fixes [00:17:02]. This knowledge base grows as it learns from fixes, making it more intelligent over time for Rust development than generic coding large language models [00:17:16].

The Future: MCP for Machines and AGI

Historically, computer interfaces evolved from human-centric UIs (web, desktop, mobile) to API-first approaches where other computers consumed services [00:21:50]. With the advent of large language models, “Tools” (like MCP) represent a new way for applications to be consumed, with LLMs acting as users [00:23:01].

The vision for the Rust Coder project is to provide these services (like Rust compilation and LLM-based bug fixing) as tools for other large language models to use [00:23:41]. This enables a future where AI agents can:

  • Generate Rust code on the fly for complex tasks (e.g., controlling a drone) [00:23:51].
  • Automatically compile and debug the code until it works [00:24:14].
  • Execute tasks entirely without human intervention, with reasonable guarantees of code correctness [00:24:24]. This is considered a long-term vision for AGI development [00:24:30].

Tech Stack: Local Rust Project

The Rust Coder is part of a program called “Local Rust,” which provides Rust tools for computers through APIs (for workflow engines) and MCP services (for autonomous agents and LLMs) [00:25:05].

Key components and features:

  • Easy Installation: Clonable GitHub repository with a Docker Compose script for spinning up all containers [00:25:41].
  • APIs:
    • generate: Accepts a JSON object with description and requirements to generate Rust project files [00:26:26].
    • compile and fix: Takes a flattened text file of project files, runs the Rust compiler and an LLM to fix errors, and returns the corrected project [00:27:00].
  • MCP Service: Integrates with modern agent frameworks, allowing LLMs to use standard tool calls for Rust code generation and error fixing [00:27:51].
  • Llama Edge Project: An underlying Linux Foundation project that runs large language models and other AI models (YOLO, Whisper, TTS, Stable Diffusion) across various GPUs and MPUs [00:20:00]. It has a small runtime (tens of megabytes), unlike PyTorch [00:20:25].
  • Integrated Knowledge Base: A core part of the system that includes vortex search (Elasticsearch, TiDB) and vector search (Qdrant) with various vector embedding models [00:20:36]. It contains a self-improving knowledge base of Rust compiler error messages and their fixes [00:19:15].
  • Gaia Network: A product built on Llama Edge, which turns into an MCP server using the Open MCP proxy [00:20:59].
  • Optimized Prompts: Prompts are tailored to specific large language models (e.g., Gamma 3 model without a system prompt) [00:18:51].

The project is a work in progress, with ongoing Linux Foundation internships, and encourages community contributions to expand its knowledge base and functionalities [00:28:21]. The belief is that Rust is the best language for AI coders on the path to AGI [00:28:49].