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.
Rust agent-skillsai-agentsclaude-codeclaude-code-plugincodexdeveloper-toolsffimcpmcp-servernapi-rsnodejsoptimizationperformanceprofilerpyo3pythonrewrite-it-in-rustrubyrusttypescript
C/C++: Intel oneAPI compilers (icx, icpx, dpcpp); host-only profiling with -fsycl
EL4CTEO572ae224c09e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6e19bf6..96447e6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,12 @@# Changelog+## Unreleased++- Python: verify tells ints from floats (#9); `@staticmethod`s can be ported (#13).+- Node.js: verify checks functions that aren't exported (#15); entry-script functions port when the main code sits under `if (import.meta.main)` or `require.main === module` (#17); `const` functions port (declared with `let` while enabled, put back on disable) (#19); typed-array edge cases, `Uint8ClampedArray`, `Buffer` and `Set<string>` (#22). Thanks @mohitmishra786 and @ashp15205.+- `bench` warns when the app prints something else with the Rust ports (#11).+- C/C++: Intel oneAPI compilers (`icx`, `icpx`, `dpcpp`); `-fsycl` builds profile host code only (#21, thanks @Asahi-Prv).+## 0.6.0- C# / .NET 8+: `fast-anything scan -- dotnet run -c Release`. Profiled with the runtime's own EventPipe sampler (nothing to install), sources read with Roslyn, ports called through NativeLibrary. Static methods taking numbers, strings, arrays, lists and string-keyed dictionaries; verify adds edge cases and shrunk inputs. Thanks @JuggyBob for the request (#3).diff --git a/README.md b/README.mdindex 889cb32..17cc3cd 100644--- a/README.md+++ b/README.md@@ -94,11 +94,13 @@ 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 and C++ (gcc or clang: `clang -O2 main.c lib.c`) | the same C bridge, through LoadLibrary or dlopen | ✅ |+| C and C++ (gcc, clang or Intel oneAPI icx/icpx: `clang -O2 main.c lib.c`) | the same C bridge, through LoadLibrary or dlopen | ✅ || C# / .NET 8+ (`dotnet run -c Release`) | the same C bridge, through NativeLibrary; profiled with EventPipe, nothing to install | ✅ |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`, or `if (import.meta.main)` / `if (require.main === module)`). In Python that means module-level functions and `@staticmethod`s, in Java, C# and PHP 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.+With Intel oneAPI on Windows, run fast-anything from a shell where `setvars.bat` ran (it sets up the linker). SYCL kernels run on the device and aren't ported; with `-fsycl`, only host functions are profiled and ported.+Ruby, Java, Go, PHP, C, 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.## Licensediff --git a/src/backend.rs b/src/backend.rsindex cc40a54..098f7b6 100644--- a/src/backend.rs+++ b/src/backend.rs@@ -65,7 +65,7 @@ impl Lang {Ok(lang)} else {bail!(- "fast-anything speaks Python, Node.js (JavaScript/TypeScript), Ruby, Java, Go, PHP, C, C++ and C#. Start the command with one of them:\n fast-anything scan -- python app.py\n fast-anything scan -- node app.js\n fast-anything scan -- ruby app.rb\n fast-anything scan -- java App.java\n fast-anything scan -- go run .\n fast-anything scan -- php app.php\n fast-anything scan -- clang -O2 main.c (or gcc, g++, clang++)\n fast-anything scan -- dotnet run -c Release"+ "fast-anything speaks Python, Node.js (JavaScript/TypeScript), Ruby, Java, Go, PHP, C, C++ and C#. Start the command with one of them:\n fast-anything scan -- python app.py\n fast-anything scan -- node app.js\n fast-anything scan -- ruby app.rb\n fast-anything scan -- java App.java\n fast-anything scan -- go run .\n fast-anything scan -- php app.php\n fast-anything scan -- clang -O2 main.c (or gcc, g++, clang++, icpx)\n fast-anything scan -- dotnet run -c Release")}}diff --git a/src/cfamily.rs b/src/cfamily.rsindex 8b97a50..419a21c 100644--- a/src/cfamily.rs+++ b/src/cfamily.rs@@ -24,8 +24,9 @@ const REC_C: &str = include_str!("cfamily/rec.c");const REC_HPP: &str = include_str!("cfamily/rec.hpp");const JSON_HPP: &str = include_str!("cfamily/json.hpp");-const C_COMPILERS: &[&str] = &["gcc", "clang", "cc"];-const CPP_COMPILERS: &[&str] = &["g++", "clang++", "c++"];+/// Intel oneAPI: icx (C, clang-based), icpx and dpcpp (C++). icx-cl takes MSVC-style flags, so it isn't listed.+const C_COMPILERS: &[&str] = &["gcc", "clang", "cc", "icx"];+const CPP_COMPILERS: &[&str] = &["g++", "clang++", "c++", "icpx", "dpcpp"];const C_EXT: &[&str] = &["c"];const CPP_EXT: &[&str] = &["cc", "cpp", "cxx", "c++", "C"];/// Compiler flags whose value is the next argument.@@ -1387,6 +1388,10 @@ mod tests {#[test]fn finds_c_and_cpp_functions() {let c = "#include <stdio.h>\n/* a { comment */\nstatic int lev(const char *a, const char *b) {\n return 0;\n}\n\nlong count(const int *xs, size_t n, int max)\n{\n if (n) { return 1; }\n printf(\"{\");\n return 0;\n}\nint main(void) { return lev(\"a\", \"b\"); }\n";+ assert_eq!(detect("icpx"), Some(Lang::Cpp));+ assert_eq!(detect("C:\\oneAPI\\bin\\dpcpp.exe"), Some(Lang::Cpp));+ assert_eq!(detect("icx"), Some(Lang::C));+ assert_eq!(detect("icx-cl"), None);let f = parse(c);assert_eq!(f.iter().map(|f| f.name.as_str()).collect::<Vec<_>>(), ["lev", "count", "main"]);assert_eq!(f[0].ret, "int");diff --git a/src/cfamily/prof.h b/src/cfamily/prof.hindex c4869a8..7b478ca 100644--- a/src/cfamily/prof.h+++ b/src/cfamily/prof.h@@ -10,5 +10,10 @@ void fa_prof_exit(fa_prof_frame *f);#ifdef __cplusplus}#endif+#if defined(__SYCL_DEVICE_ONLY__)+/* SYCL device code (icpx -fsycl): the device pass can't call host functions, and kernels run on the device anyway */+#define FA_PROF(id)+#else#define FA_PROF(id) __attribute__((cleanup(fa_prof_exit))) fa_prof_frame fa_prof_frame_ = fa_prof_enter(id)#endif+#endifdiff --git a/src/doctor.rs b/src/doctor.rsindex 6f987bd..5a4dcd7 100644--- a/src/doctor.rs+++ b/src/doctor.rs@@ -55,8 +55,10 @@ pub fn run() -> Result<()> {},Check {name: "clang",- found: version("clang", &["--version"]).or_else(|| version("gcc", &["--version"])),- need: "for C/C++ apps (or gcc)",+ found: version("clang", &["--version"])+ .or_else(|| version("gcc", &["--version"]))+ .or_else(|| version("icpx", &["--version"])),+ need: "for C/C++ apps (or gcc, icpx)",hint: "https://llvm.org",},Check {