News for hackers. Stuff that matters.
Re:Strings in WebAssembly by tyingq on Monday February 24, 2020 @07:14AM (#22403408)
Is it unusual for a VM not to have a string (or at least a bytes) type? I have little experience in the space, but it seems clunky. Curious why WASM went this direction.
Re:Strings in WebAssembly by kbumsik on Monday February 24, 2020 @08:02AM (#22403644)
WASM just reached MVP. The design goal of the MVP seems to be a small spec that includes the minimum amount of requirements.

I guess that is the reason why all four major browsers cloud adopt it almost in the same time, without having many proposal ping-pongs between Google vs Mozilla vs Apple vs Microsoft.

Re:Strings in WebAssembly by tyingq on Monday February 24, 2020 @08:14AM (#22403698)
This article, and proposals for reference types, though, make it sound like working around the lack of strings/bytes/chars might have been more work in the end. Sort of like a unicycle isn't really a bicycle MVP :)
Re:Strings in WebAssembly by kbumsik on Monday February 24, 2020 @08:41AM (#22403855)
Right, but it is better than having to wait more years until browsers reach consensus. I'm not sure but specifying a WASM-native string representation might be more favorable to a specific JS engine than the others, depending on its existing JS string implementation. This might cause disagreements.
Re:Strings in WebAssembly by AndrewDucker on Monday February 24, 2020 @08:15AM (#22403709)
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.

Re:Strings in WebAssembly by tyingq on Monday February 24, 2020 @08:20AM (#22403732)
"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.

Re:Strings in WebAssembly by kaoD on Monday February 24, 2020 @08:35AM (#22403818)
And linear memory, which is just an array of bytes.
Re:Strings in WebAssembly by AndrewDucker on Monday February 24, 2020 @08:32AM (#22403801)
An i32 is a byte.
Re:Strings in WebAssembly by kaoD on Monday February 24, 2020 @08:35AM (#22403815)
The common definition of byte nowadays is an octet.
Re:Strings in WebAssembly by kbumsik on Monday February 24, 2020 @08:42AM (#22403861)
In WASM i32 can be treated like a 8-bit byte too.
Re:Strings in WebAssembly by kaoD on Monday February 24, 2020 @08:56AM (#22403951)
Can 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).

Re:Strings in WebAssembly by kbumsik on Monday February 24, 2020 @09:04AM (#22404005)
Although 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/