Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

WebAssembly #19

Closed
benjamingr opened this issue Jun 17, 2015 · 24 comments
Closed

WebAssembly #19

benjamingr opened this issue Jun 17, 2015 · 24 comments

Comments

@benjamingr
Copy link
Member

With V8 working on WebAssembly and the big announcement I wonder in what ways we could leverage WebAssembly in NG?

It sounds like another tool available for our toolbox - and I wonder what we can do with it?

Ideas:

  • Move modules to web assembly? (Possibly from C++)
  • Allow requireing WebAssembly through require?

Concerns:

  • How do we interop with it from Node/io.js code?
  • How do user packages interop with it?
@domenic
Copy link

domenic commented Jun 17, 2015

Per https://github.com/WebAssembly/design/blob/master/FAQ.md#why-create-a-new-standard-when-there-is-already-asmjs the main advantages over JS are:

  1. Faster load time especially on mobile
  2. Maybe in the future it will add more features

Given that (1) is pretty rarely a concern (there's much lower-hanging fruit than parse time---e.g. there were recent changes to the require algorithm that make it way faster), I don't think there's much to do here unless (2) starts materializing.

@benjamingr
Copy link
Member Author

I think the lowest hanging fruit and first task is being able to require WebAssembly - I'm not sure how much work or how hard that would be but it looks like it's "just v8", although since it targets TF I guess it's not a priority given how much shit will likely hit the fan when TF will land anyway.

@ChALkeR
Copy link
Member

ChALkeR commented Jun 18, 2015

@benjamingr It could be done via an (already existing?) polyfill. As that polyfill could live in user modules, there seems to be no reason to include it in core nor to take any steps to support webasm until v8 supports it natively.

@benjamingr
Copy link
Member Author

Yes, see my above comment about TF (which will support it natively as it seems)

@runvnc
Copy link

runvnc commented Aug 31, 2015

Just throwing in my 2 cents. I am under the impression, given quite a bit of recent interest and there now being about 180,000 (mostly) semantically versioned packages, that Node (with npm) is by far the most up-to-date and relevant ecosystem of software for the web.

I have been mainly a JavaScript programmer for several years. I like JavaScript and the various dialects. However, I believe that the most realistic way to evaluate Brendan Eich & co's introduction of web assembly is as a deprecation of JavaScript. Now, they would not be so politically/practically impertinent as to say such as thing as I have just done. But I believe that this is what the leadership of their actions suggest.

Therefore, it seems to me a priority to integrate what is currently the most relevant software repository in the body of Node packages, with the new binary and non-JavaScript web assembly system, for the purposes of both taking advantage of the vast body of (soon to be) legacy JavaScripts, and/or converting them, and/or integrating with new web assembly software.

Of course, these are easily classified as being premature remarks, but within a few years we will see.

@ChALkeR
Copy link
Member

ChALkeR commented Sep 1, 2015

@runvnc WebAssembly is not a JavaScript replacement.

@wanderer
Copy link

here is a native v8 wasm interpter https://github.com/WebAssembly/v8-native-prototype

@benjamingr
Copy link
Member Author

I'm going to close this until it becomes relevant. In retrospect I was a bit quick on the gun here.

@ChALkeR
Copy link
Member

ChALkeR commented Mar 18, 2016

v8: http://v8project.blogspot.com/2016/03/experimental-support-for-webassembly.html (available behind a flag in v8 5.1).

Mozilla: https://hacks.mozilla.org/2016/03/a-webassembly-milestone/ (available behind a config flag in Nightly).

ChakraCore: https://blogs.windows.com/msedgedev/2016/03/15/previewing-webassembly-experiments/ (avaibale in a separate branch).

@wanderer
Copy link

so wasm is now available in node.js on the latest in master. just run node --expose-wasm and you will have have the _WASM_ global

@minggangw
Copy link

Hi, I notice the current v8 version is 5.0.71.52, besides Google announced the experimental support of WebAssembly with v8 5.1.117 in March (http://v8project.blogspot.com/2016/03/experimental-support-for-webassembly.html), so is there any plan that NodeJS will upgrade to this version soon? Thank you!

@bnoordhuis
Copy link
Member

V8 5.1 is in node.js master. node.js v6 will probably upgrade to 5.1 in the next month or two.

@wanderer
Copy link

@pannous node V 7 now has the newer webassembly js api. Try

WebAssembly

@pannous
Copy link

pannous commented Oct 31, 2016

great, thanks!
How come even the latest version can't handle binary version 0d?
WebAssembly.compile(): Result = expected version 0b 00 00 00, found 0d 00 00 00 @+4

@wanderer
Copy link

@pannous it is using binary version 0xc. We will have to wait for the next V8 update to node to happen. It is currently using v8 5.4.500 and 0x0d is in v8 5.6.

@LinusU
Copy link

LinusU commented Oct 31, 2016

I'm getting ReferenceError: WebAssembly is not defined in Node.js 7.0.0. Am I missing something?

@pannous
Copy link

pannous commented Oct 31, 2016

node --expose-wasm

@LinusU
Copy link

LinusU commented Oct 31, 2016

Aha, I misinterpreted a previous comment as it bing available flag less and got very excited 😄

Thank you for the quick answer!

@pannous
Copy link

pannous commented Dec 23, 2016

Update: even node.js v8.0 doesn't use v8 5.6, so no wasm experiments for the next months?

See nodejs/node#9618 for v8-5.5 progress

node -v
v8.0.0-nightly2016...
node
> console.log(process.versions.v8)
5.4.500.45

So do people just use wavm to experiment?

Or is there a simple way to produce/target old wasm 0b binary format?

@pannous
Copy link

pannous commented Dec 23, 2016

Some reasons why WebAssembly can become very important for node.js:

  1. People are starting to use node.js as their full fledged development/runtime/scripting/experiment/server environment. They just expect wasm to be fully integrated.
  2. Move modules to web assembly

Regarding 2 (as originally identified by @benjamingr) :
Yes, moving native(c++) modules to WebAssembly can be a big boon, as it will reduce dependency hell, increase system stability and security and most important: will run on all systems without further compilation! At least in some percentage of all native modules.

This can even suddenly bring node.js on par with the JVM, with all its positive business implications.

Why not asm.js? It's kind of awkward/deprecated, plus faster load time in wasm is a real thing: You don't want your 5MB c++ lib to be parsed via asm.js!

@wanderer
Copy link

@pannous you can use @targos 5.5 branch here nodejs/node#9618 , this will get you up to version 0x0c. If you need 0x0d for now you can use chrome dev channel or firefox-nightly and browerify

@ofrobots
Copy link

ofrobots commented Dec 23, 2016

If you want to live on the bleeding edge, you can build the V8 master + Node integration branch here: https://github.com/v8/node/tree/vee-eight-lkgr. This has V8 5.7.

Note: this is the tip close to the tip of the V8 development tree. Things may not work. Or things may catch fire. etc. etc. Use at own risk.

@pannous
Copy link

pannous commented Dec 23, 2016

@wanderer @ofrobots thanks

@ofrobots
Copy link

@pannous This is not the best place for this style of discussion – at least 10 subscribers on this thread get pinged on every message posted here. I would suggest #node-dev on IRC. I'm ofrobots on IRC.

If you're on linux (Ubuntu), you could try the latest V8+Node integration build binaries from the build page: https://build.chromium.org/p/client.v8.fyi/builders/V8%20-%20node.js%20integration.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants