Is WASM generally faster than using Deno FFI?

I doubt it, you can benchmark though
FFI should be faster afaik but it depends on whatever you are FFI-ing to
IIRC, Sqlite is a lot faster in FFI than in WASM
in short FFI will always be faster than WASM because of how it works (being sandboxed and all that)
I kinda but not really benchmarked it once by using rust for image generation wasm was about 2x slower but it's likely caused by the amount of allocating needed it was still decently fast though & wasm_bindgen is more polished than deno_bindgen i couldn't get the latter to work so I had to use raw ffi
What about FFI vs JS for something trivial like adding two numbers? I presume there is an startup overhead for FFI which will make it slower
ABAltair 680b9/4/2023
Crossing brain-blood barrier can be costly for small tasks.
Generally WASM is slower than FFI. This does not always matter though. Sometimes you need to use a system API that Deno does not expose bindings for, in which case you must use FFI. However, FFI does not work on Deno Deploy, so WASM may be better suited if you have stronger security restrictions (such as in Deno Deploy).
yea and there is no difference in performance between native code and JS for such operations FFI will also be slower since it will need to call a function from the lib

Looking for more? Join the community!

Recommended Posts
Deno hanging when trying to connect with MongooseWhen I try to connect to MongoDB using Mongoose the whole process just hangs until eventually timingEmbeding Dino compiled code within rust (Tauri) code, inside main.rs during build compilation.Hi. Still not sure if this is question for Tauri community or Deno community, so I'll place on both DuckDB deno package broken & npm package segfaultingHas anyone had any luck using DuckDB with Deno? I've tried with the npm package with segfaults on a Get Deno working with ESLintHi! I'm trying out a Deno project and I want to get Deno TS Typing working with ESLint. I understanInstall issueI am triyng to instal Deno but i always get this error and I cant solve it. Help pls!LSP: Uncached or missing @types/node when importing node:processI'd like to understand better what's going on here in case it's a potential bug in node interop: ```Deno vs Node for writing a React component library.Hi all. I love Deno and what it does, but I need some help deciding if it is right for my small projrun code at the start of every hourI would like the most performant code pls.Denoflare scheduled workersCloudflare has a cronjob feature for running workers at a scheduled time. Wrangler has a flag wranglHow to make a function whose return type is inferred to be the same as an input function'sThis is what I got so far. ```ts type Context = { abc: string, def: boolean } /* HAVE TO Tfresh.gen.ts blankhey folks. I've been using fresh for a while as a hobbist. Recently started a new project using thCan extension state have fields that require passing lifetime?It is possible to pass bounds and parameters to the extension! macro but as far as I see it doesn't Limits for background tasksI was thinking of making a filter page for users of multible game cdns, like steam, epic games, and Compiled binary from Cross-Platform CLI example will not workGoing through https://deno.com/blog/build-cross-platform-cli and running the output file, I get ```SDeno Vite App CLI doesn't match Deploy DocsI hope this is the right channel for this. (Deno team is probably already aware of this, but postingthird party module not updating / releasingDear all, I have just added a github repo , https://github.com/jonasfrey/o_file__wav, added a webhoPossible error in Deno.renameI’ve noticed that `Deno.renameˋ does not actually throw a ˋDeno.errors.AlreadyExists` on Linux and BOutgoing connection over TLS (port 465) from the deno deployment is failingI am trying to send an email via Gmail SMTP. The code is trying to connect to smtp.gmail.com on portsetting module scope variable based on module import pathI have a big utilities file with many helper functions, mostly arround html parsing. Many of which tHow to import a npm package that relies on WasmI'm trying to import `npm:@biscuit-auth/biscuit-wasm@0.4.0` and I wrote the following script: ```Typ