Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Swift is a more convenient Rust. Parent comment
> 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(){...}
To build a library to load and call from any language:
swiftc mine.swift -emit-library -o libmine.dylib
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.
There are no comments on this comment yet.
> call a swift compiled extension from Python/JS/Ruby/PHP
The story there is excellent.
Here's a Swift function callable from C
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:
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.