7 ms·
>> the goal of WebAssembly is not to replace JavaScript, but to be an awesome tool to use with JavaScript. Let's hope exactly the other way around will happen.
by themihai 9y ago
>> the goal of WebAssembly is not to replace JavaScript, but to be an awesome tool to use with JavaScript.
Let's hope exactly the other way around will happen. I would rather like to see better interop between different languages using wasm than wasm + js.
- austincheney 9y agoI think that misses the point. Since WASM is a compile target you don't need JS to achieve interop between different languages if they are all compiled to WASM. The JS + WASM combo is to do things that WASM container cannot do on its own.
- fulafel 9y agoAlso, JS is a more suitable target for most managed languages like clojure, typescript, elm, etc.
- themihai 9y agoWell... two of 3 of the languages you provided as example were designed to be transpiled to javascript. I doubt JS is a more suitable target for other languages than an IR like wasm which is being designed to be a compiler target.
- fulafel 9y agoI would be interested in hearing a more detailed argument on why ClojureScript & Elm would be better if they targeted WebAssembly. Even the WebAssembly authors seem to agree that it's not foremost a managed language compile target - The Overview text from http://webassembly.org/ http://webassembly.org/ says "Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications."
- themihai 9y agoElm was designed to be transpiled into javascript just like CoffeScript so let's put it aside for a moment. WASM is work in progress so I'm sure that if people care enough they can find solutions for such specific issues(i.e. seems that VM languages have their own set of issues). There is a GC proposal so managed languages will benefit a lot(i.e. smaller runtime). JS is a high level language. I don't see many people compiling to managed languages outside of the browser. Wonder why is that? Few target JVM...but I don't see many(if any) compiling to Java, C#, Ruby or Lua or PHP. I've never seen anyone compiling JavaScript either unless they had to run it in a browser. This should tell you how good JS is when it has to compete on merit as compiler target.
- fulafel 9y agoElm semantics is very far from JS - it's a kind of Haskell-lite. The tooling and diagnostics are very much custom and don't rely on JS developer tools or source maps. (Also, "transpile" is just another word for "compile")
- themihai 9y agoDo you mean that Elm was not designed considering JS as its compilation target? Is Elm used anywhere else than the web browser? Why nobody compiles to JS outside the web browser if it's such a good compilation target? >> Also, "transpile" is just another word for "compile" Well, I prefer to use the "transpile" term when the target is a high level language. JavaScript is a high level language. It seems some smart folks decided that a new "language/IR" is needed (wasm) so that people can use other languages on the web. Now let's make this new IR a first class citizen on the web.
- fulafel 9y agoI'm sure Elm design considered JS, but I'm also sure that if WebAssembly had been available when Elm was designed, it would still have targeted JS rather than WebAssembly. Same goes for ClojureScript. WebAssembly is a refinement of asm.js, which started as a mechnism to enable C/C++ code to run in browsers. Other, managed languages aren't forced to go the asm.js route because their semantics aren't tightly married to a byte addressable, untyped program heap.
- themihai 9y ago>> I think that misses the point. Since WASM is a compile target you don't need JS to achieve interop between different languages if they are all compiled to WASM Really? Can you please point me to some documentation about this? I can't mange to find out how to use a wasm compiled library (compiled from C) in C#/mono project (which also compiles to wasm )
- glibgil 9y agoIf you manipulate the two code bases to be in the same module https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#Exploring_fundamentals https://developer.mozilla.org/en-US/docs/WebAssembly/Underst.... Otherwise, export and import which is also covered on that page
- jlebrech 9y agoyou only need js to bootstrap wasm onto a canvas. then write the rest of your "site" in QT or GTK ;)
- bigato 9y agoIs this possible already? I'd love to build web CRUDs using tcl/ttk for the GUI part
- jlebrech 9y agoyou could use emscripten to compile to wasm as a target https://kripken.github.io/emscripten-site/docs/compiling/WebAssembly.html https://kripken.github.io/emscripten-site/docs/compiling/Web...
- api 9y agoYes, that was my thought too and I was disappointed to see them defending JS at the top of the article. Getting away from dynamic language mush is one of the biggest attractions I have to WASM.
- Touche 9y agoYou already got that from asm.js though.
- themihai 9y agowhy to use a half baked solution than something designed from the ground up for the job?
- Touche 9y agoI don't read binaries so I don't particularly care how hackish the solution is as long as it works. There are benefits to wasm of course, but running C code in the browser isn't one of them.
- IshKebab 9y agoLet's be real, the goal of WebAssembly is to replace JavaScript, but providing alternatives to it. The whole "WASM doesn't replace JS!" thing is pretty much just to placate the "But what's wrong with Javascript?!" crowd.
- austincheney 9y agoI disagree from a technical perspective. WASM is a box much like an iframe or a Java applet or Flash media. Therefore the things contained within that box are isolated from the things outside that box. JavaScript, on the other hand, operates outside that box and, with appropriate bindings, can interface with APIs inside that box. The WASM will replace JavaScript argument exists not for any valid technology reasoning, because people desperately need it to (only for personal reasons) and don't understand how web technologies work on the front end. The goal of WASM was never to replace JavaScript, but to replace Flash (before Adobe announced the death of Flash) in a language agnostic way.
- themihai 9y agoI believe you are wrong. WASM has a text version and nothing stops you from using the DOM or the web APIs (given that wasm gets an API). What exactly is the black box? You can use OpenGL in javascript too if that's what you mean by "black box". You can't do anything new in wasm than in JS except you get better performance and more options (language wise).
- IshKebab 9y agoCurrently WASM can't access the DOM. But WASM-native DOM APIs are planned and then you will be able to completely ditch Javascript if you want.
- austincheney 9y agoIssues have been opened for native DOM bindings in WASM, but I am not sure if that work ever started. As others have mentioned there is the hosting bindings API that is well underway, which provides web APIs to the WASM container so that code compiled to WASM can interact with the JavaScript outside it. This doesn't sound like what you are hoping for though. At this time, and for the foreseeable future, there are no plans with active code in development to implement WASM as a JavaScript replacement, at least to my knowledge.
- skybrian 9y agoIs anyone even working on this? I don't remember seeing foreign function bindings in wasm other than for JavaScript. If there are no competitors, JavaScript wins by default, just like C ffi did on server and desktop.
- steveklabnik 9y agoThere’s a bunch of uses of wasm outside the browser. I’m personally not a huge fan of crypto currencies, but Etherium is looking to use it as a language for smart contracts, for example. Just like any small language, you can embed the interpreter into whatever and use it for scripting; the spec is written so that this is pretty easy. That said, none of this means “replacing” JavaScript, no matter what the parent says. It’s a non-goal.
- themihai 9y ago>> That said, none of this means “replacing” JavaScript, no matter what the parent says. It’s a non-goal. I believe a better term would be "skipping" javascript than "replacing" javascript. There won't be many rewrites but I'm sure that many people would skip JS on new projects if they would have that option. Why would a Python, Go, Ruby developer choose JavaScript over Python given that their language of choice would compile to WASM(along with DOM/webAPI access)? The ecosystem may be a reason but that's only a matter of time(i.e. 1 -2 years).
- steveklabnik 9y agoOne good reason is binary size; JS is going to have the advantage here since it’s runtime is already installed. Another good reason is that, regardless of what you read on Reddit and Hacker News, a lot of people actually really like JavaScript.
- themihai 9y ago>> One good reason is binary size; JS is going to have the advantage here since its runtime is already installed. Yeah, that's true now though I don't think there is something that stops browsers to host a runtime(i.e. a pre-loaded std wasm library + wasm-gc) to help the languages compiled to wasm to reduce their compilation size. The question is really whether the browsers want to make WASM a first class citizen or not. >> Another good reason is that, regardless of what you read on Reddit and Hacker News, a lot of people actually really like JavaScript. I believe WASM could serve the other lot of people who are not that much into JavaScript. Using the same language on server and browser also reduces friction(i.e. see NodeJS). Personally I believe JS has a such rank based on reach not on merit.
- amelius 9y ago> I would rather like to see better interop between different languages using wasm Yes, and garbage collection that crosses language boundaries.