🤔 WASM on the backend? 🤔
Ladies and gentlemen, I need your opinion
#webassembly #serverless #go #rust #zig
# [ $davids.sh ] · message #230
🤔 WASM on the backend? 🤔
Ladies and gentlemen, I need your opinion
#webassembly #serverless #go #rust #zig
@ [ $davids.sh ] · # 1328
I dove in to study various streaming/processing technologies and stumbled upon Yomo.
I don't fully understand what this technology is. It seems like a framework + infra for running serverless functions, with built-in transport, router, deployment, and runtime environment.
What caught my eye is that they allow writing serverless functions in Go, Rust, C, and even Zig (oh, the joy!), after which you convert them to WASM, and the Yomo engine runs these functions...
And here's what I don't get: is this brilliant or dumb?
What confuses me is that all these languages compile into binaries that can run even on a hypothetical toaster. The question is, why WASM for this? Can one WASM application call functions from different languages, or will each require its own application? And what happens to the "runtime" of these languages themselves, for example, concurrency, I/O, or GC, in the case of Go?
Theoretical advantages:
Based on these advantages, I can assume that WASM could be a convenient technology for building serverless PaaS with specific limitations for particular tasks (e.g., ETL).
P.S.
Happy holidays to you, my wonderful gym bros and gals! 💪
@ Vassiliy ITK Kuzenkov · # 1330
Overall, it looks cool, yeah. I played around with WASM. Some kind of runtime is embedded directly into the module, and then it's left to the launcher. There are several of these WASM launchers, and each has its own quirks for working with, for example, the file system.
@ Artur G · # 1331
My opinion.
This is definitely genius (wasi). It's just not clear if it will catch on.
The main advantage is that a wasi container doesn't have access to the environment, only to what dependencies are explicitly passed in. Consequently, there's a gain in performance and resource utilization.
You can run different code from different clients on the same hardware, and it's very fast. There's no cold start.
As a rule, there's no language runtime, nor memory management. A lot of things are missing. 😁
This approach requires a change in thinking. 🥸 Essentially, all application code should have no side effects. 😌
Previously heard of:
@ Vassiliy ITK Kuzenkov · # 1332
Go comes with a garbage collector, so there is some runtime.
@ Artur G · # 1333
There's definitely no way to free up memory in the browser. I think there's something similar in WASI.
@ Vassiliy ITK Kuzenkov · # 1334
Really? I tried the Vecty framework in the browser, and it seemed like goroutines and some kind of GC were working there. Maybe it's a bit limited, I honestly didn't delve into it.
@ Artur G · # 1335
The memory is probably freed up when the module is unloaded. Otherwise, no, everything you use is yours until the end.
@ Vassiliy ITK Kuzenkov · # 1336
It seems you're right, there's a proposal for integrating a large WASM GC https://chromestatus.com/feature/6062715726462976 with GO, but according to https://github.com/WebAssembly/gc/issues/59, it's not in the MVP, and they've already enabled GC in Chrome.
@ [ $davids.sh ] · # 1338
So, if we're talking about languages with GC, then at the moment this can only work well for short-lived programs, which serverless / edge functions are?
@ Artur G · # 1339
I think not only that. Allocated memory can be reused, theoretically.
And it's ideal for short-lived objects.
@ [ $davids.sh ] · # 1340
I'm currently reading about WasmGC and I realize that Dart has actually been useful somewhere: thanks to Google's efforts to push it somewhere, they actively started developing Dart + WASM to integrate it into the browser more humanely, and this leads to the emergence of WasmGC, which provides a path for other languages))
@ Artur G · # 1341
I think one of the applications is "stored procedures" in your favorite language right in the DB instance. 😆
You write business code with DB dependencies. You build and deploy a new DB instance with its own API.
I hope I haven't opened Pandora's box just now. 😂
@ [ $davids.sh ] · # 1342
Ooh, yes, by the way, I've even heard of that (almost like JS was just integrated into the new MySQL beta like that)
Sounds like a great idea
@ Artur G · # 1343
Firestore can work on this principle. Only it has its own language, instead of the beloved one. 🥶
service cloud.firestore { match /databases/{database}/documents { // Assign roles to all users and refine access based on user roles match /some_collection/{document} { allow read: if request.auth != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == "Reader" allow write: if request.auth != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == "Writer"
// Note: Checking for roles in your database using \`get\` (as in the code
// above) or \`exists\` carry standard charges for read operations.
}
} }
https://firebase.google.com/docs/firestore/security/get-started
@ [ $davids.sh ] · # 1344
I think it can also be formulated like this: just as Apache is a runtime for PHP (there seems to be stateful too, but let's assume without it), WASM is a runtime for stateless scripts in "any" language.
@ Vassiliy ITK Kuzenkov · # 1345
Redis also has JS, by the way.