scale
cargo-component
scale | cargo-component | |
---|---|---|
5 | 2 | |
464 | 401 | |
3.0% | 7.7% | |
8.5 | 8.7 | |
5 days ago | 3 days ago | |
C | Rust | |
Apache License 2.0 | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
scale
-
WASM by Example
This is exactly one of the use-cases for the Scale Framework[1]. (Disclaimer: I work on this project)
You can absolutely take a library from one language and run it in another. In a sense, you could kind of see this ability as drastically reducing the need for rewriting sdks, middlewares, etc. across languages, as you could just reuse code from one language across many others. We played around with some fun ideas here, like taking a Rust regex library and using it in a Golang program via a scale function plugin (compiled to Wasm), to the effect of the performance being ~4x faster than native code that uses Go's regex library.
[1] https://github.com/loopholelabs/scale
- Show HN: Scale – Serverless functions, in any language, powered by WASM
- Show HN: Write Language-agnostic functions with WebAssembly you can use
-
Announcing Scale: A WebAssembly runtime for running Go functions in any other language
We're currently working on a couple of different projects, but everything we've launched so far (fRPC and Scale) is FOSS.
cargo-component
-
WASM by Example
well, for starters, wasm is sandboxed. So, if a wasm library needs an import (eg: read/write filesystem), it has to be explicitly provided. It cannot do anything except math by default. This allows host a high amount of control.
different wasm libraries can have separate memories. So, if a library X depends on a jpeg decoder library, the host has to provide that as import. The jpeg decoder library might export a fn called "decode" which takes an array of bytes of a jpeg, and returns an Image struct with rgba pixels. This allows the "memory" of the two libraries to be separate. the jpeg decoder cannot "write" to the X's memory, cleanly separating the two of them.
Wasm component model recognizes higher level objects called resources, which can be shared between libraries (components). This allows X to simply pass a file descriptor to jpeg decode fn, and the sandbox model makes sure that jpeg library can read from that file only and the rest of the filesystem is still offlimits. wasm is already getting support for garbage collector. So, a high level language can just rely on wasm's GC and avoid shipping its entire runtime. Or the host can guarantee that all the imports a language needs will be provided, so that the language libraries can shed as much runtime weight as possible.
Finally, Component model is designed from ground up to be modular, which allows imports/exports/namespaces and other such modern features. C.. well, only has headers and usually brings a lot of backwards compatibility baggage. The tooling (eg: wit-bindgen) will provide higher level support like generating code for different language bindings by taking a wit (header for wasm) declaration file. If you are familiar with rust, then https://github.com/bytecodealliance/cargo-component#getting-... shows how easy it is to safely create (or bind to) wasm bindings
-
Using WASM for a plugin system in Rust? (generate code at runtime and then hot reloading it as a library)
Yes, wasm_bindgen is js only. At least for now, in future I would also expect it to migrate to component model. There is also cargo-component which is a way to create modules compatible with component model. You define your module interface in WIT and your dependencies on other wasm modules in the similar way you would define crate dependencies. Alternately there is wit-bindgen that is a codegen tool for multiple languages that also accepts WIT as input.
What are some alternatives?
excelize-wasm - A WebAssembly build of the Go Excelize library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
dotnet-pdk - Extism Plug-in Development Kit (PDK) for C# and F#
olin - Webassembly + Event Sourcing
dcraw - Mirror of Dave Coffin's dcraw, with full history
plugin-XDCC - 📁 XDCC for webircgateway
component-model - Repository for design and specification of the Component Model
cup - Git Contribution Automation
wasm-by-example - Wasm By Example is a website with a set of hands-on introduction examples and tutorials for WebAssembly (Wasm)
lagon - Deploy Serverless Functions at the Edge. Current status: Alpha
wasmtime - A fast and secure runtime for WebAssembly
yatas-template - Template for creating a plugin for YATAS
wit-bindgen - A language binding generator for WebAssembly interface types