2 ms·
The problem is that WebAssembly exists for other languages to be compiled into. And those other languages don't agree what a string looks like. So do you have
by AndrewDucker 7y ago
The problem is that WebAssembly exists for other languages to be compiled into.
And those other languages don't agree what a string looks like.
So do you have a Rust string? Or a C string? Or a C# string? Or one of the other representations?
By just giving you a bunch of bytes to play with, and letting different languages use them differently, WebAssembly stays out of the way and lets the compiler decide how it wants to make strings.
- tyingq 7y ago"By just giving you a bunch of bytes to play with" It doesn't appear to do even that though. You get i32, i64, f32, and f64. The linear memory is some multiple of the 64KiB page size.
- AndrewDucker 7y agoAn i32 is a byte.
- kaoD 7y agoThe common definition of byte nowadays is an octet.
- kbumsik 7y agoIn WASM i32 can be treated like a 8-bit byte too.
- kaoD 7y agoCan you elaborate? I'm not well-versed in WASM internals and I might be missing something. I mean, any integer with 8+ bits can be treated like an octet, but memory layout is very different (e.g. an array of i8 and an array of i32 look very different even if they represent the same values).
- kbumsik 7y agoAlthough WASM types only have 32/64 bits it has 8/16 bit operations too. So it won't matter much: https://webassembly.org/docs/semantics/ https://webassembly.org/docs/semantics/
- kaoD 7y agoAnd linear memory, which is just an array of bytes.