3 min Devops

OpenAI rewrites AI coding tool in Rust

OpenAI rewrites AI coding tool in Rust

OpenAI has rewritten its upcoming command-line tool for AI programming, Codex CLI, in Rust. The organization cites improved performance and security as reasons, while also wanting to move away from its dependence on Node.js, which can be problematic or limiting for some users.

This was reported by DevClass. Codex is an experimental programming assistant that can be used both via a web browser in ChatGPT and locally via Codex CLI. The tool has a chat-based interface and the CLI can be used interactively with commands preceded by codex, or in a silent, non-interactive mode — for example, in automated processes to generate changelogs. This version of Codex should not be confused with the earlier product of the same name from 2021, which was discontinued in March 2023.

Codex CLI is open source on GitHub and runs on macOS, Linux, and Windows (via WSL). Until now, the source code was mostly in TypeScript and ran on Node.js, but the team has now released a rewritten version in Rust. Bugs in the TypeScript version will continue to be fixed for the time being, until the Rust version is equivalent in terms of features and user experience, according to project maintainer Fouad Matin.

Four reasons for the new version

According to Matin, building with React and TypeScript was quick and easy in the beginning, but there are four main reasons why he believes Rust is better:

  1. Installation without dependencies
    Where the current version requires Node.js 22 or higher — which can be a stumbling block — the Rust version has no external dependencies.
  2. Sandboxing for more security
    On macOS, Codex CLI already runs in a sandbox via Apple’s sandbox-exec. This is not yet the case on Linux, but OpenAI recommends running the tool in a container. For the Rust version, OpenAI has already developed a way to apply sandboxing: on macOS with sandbox-exec, and on Linux with Landlock.
  3. Better performance
    Rust has no runtime garbage collection and uses less memory, resulting in faster and more efficient execution.
  4. Use of existing Rust implementation of MCP
    Codex CLI can now function as both a client and server for the Model Context Protocol (MCP), thanks to an existing Rust implementation.

Rust is originally a system programming language and significantly more efficient than code running on Node.js’s V8 JavaScript engine. On the other hand, programming in Rust is more difficult and therefore potentially less productive than working with TypeScript or JavaScript. According to most studies, JavaScript and Python are still the most popular languages, while Rust has a smaller user base. However, the Rust version of Codex CLI will be extensible with code in other languages such as JavaScript and Python — although no details are available yet.

OpenAI is not the only organization choosing Rust for its efficiency. Evan You, the creator of Vue.js, also announced a new version of the development tool Vite. This is Rolldown-Vite, which replaces the current Rollup.js with Rolldown, written in Rust. According to You, this results in builds that are up to 16 times faster and memory usage that can be up to 100 times lower.