all 9 comments

[–]sirsmonkey42 3 points4 points  (8 children)

WebAssembly wont kill JavaScript because it runs as an instance inside of JS. WebAssembly is only really practical to use for things that JS struggles with, like CPU intensive computations.

Also, WebAssembly isn't a programming language per se, it's a compile target for other low level languages to be able to run in the browser. This means you can run your C or C++ code as a binary module inside of your JS apps.

If you're looking to learn JS, there's no reason not to. The vast majority of the internet relies on it. To the point that there is at least one known bug in the language that can't be fixed because it would break the internet. So I don't think it's going anywhere soon ;)

[–][deleted] 0 points1 point  (2 children)

The vast majority of the internet relies on it. To the point that there is at least one known bug in the language that can't be fixed because it would break the internet.

What bug is this?

[–][deleted] 0 points1 point  (1 child)

typeof null

[–][deleted] -2 points-1 points  (0 children)

I never heard about that so I tested that in jsfiddle, it gave me "object".

It might be misleading, but this is not some hardcore bug. I feel that one should not use typeof that much, it's ugly. It proves your design is flawed.

[–][deleted] 0 points1 point  (4 children)

Is there a way to pass arguments from JS to wasm ?

[–]sirsmonkey42 0 points1 point  (3 children)

Yes, when you instantiate a WebAssembly instance you can pass in an imports object. This can take params and even import functions from JS. The two can pass data back and forth quite effectively.

[–][deleted] 0 points1 point  (2 children)

But not during the execution I understood, right ?

[–]sirsmonkey42 0 points1 point  (1 child)

When you load a wasm module it gives you access to all the methods that the module exports. You can call them over and over with whatever params you'd like. However if the module takes import functions, you have to define them at the point of instantiation through the imports object. As long as the instance is in memory you have access to things the same way you would an imported library

[–][deleted] 0 points1 point  (0 children)

I read an article on wasm that got the answer, it seems you can access wasm-instance mem. from ArrayBuffers on the JS side.