4 ms·
> The "infrastructure" is usually a just a C header. It's more than that. These languages often come with build systems for building extensions. For example,
by haberman 8y ago
> The "infrastructure" is usually a just a C header.
It's more than that. These languages often come with build systems for building extensions. For example, Ruby's 'mkmf'. You just list your .o files and mkmf creates a Makefile that builds against the correct headers with the correct flags:
https://github.com/google/protobuf/blob/master/ruby/ext/google/protobuf_c/extconf.rb https://github.com/google/protobuf/blob/master/ruby/ext/goog...
This tool knows about C/C++. It sadly doesn't know about Rust.
- kodablah 8y agoRust can make .o files just fine. But yes, PHP had some of these types of tools (at least back in the day, haven't looked lately) for PECL extensions. Like Node, if it's C++ only or requires actual C source, writing glue is trivial, should have no performance cost, and is a way better option than completely switching WASM impl choices because of these limiting platforms. If you don't want to manually write this glue, there are often projects (like [0] for Ruby) that will help. Again, better than artificially constraining the implementation language. 0 - https://github.com/tildeio/helix https://github.com/tildeio/helix
- curun1r 8y agoI think you're missing his point, and I say this as someone who's deployed native Node modules using Rust/Neon in our production environment and advocate that approach whole-heartedly. Writing my own Node modules in Rust works great. But I can't write a node module in Rust and distribute it via npm the way that C++ authors can. When someone adds their module as a dependency and does an npm install, npm will duly run node-gyp to compile their C++. There's no Rust equivalent of that and, until there is, Rust will always be a second-class citizen when it comes to embedding into those languages. As you point out, there's nothing technically stopping the ecosystem tools for those languages from supporting Rust, but they just don't--likely because they'd prefer to not have to bundle an entire Rust toolchain with their distribution. But whether the reason is technical or not is immaterial...I still can't push a Rust-implemented module to npm. If the goal is to create a module that the larger Node community can use to embed wasm in Node, Rust simply isn't an option because distribution via npm is a given.
- TomMarius 8y agoWe are talking about a new technology, of course the support is not that strong. You said the most important bit yourself: > As you point out, there's nothing technically stopping the ecosystem tools for those languages from supporting Rust There of course would be a problem if it was technically impossible, but that's not true, it just might be impractical right now.
- steveklabnik 8y agoWith wasm, you can distribute an npm package that’s pre compiled and doesn’t require rustc. wasm-pack already does this.
- curun1r 8y agoThat is both a) cool and b) proof of what we were dicussing...that web assembly provides a means for embedding into these scripting languages that vanilla Rust does not.