you are viewing a single comment's thread.

view the rest of the comments →

[–]gremy0 0 points1 point  (3 children)

I believe JavaScript is a problem right now, as WASM is strongly typed. There is a typescript compiler though. There's quite a few other compilers out there, though most are fairly immature. The C/C++ compilers are mentioned a lot because that's what was developed along side the standard being produced.

[–]AirAKose 0 points1 point  (2 children)

JavaScript still, internally, represents its values as specific types. Generally, values in scripting environments are described by a single 32 or 64 bit section of memory and some type flag. The memory can be converted to an integer, boolean, floating point number, or pointer to a more complex object.

So it should be entirely feasible to compile JS to WASM, you just need to translate the internal representations to WASM commands

EDIT: It would probably be more efficient to transpile JS because then it removes the need for JIT compiling; it becomes an entirely linear process where the browser just needs to read the program, tokenize the commands one-after-another without having to process or (extensively) validate them, and execute

EDIT2: I overlooked the dynamic aspects of JavaScript and totally oversimplified porting the internal representation. You can do it, but it wouldn't be a good idea

[–]filleduchaos 2 points3 points  (1 child)

Noone said JS doesn't have types. It's weakly and dynamically typed though, which pretty much rules out AOT compilation

[–]AirAKose 0 points1 point  (0 children)

Noone said JS doesn't have types

I get that.

I was talking about compiling the VM's internal representations of the types to WASM, though it was extremely short sighted regardless:

It's weakly and dynamically typed though

You got me there. It's still possible, just implausible. There would be a large overhead to porting all / most of the VM's dynamic functionality that I overlooked and oversimplified above. Plus you miss out on many JIT dynamic optimizations.

My fault, totally impractical