Skip to content

Don't rewrite it in Rust. Rewrite the 5% that's slow: profile your app, port the hot functions with your coding agent, prove they behave the same. Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R.

fast-anything 0.4.0: C and C++, Maven and Gradle

EL4CTEO0db84ddc3a91
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 429cc17..5e75d12 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "fast-anything",
- "version": "0.3.0",
+ "version": "0.4.0",
"description": "Find the slow 5% of your app, port just that to Rust, and prove it still behaves the same.",
"author": {
"name": "EL4CTEO"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b005158..55487e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,8 @@
# Changelog
-## Unreleased
+## 0.4.0
+- C and C++ (gcc or clang): `fast-anything scan -- clang -O2 main.c lib.c`. fast-anything builds the app itself, profiles every function for one run, and loads ports with LoadLibrary or dlopen. C ports take numbers, strings and `const T *` + length arrays; C++ ports also take std::string, vector, array, map and pair.
- Java apps built with Maven (`mvn -q compile exec:java`) or Gradle (`gradle -q run`): sources come from `src/main/java`, every JVM the build starts is profiled, and Gradle runs without its daemon.
## 0.3.0
diff --git a/Cargo.lock b/Cargo.lock
index a22d587..3b7abbc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -112,7 +112,7 @@ checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "fast-anything"
-version = "0.3.0"
+version = "0.4.0"
dependencies = [
"anyhow",
"clap",
diff --git a/Cargo.toml b/Cargo.toml
index e8811b3..de633f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "fast-anything"
-version = "0.3.0"
+version = "0.4.0"
edition = "2024"
rust-version = "1.88"
description = "Find the slow 5% of your app, have your coding agent rewrite just that in Rust, and prove it still behaves the same."
diff --git a/README.md b/README.md
index e44c6c2..eacd0ee 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
<a href="https://www.npmjs.com/package/@el4cteo/fast-anything"><img src="https://img.shields.io/npm/v/@el4cteo/fast-anything?color=f74c00&label=npm" alt="npm"></a>
<a href="https://crates.io/crates/fast-anything"><img src="https://img.shields.io/crates/v/fast-anything?color=f74c00" alt="crates.io"></a>
<a href="https://github.com/EL4CTEO/fast-anything/actions/workflows/ci.yml"><img src="https://github.com/EL4CTEO/fast-anything/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
- <img src="https://img.shields.io/badge/Python%20%C2%B7%20Node%20%C2%B7%20TypeScript%20%C2%B7%20Ruby%20%C2%B7%20Java%20%C2%B7%20Go%20%C2%B7%20PHP-2563eb" alt="Python, Node, TypeScript, Ruby, Java, Go, PHP">
+ <img src="https://img.shields.io/badge/Python%20%C2%B7%20Node%20%C2%B7%20TypeScript%20%C2%B7%20Ruby%20%C2%B7%20Java%20%C2%B7%20Go%20%C2%B7%20PHP%20%C2%B7%20C%20%C2%B7%20C%2B%2B-2563eb" alt="Python, Node, TypeScript, Ruby, Java, Go, PHP, C, C++">
<img src="https://img.shields.io/badge/Claude%20Code-plugin-d97757" alt="Claude Code plugin">
<img src="https://img.shields.io/badge/MCP-server-555" alt="MCP server">
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-555" alt="MIT"></a>
@@ -31,7 +31,7 @@ Ports are compiled with your Rust toolchain ([rustup](https://rustup.rs)).
## Use
```sh
-fast-anything go --agent claude -- python app.py # or: -- node app.ts / ruby app.rb / java App.java / mvn exec:java / gradle run / go run . / php app.php
+fast-anything go --agent claude -- python app.py # or: -- node app.ts / ruby app.rb / java App.java / mvn exec:java / gradle run / go run . / php app.php / clang -O2 main.c
```
Or step by step:
@@ -56,7 +56,7 @@ That port looked right but compared bytes instead of characters. 148 of 500 real
## Results
-Real runs on an i5-10500, Windows 11. Reproduce them from [`examples/`](examples).
+Real runs on an i5-10500, Windows 11 (C and C++: a 4-core GitHub Actions Linux runner). Reproduce them from [`examples/`](examples).
| app | before | after |
|---|---|---|
@@ -66,6 +66,8 @@ Real runs on an i5-10500, Windows 11. Reproduce them from [`examples/`](examples
| Go fuzzy dedupe (3,000 names) | 3.02s | **144ms, 21×** |
| Ruby fuzzy dedupe (400 names) | 3.13s | **228ms, 14×** |
| Java fuzzy dedupe (4,000 names) | 3.50s | **1.18s, 3×** (11× on the function; the rest is JVM startup) |
+| C mandelbrot (8 zoom levels) | 431ms | **127ms, 3.4×** |
+| C++ fuzzy dedupe (6,000 names) | 3.02s | **1.09s, 2.7×** |
fast-anything ports the outermost loop it can, not the tiny function called inside it, so the app crosses into Rust once instead of millions of times. Porting only the inner `levenshtein` gave 35× and 1.9×.
@@ -91,11 +93,11 @@ fast-anything ports the outermost loop it can, not the tiny function called insi
| Java 22+ (`java App.java`, Maven, Gradle) | the same C bridge, through the FFM API | ✅ |
| Go 1.22+ (`go run .`) | the same C bridge, through the Windows loader or dlopen (cgo) | ✅ |
| PHP 8.1+ (`php app.php`) | the same C bridge, through PHP's FFI extension (`extension=ffi`) | ✅ |
-| C, C++ | the same C bridge | next |
+| C and C++ (gcc or clang: `clang -O2 main.c lib.c`) | the same C bridge, through LoadLibrary or dlopen | ✅ |
-It ports top-level, deterministic functions that take plain data (numbers, strings, lists, dicts, typed arrays…), including ones in your entry script when its main code sits under `if __name__ == "__main__":` (or `if __FILE__ == $0`). In Java and PHP that means static methods (and PHP functions), in Go plain functions. `scan` says why anything else can't move yet.
+It ports top-level, deterministic functions that take plain data (numbers, strings, lists, dicts, typed arrays…), including ones in your entry script when its main code sits under `if __name__ == "__main__":` (or `if __FILE__ == $0`). In Java and PHP that means static methods (and PHP functions), in Go plain functions, in C and C++ free functions and static methods. `scan` says why anything else can't move yet.
-Ruby, Java, Go and PHP need no headers, bindings or extra tools: the port is a plain Rust library with one C entry point taking and returning JSON, and fast-anything replays the recorded calls against it directly. Any language that can call C can use that bridge.
+Ruby, Java, Go, PHP, C and C++ need no headers, bindings or extra tools: the port is a plain Rust library with one C entry point taking and returning JSON, and fast-anything replays the recorded calls against it directly. Any language that can call C can use that bridge.
## License
diff --git a/npm/fast-anything/package.json b/npm/fast-anything/package.json
index 3f55e56..53fd5c1 100644
--- a/npm/fast-anything/package.json
+++ b/npm/fast-anything/package.json
@@ -1,7 +1,7 @@
{
"name": "@el4cteo/fast-anything",
- "version": "0.3.0",
- "description": "Don't rewrite it in Rust. Rewrite the 5% that's slow: profile Python, Node, Ruby, Java, Go or PHP apps, port the hot functions with your coding agent, prove they behave the same.",
+ "version": "0.4.0",
+ "description": "Don't rewrite it in Rust. Rewrite the 5% that's slow: profile Python, Node, Ruby, Java, Go, PHP, C or C++ apps, port the hot functions with your coding agent, prove they behave the same.",
"keywords": [
"rust",
"python",
@@ -11,6 +11,8 @@
"java",
"golang",
"php",
+ "c",
+ "cpp",
"performance",
"optimization",
"profiler",
@@ -45,11 +47,11 @@
"node": ">=18"
},
"optionalDependencies": {
- "@el4cteo/fast-anything-win32-x64": "0.3.0",
- "@el4cteo/fast-anything-linux-x64": "0.3.0",
- "@el4cteo/fast-anything-linux-arm64": "0.3.0",
- "@el4cteo/fast-anything-darwin-arm64": "0.3.0",
- "@el4cteo/fast-anything-darwin-x64": "0.3.0"
+ "@el4cteo/fast-anything-win32-x64": "0.4.0",
+ "@el4cteo/fast-anything-linux-x64": "0.4.0",
+ "@el4cteo/fast-anything-linux-arm64": "0.4.0",
+ "@el4cteo/fast-anything-darwin-arm64": "0.4.0",
+ "@el4cteo/fast-anything-darwin-x64": "0.4.0"
},
"publishConfig": {
"access": "public"
diff --git a/skills/fast-anything/SKILL.md b/skills/fast-anything/SKILL.md
index 65c2ff7..e268213 100644
--- a/skills/fast-anything/SKILL.md
+++ b/skills/fast-anything/SKILL.md
@@ -1,6 +1,6 @@
---
name: fast-anything
-description: Speed up a slow Python, Node.js/TypeScript, Ruby, Java or Go app by porting its hottest pure functions to Rust and proving each port gives the same results on real recorded calls. Use when the user wants their Python code faster, asks about hot paths or profiling, or says "rewrite the slow part in Rust".
+description: Speed up a slow Python, Node.js/TypeScript, Ruby, Java, Go, PHP, C or C++ app by porting its hottest pure functions to Rust and proving each port gives the same results on real recorded calls. Use when the user wants their Python code faster, asks about hot paths or profiling, or says "rewrite the slow part in Rust".
---
# fast-anything
@@ -15,7 +15,7 @@ The `fast-anything` CLI measures, records, builds, checks and swaps. You write t
Skip anything under 2% of the run: porting it can't make a visible difference.
2. **Port**: `fast-anything port <id>`. It re-runs the app, records up to 500 real calls, and creates
`.fast/ports/<id>/` with a stub `src/lib.rs` and a `TASK.md`. Read TASK.md fully.
-3. **Write the Rust** in `src/lib.rs` (Ruby, Java, Go: `src/port.rs`; `src/lib.rs` there is generated glue):
+3. **Write the Rust** in `src/lib.rs` (Ruby, Java, Go, PHP, C, C++: `src/port.rs`; `src/lib.rs` there is generated glue):
- Same semantics: Unicode code points (`.chars()`; JavaScript compares UTF-16 units), integer ranges, float operation order, error cases.
- Fast: borrow, no needless allocation, ASCII fast paths, `with_capacity`.
- Keep the function and module names. Run `cargo check` in the crate.
diff --git a/src/doctor.rs b/src/doctor.rs
index 6c1682e..3b00763 100644
--- a/src/doctor.rs
+++ b/src/doctor.rs
@@ -53,6 +53,12 @@ pub fn run() -> Result<()> {
need: "for PHP apps (8.1+, extension=ffi)",
hint: "https://php.net",
},
+ Check {
+ name: "clang",
+ found: version("clang", &["--version"]).or_else(|| version("gcc", &["--version"])),
+ need: "for C/C++ apps (or gcc)",
+ hint: "https://llvm.org",
+ },
Check {
name: "claude",
found: version("claude", &["--version"]),
@@ -81,7 +87,10 @@ pub fn run() -> Result<()> {
}
}
ensure!(checks[0].found.is_some(), "Rust is needed to build ports");
- ensure!(checks[1..7].iter().any(|c| c.found.is_some()), "install Python, Node.js, Ruby, Java, Go or PHP");
+ ensure!(
+ checks[1..8].iter().any(|c| c.found.is_some()),
+ "install Python, Node.js, Ruby, Java, Go, PHP or a C compiler"
+ );
ui::ok("ready");
Ok(())
}
diff --git a/src/mcp.rs b/src/mcp.rs
index a2ebd5c..d6116ff 100644
--- a/src/mcp.rs
+++ b/src/mcp.rs
@@ -8,7 +8,7 @@ use std::path::PathBuf;
const PROTOCOL: &str = "2025-06-18";
-const INSTRUCTIONS: &str = "fast-anything speeds up Python, Node.js, Ruby, Java and Go apps by porting their hottest pure functions to Rust (PyO3 / napi-rs / a C ABI bridge) \
+const INSTRUCTIONS: &str = "fast-anything speeds up Python, Node.js, Ruby, Java, Go, PHP, C and C++ apps by porting their hottest pure functions to Rust (PyO3 / napi-rs / a C ABI bridge) \
and proving the port gives the same results on real recorded calls. Loop: fast_scan -> fast_port -> write src/lib.rs \
following the returned task -> fast_verify (repeat until it passes) -> fast_enable -> fast_bench -> fast_report.";