9 ms·
I thought web assembly compiled to JavaScript, but it doesn't look like that's so. It looks like a binary format. I think that's great if so. Finally we can exp
by mevile 10y ago
I thought web assembly compiled to JavaScript, but it doesn't look like that's so. It looks like a binary format. I think that's great if so. Finally we can expand beyond JavaScript on front-end development.
- RussianCow 10y agoI think you're thinking of asm.js, which is a subset of JavaScript that can compile to native code directly. WebAssembly is more or less a binary representation of asm.js. Edit: Looks like WebAssembly is more low level than asm.js, and is actually closer to real assembly, whereas asm.js is more akin to C.
- crooked-v 10y agoasm.js is a strict subset of JS, designed to be valid JS for preexisting browser engines while at the same time containing what's effectively a lot of primitive types hinting for an optimized engine. For a simple example... i = i|0; This is valid JS, but a JS engine designed to use asm.js optimizations can look at the bitwise OR with 0 before the script even runs and realize that i must be an integer in that block of code, so it can use more-efficient integer operations instead of float ones.
- TazeTSchnitzel 10y agoWebAssembly is also akin to C, but it has a more efficient encoding and is not constrained by the set of operations that can be expressed in JavaScript.
- Ralfp 10y ago> Finally we can expand beyond JavaScript on front-end development. Yup! Thats the plan for web assembly! Write in what you want, compile to browser-supported format, deploy.
- bobajeff 10y agoThat is not the plan. WebAssembly is not some holy grail universal bitecode intended for every language. It is intended for C and C++ developers to be able run their code in a performant way on the web.
- k__ 10y agoSo it's not suitable for Python, Java, or C#?
- tyoverby 10y agoNot unless you want to compile the JVM to webassembly and load a it on every pageview.
- binji 10y agoTeaVM[1] has an experimental WebAssembly backend that does something like this. Here's the recent Reddit thread[2]. [1] http://teavm.org/ http://teavm.org/ [2] https://www.reddit.com/r/programming/comments/5899ln/teavm_java_bytecode_to_js_adds_experimental/ https://www.reddit.com/r/programming/comments/5899ln/teavm_j...
- int_19h 10y agoYou just need an AOT compiler that targets wasm directly. AOT compilers already exist for Java and C# for various target architectures; this is just another one.
- kibwen 10y agoEventually it should be, but trying to design a way to integrate multiple runtimes into a single webpage is going to take some work (e.g. imagine a page that imports code originally written in Python and Javascript and Ruby and Go, all with their own garbage collectors (and Go's custom concurrency model!)). The reason that C and C++ and Rust will work from the start is that they don't require invasive runtimes and so allow the browser vendors to punt on this problem until later.
- kowdermeister 10y agoI sense some wishful thinking here. WA will supplement JS not replace it. You'll have a canvas and that's it, but with the JS interface I can see how some people will try to abuse it. You can get rid of JS's shortcomings for years now with compilation. That's not really the goal here. What I see here is low level access for raw power. Most of the JS apps don't really need it. Edit: I take it back. According to this note, I don't see what would stop anyone avoiding JS at all. http://webassembly.org/docs/gc/#webidl-integration http://webassembly.org/docs/gc/#webidl-integration
- binji 10y agoThere is a FAQ entry on this point: https://github.com/WebAssembly/design/blob/master/FAQ.md#is-webassembly-trying-to-replace-javascript https://github.com/WebAssembly/design/blob/master/FAQ.md#is-...
- kowdermeister 10y agoThat's what I remembered and I answered based on that before the edit. Once you can reach the DOM API directly from WA code, JS is redundant for you can use for example C# to build apps. I hate to sound alarmist, but we might look back at 2012-16 as the years when frontend tooling was easy :)
- maga 10y agoYes, you're right. This can allow to avoid JS in browser altogether one day. As a hardcore JavaScript developer I welcome this tech for a couple reasons. For one thing, it's undeniably a significant step forward for Web Platform as a whole. For another, now people can struggle with the peculiarities of the said Web Platform with their own languages. The legitimate grievances associated with JS over the years were due to the browser APIs and first of all DOM, which wasn't designed for JS to begin with and later just accumulated problems for the sake of backwards compatibility.
- RussianCow 10y agoI don't think that will be feasible in the near future, because in order to run another language in the browser (say, Python) through wasm, you will need to bundle the entire runtime with your app, which is an unacceptable amount of overhead for most apps.
- comex 10y agoI feel like this shouldn't be the end of the world. If everyone uses the same CDN for a given language's runtime (with subresource-integrity to ensure security), even a 1MB download should be... tolerable. Not great, but tolerable. Load time is also an issue, but WebAssembly is designed to greatly improve initial load time compared to asm.js.
- hackcasual 10y agoI'm currently working on a large-ish code based designed primarily to run via Emscripten. Current optimized .js size is 3MB. While the WASM size is noticeably smaller <2MB, startup time is actually worse due to browsers compiling everything ahead of time.
- maga 10y ago> startup time is actually worse due to browsers compiling everything ahead of time. On an upside, with WASM browsers can potentially save a snapshot of the compiled code to speed up re-runs. I recall the idea was promoted back when Dart was expecting to get its own VM, and one of the things that it would be capable of was this snapshot using.
- angry-hacker 10y agoI wonder if ad networks try to fight back against adblockers using web assembly? In theory, it should be easier because you can avoid dom, but who knows what the future will bring.