Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality. Learn more →
Top 23 Rust FFI Projects
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
Integrating Rust into Python, Edward Wright, 2021-04-12 Examples for making rustpython run actual python code Calling Rust from Python using PyO3 Writing Python inside your Rust code — Part 1, 2020-04-17 RustPython, RustPython Rust for Python developers: Using Rust to optimize your Python code PyO3 (Rust bindings for Python) Musing About Pythonic Design Patterns In Rust, Teddy Rendahl, 2023-07-14
Project mention: AI Toolkit: Give a brain to your game's NPCs, a header-only C++ library | news.ycombinator.com | 2024-01-09For performance intensive tasks, you could rely on Rust NIFs, there is this great project: https://github.com/rusterlium/rustler
My last project with Elixir was using Elixir merely as an orchestrator of static binaries (developed in golang) which were talking in JSON via stdin/stdout.
- The speed of the Python interpreter running in WebAssembly
Today, Python cold starts are slower than cold starts for a JavaScript Worker of equivalent size. A basic "Hello World" Worker written in JavaScript has a near zero cold start time, while a Python Worker has a cold start under 1 second.
That's because we still need to load Pyodide into your Worker on-demand when a request comes in. The blog post describes what we're working on to reduce this — making Pyodide already available upfront.
Once a Python Worker has gone through a cold start though, the differences are more on the margins — maybe a handful milliseconds, depending on what happens during the request.
- There is a slight cost (think — microseconds not milliseconds) to crossing the "bridge" between JavaScript and WebAssembly — for example, by performing I/O or async operations. This difference tends to be minimal — generally something measured in microseconds not milliseconds. People with performance sensitive Workers already write them in Rust https://github.com/cloudflare/workers-rs, which also relies on bridging between JavaScript and WebAssembly.
- The Python interpreter that Pyodide provides, that runs in WebAssembly, isn't as fast as the years and years of optimization that have gone into making JavaScript fast in V8. But it's still relatively early days for Pyodide, compared to the JS engine in V8 — there are parts of its code where we think there are big perf gains to be had. We're looking forward to upstreaming performance improvements, and there are WebAssembly proposals that help here too.
Golang uses cgo to communicate with external C libraries and Rust uses FFI (Foreign function interfaces) to export C functions. Additionally, a library for automatically generating bindings can be used to generate the header files (.h). In our case, we'll only be exporting two C functions, so using cbindgen is overkill but we'll use it regardless because why not? Firstly, we'll write the rust functions we want to export. We'll start by creating a new rust library:
Project mention: Improving Interoperability Between Rust and C++ | news.ycombinator.com | 2024-02-05Vtables are pretty solved as well. I do a lot of Windows COM interop. Using the `windows` crate, vtables for COM interfaces are relegated to an implementation detail - instead you simply implement a (typically safe!) trait:
https://microsoft.github.io/windows-docs-rs/doc/windows/Win3...
Which can then be converted to a refcounted smart pointer:
https://microsoft.github.io/windows-docs-rs/doc/windows/Win3...
All driven by win32 sdk parsing and metadata.
But suppose we want to roll our own, because we tend to prefer `winapi` but it lacks definition. That's not too terrible either:
• https://github.com/MaulingMonkey/thindx-xaudio2/blob/master/...
• https://github.com/MaulingMonkey/thindx-xaudio2/blob/master/...
• https://github.com/MaulingMonkey/thindx-xaudio2/blob/master/...
I could more heavily lean on my macros ala `windows`, but I went the route of manual control for better doc comments, more explicit control of thread safety traits to match the existing C++ codebase, etc.
Is there some pointer casting? Yes. Is it annoying or likely to be what breaks? No. What is annoying?
• Stacked borrows and narrowing spatial provenance ( https://github.com/retep998/winapi-rs/issues/1025 - this can be "solved" by sticking to pointers ala `windows`, or by choosing a different provenance model like rustc might be doing?)
• Guarding against panics unwinding over an FFI boundary. This is at least being worked on, but remains unfinished ( https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html )
• Edge case ABI weirdness specific to C++ methods ( https://devblogs.microsoft.com/oldnewthing/20220113-00/?p=10... , https://github.com/retep998/winapi-rs/issues/523 )
I really hope that people try Flutter as Rust's GUI with Rinf. Flutter doesn't involve webview, which is more like native.
Project mention: Improving Interoperability Between Rust and C++ | news.ycombinator.com | 2024-02-05I am the current passive maintainer of the cpp crate: https://github.com/mystor/rust-cpp
A bit late, but `swift-bridge` (https://github.com/chinedufn/swift-bridge) does this intelligently, and is probably what you're looking for.
I started with Rust a while ago. It's a beautiful language. My problem with it was the problem space it's good at addressing. I ended up not only trying to learn Rust but also wholly new paradigms related to writing low-level code, libraries, or even trying to write a PHP extension in Rust (that was way before https://github.com/davidcole1340/ext-php-rs). I learned a lot about PHP and Rust/C/PHP interoperability ;) But the learning curve was steep. In my opinion, it isn't easy to learn more than one thing simultaneously. A new language is enough. If, on top of that, you need to learn entirely new paradigms - it can be cumbersome.
I know all that shit because I'm the author of Rust's WinSafe library, which is a safer Rust layer over native Win32, so I had to deal with a lot of shit like this.
Project mention: Show Reddit: Metatype - a HTTP/GraphQL query engine built with Deno and Rust | /r/Deno | 2023-05-17We started initially with Deno for the full engine and saw that for some of the runtimes we wanted to implement, Rust fits well thanks to https://github.com/denoland/deno_bindgen. This choice has so far paid well off and the project is now in public beta, run in production by a few companies.
Rust FFI related posts
-
Symfony 7 vs. .NET 8 - same-same but different?
-
Encapsulation in Rust and Python
-
Show HN: A practical example of using async Rust runtimes in C and C++
-
Rust Bindings for the Python Interpreter
-
Improving Interoperability Between Rust and C++
-
AI Toolkit: Give a brain to your game's NPCs, a header-only C++ library
-
Hello World in Go From Rust
-
A note from our sponsor - InfluxDB
www.influxdata.com | 10 May 2024
Index
What are some of the best open-source FFI projects in Rust? This list will help you:
Project | Stars | |
---|---|---|
1 | PyO3 | 11,086 |
2 | Rustler | 4,164 |
3 | rust-bindgen | 4,131 |
4 | workers-rs | 2,308 |
5 | cbindgen | 2,211 |
6 | rust-cpython | 1,801 |
7 | winapi-rs | 1,803 |
8 | rinf | 1,480 |
9 | jni-rs | 1,122 |
10 | rust-cpp | 774 |
11 | swift-bridge | 730 |
12 | magnus | 591 |
13 | ext-php-rs | 534 |
14 | j4rs | 509 |
15 | winsafe | 444 |
16 | jlrs | 393 |
17 | rust-objc | 378 |
18 | duckdb-rs | 367 |
19 | emacs-module-rs | 325 |
20 | robusta | 310 |
21 | interoptopus | 288 |
22 | deno_bindgen | 262 |
23 | ocaml-rs | 249 |
Sponsored