Rust is currently the defactor choice if you want to make something with js/python bindings, of id you want to speed up a dynamic bottleneck because it makes it super easy.
Swift doesn't even have a good ffi.
Rust is currently the defactor choice if you want to make something with js/python bindings, of id you want to speed up a dynamic bottleneck because it makes it super easy.
Swift doesn't even have a good ffi.
What's holding swift is not having a good story to call a swift compiled extension from Python/JS/Ruby/PHP.
Python's community is huge, very active, Python is everywhere, and it needs compiled extensions. And tooling to make them BFF, like pyo3 and maturin, is great
And that's how we got cryptography, pydantic core, polar... Which motives even tooling to be written in rust as a side effect, and how we have uv and ruff.
The scripting community is the most active, if you got them on your side, you get access to a huge pool of devs.
Thankfully, Facebook and Microsoft are making it happen.
Maybe spend some time reading about other JIT languages expose SIMD to developers, without requiring folks to go down to C.
Which incidentally is what all those Python DSLs for GPGPU APIs also do, with the caveat of not being that useful for general purpose programming outside machine learning algorithms.
> call a swift compiled extension from Python/JS/Ruby/PHP
The story there is excellent.
Here's a Swift function callable from C
@cdecl("myfunc")
public static func f(){...}
C/C++ types are mostly handled automatically (including sharing memory management), but it can be tricky.To build a library to load and call from any language:
swiftc mine.swift -emit-library -o libmine.dylib
E.g., calling from java 22 FFI:https://foojay.io/today/java-panama-polyglot-swift-part-2/
But most people instead use a slower json server network interface because (sadly) json is the lingua franca for scripting and Swift Codable makes it trivial to map the json to a swift type.
(Though I wouldn't fault anyone for making an argument that Swift is still more ergonomic here)