rcotter / use-rust-in-other-langs

Use a Rust dependency via FFI and WASM in .Net, Java, Ruby, Python, Dart, Node.js and Browser Javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This repo demonstrates a simple write once, use everywhere calculation library being used by multiple client technologies, including in the browser via WASM/WebAssembly. For good measure, unit tests would be created for each client reusing the same inputs.

Why Rust? It is compatible with C, runs just or nearly as fast but is much safer. Linus is even putting it in the Linux kernel. Checkout some metrics and caveats.

NOTE: All were created and tests on MacOS unless otherwise noted.

CLIENT INTERFACE Unit Tests
.Net FFI via P/Invoke / DllImport
Delphi FFI 64-bit on Windows (credit to @jrmaciel-zx)
Dart / Flutter FFI via FFIGEN & FFI.
Java JNI
Javascript Web WASM / WebAssembly
Node.js WASM / WebAssembly
Python FFI
Ruby FFI
Rust Direct Dependency
Swift Won't Do - Lots of Examples Available

ALTERNATIVE USAGE TO EXPLORE

Just use WASM everywhere! Many languages are including and optimizing this ability.

About

Use a Rust dependency via FFI and WASM in .Net, Java, Ruby, Python, Dart, Node.js and Browser Javascript


Languages

Language:Makefile 89.8%Language:Rust 8.9%Language:HTML 0.3%Language:Dart 0.3%Language:JavaScript 0.3%Language:Shell 0.1%Language:Java 0.1%Language:C# 0.1%Language:Pascal 0.1%Language:Python 0.1%Language:Ruby 0.1%Language:C++ 0.0%