FFI

Top 23 FFI Open-Source Projects

  • PyO3

    Rust bindings for the Python interpreter

  • Project mention: Encapsulation in Rust and Python | dev.to | 2024-04-05

    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

  • 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.

  • Project mention: I modified and hacked away xonsh source code | /r/xonsh | 2023-10-18
  • 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.

    InfluxDB logo
  • Rustler

    Safe Rust bridge for creating Erlang NIF functions

  • Project mention: AI Toolkit: Give a brain to your game's NPCs, a header-only C++ library | news.ycombinator.com | 2024-01-09

    For 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.

  • rust-bindgen

    Automatically generates Rust FFI bindings to C (and some C++) libraries.

  • Project mention: Rust Bindgen | news.ycombinator.com | 2023-09-18
  • flutter_rust_bridge

    Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

  • Project mention: flutter_rust_bridge VS rinf - a user suggested alternative | libhunt.com/r/flutter_rust_bridge | 2024-01-17
  • workers-rs

    Write Cloudflare Workers in 100% Rust via WebAssembly

  • Project mention: Python Cloudflare Workers | news.ycombinator.com | 2024-04-02

    - 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.

  • cbindgen

    A project for generating C bindings from Rust code

  • Project mention: Hello World in Go From Rust | dev.to | 2024-01-07

    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:

  • 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.

    WorkOS logo
  • rust-cpython

    Rust <-> Python bindings

  • winapi-rs

    Rust bindings to Windows API

  • Project mention: Improving Interoperability Between Rust and C++ | news.ycombinator.com | 2024-02-05

    Vtables 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 )

  • core

    MetaCall: The ultimate polyglot programming experience. (by metacall)

  • Project mention: Show HN: Pip Imports in Deno | news.ycombinator.com | 2023-08-11

    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)

  • rinf

    Rust for native business logic, Flutter for flexible and beautiful GUI

  • Project mention: slint VS rinf - a user suggested alternative | libhunt.com/r/slint | 2024-01-24

    I really hope that people try Flutter as Rust's GUI with Rinf. Flutter doesn't involve webview, which is more like native.

  • jni-rs

    Rust bindings to the Java Native Interface — JNI

  • dart_native

    Write iOS&macOS&Android Code using Dart. This package liberates you from redundant glue code and low performance of Flutter Channel.

  • go-cshared-examples

    Calling Go Functions from Other Languages using C Shared Libraries

  • Project mention: Fail to build Go library similar to C# and Rust | /r/golang | 2023-05-23
  • hyperimport

    ⚡ Import c, rust, zig etc. files in your TypeScript code and more.

  • Project mention: Hyperimport - Import c, rust, zig etc. files in TypeScript | dev.to | 2023-10-14

    ...and even more, like importing native C functions from libc in typescript. Check out the guide.

  • milksnake

    A setuptools/wheel/cffi extension to embed a binary data in wheels

  • rust-cpp

    Embed C++ directly inside your rust code!

  • Project mention: Improving Interoperability Between Rust and C++ | news.ycombinator.com | 2024-02-05

    I am the current passive maintainer of the cpp crate: https://github.com/mystor/rust-cpp

  • Cxx.jl

    The Julia C++ Interface

  • win32

    Build Win32 apps with Dart! (by dart-windows)

  • Project mention: Show HN: Win32 – Build Win32 Apps with Dart | news.ycombinator.com | 2023-11-28
  • swift-bridge

    swift-bridge facilitates Rust and Swift interop.

  • Project mention: macOS Apps in Rust | news.ycombinator.com | 2023-05-13

    A bit late, but `swift-bridge` (https://github.com/chinedufn/swift-bridge) does this intelligently, and is probably what you're looking for.

  • rucaptcha

    Captcha Gem for Rails, which generates captcha image by Rust.

  • PythonCall.jl

    Python and Julia in harmony.

  • Project mention: I just started into Julia for ML | /r/Julia | 2023-06-06

    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).

  • rust-plus-golang

    Rust + Go — Call Rust code from Go using FFI

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020).

FFI related posts

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
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com