|
|
|
|
|
by xscott
34 days ago
|
|
No worries, and I apologize if I was too blunt. We'd have to get pretty specific to have a real bake-off on size, and that's probably more effort than either of us wants to spend for a HN thread that's basically dead. I could invent scenarios where either of JS or WASM has the advantage. Code-golfing that particular example though, the JS could be "const x2=a=>2*a;" (15 bytes). If you ignore the one-time (insignificant) costs for the WASM headers and sections, the comparable byte code for that export is about the same number of bytes. If JS wins, it doesn't win by a lot. Maybe I misunderstand, but I'm not sure I see the point about hard working engineers or memory mapping. I'm sure the JavaScript JIT engineers had to work really hard to get good performance. Among many other things, JS Objects using "shapes" or "hidden classes" was a pretty clever way to compensate for not having structs at all. For both JS and WASM, end developers don't need to worry about it, and you can't mmap JS to execute the code either. |
|
I was just saying, in my experience, binary formats tend to be easier to parse than text, relying on machine native constructs such as binary integers, sometimes even matching up their stored formats to C struct layouts (this is the case with, Linux's inode format for example).
Whereas complex textual formats such as JSON or Javascript usually have a tokenization and parsing pass. But they are mostly human readable in exchange, which is a ton more engineering effort to build and CPU time to run.
I was just trying trying to say, that once you really get into sophisticated binary formats, you have to take on similar levels of complexity to parsing something like a programming language, meaning that the parser is not simple, or fast, but the file is not human readable either. Which is kinda the worst of both worlds, and doesn't really drastically reduce file size.
TLDR: Text-based formats are fine, expecially for complex data, and are surprisingly competitive with hand-tuned binary formats.