SaaSHub helps you find the best software and product alternatives Learn more →
Top 23 FFI Open-Source Projects
-
PythonNet
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
-
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.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
dart_native
Write iOS&macOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.
-
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.
Project mention: flutter_rust_bridge VS rinf - a user suggested alternative | libhunt.com/r/flutter_rust_bridge | 2024-01-17
- 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 )
An alternative is metacall. The example in the readme is about calling Python from Javascript, but it also works with other languages, like Ruby, C#, Java, and other languages
https://github.com/metacall/core
List of supported languages here https://github.com/metacall/core/blob/develop/docs/README.md...
In the future, maybe webidl (or extensions of it) will bring interoperability between languages too. At the moment there is https://mozilla.github.io/uniffi-rs/ for interoperability between Rust and a number of languages (basically the ones mozilla needs: Swift, Kotlin, Javascript)
I really hope that people try Flutter as Rust's GUI with Rinf. Flutter doesn't involve webview, which is more like native.
...and even more, like importing native C functions from libc in typescript. Check out the guide.
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.
For point 3 you can use https://github.com/cjdoris/PythonCall.jl or https://github.com/JuliaPy/PyCall.jl (and their respective Python sister packages).
FFI related posts
- 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
- Polars – A bird's eye view of Polars
- Improving Interoperability Between Rust and C++
-
flutter_rust_bridge VS rinf - a user suggested alternative
2 projects | 17 Jan 2024
- AI Toolkit: Give a brain to your game's NPCs, a header-only C++ library
-
A note from our sponsor - SaaSHub
www.saashub.com | 26 Apr 2024
Index
What are some of the best open-source FFI projects? This list will help you:
Project | Stars | |
---|---|---|
1 | PyO3 | 10,997 |
2 | PythonNet | 4,353 |
3 | Rustler | 4,154 |
4 | rust-bindgen | 4,070 |
5 | flutter_rust_bridge | 3,552 |
6 | workers-rs | 2,273 |
7 | cbindgen | 2,189 |
8 | rust-cpython | 1,800 |
9 | winapi-rs | 1,795 |
10 | core | 1,492 |
11 | rinf | 1,436 |
12 | jni-rs | 1,110 |
13 | dart_native | 938 |
14 | go-cshared-examples | 830 |
15 | hyperimport | 803 |
16 | milksnake | 787 |
17 | rust-cpp | 771 |
18 | Cxx.jl | 751 |
19 | win32 | 723 |
20 | swift-bridge | 698 |
21 | rucaptcha | 686 |
22 | PythonCall.jl | 670 |
23 | rust-plus-golang | 654 |
Sponsored