9 ms·
AssemblyScript: A Subset of TypeScript That Compiles to WebAssembly
- cwyers 9y agoThis links to a GitHub organization page, which is spectacularly uninformative. https://github.com/AssemblyScript/assemblyscript https://github.com/AssemblyScript/assemblyscript is a better link for this submission, I think. You get a README.md, at least.
- bsimpson 9y agoLooks like their DNS is fucked up. http://assemblyscript.org/ http://assemblyscript.org/ redirects to their GitHub org, even though there's a website repo in there that claims to be http://assemblyscript.org/ http://assemblyscript.org/. Edit: apparently their website has no content, just a redirect to GitHub. ¯\_(ツ)_/¯
- zachberger 9y agoAnd if you look at the HTML file in the website repo it is redirecting to GitHub. Not DNS' fault
- vosper 9y agoI get the attraction for compiling a non-web language (say Python) so that you can write Python and have it run in the browser, but since Typescript already compiles to JS I don't really get it. What am I missing? Can it be faster, or do more/different things?
- shakna 9y ago> It aims to provide everyone with an existing background in TypeScript and standard JavaScript-APIs with a comfortable way to compile to WebAssembly, eliminating the need to switch between languages or to learn new ones just for this purpose. Learn WASMs APIs without the need to learn another language seems to be the goal.
- Ironchefpython 9y ago> Can it be faster, or do more/different things? Currently, no. Ostensibly, there is the possibility for significant execution speed improvements though AOT optimization in the compiler, and simpler (and therefore faster) JIT compilation in the browser. Currently however, interaction with the DOM API from webassembly is a bad experience, making it a poor choice from most browser-based apps.
- bcoates 9y agoYou get it. It's more of a dying-on-Everest-because-we-can than something you'd actually want to use.
- deleted 9y ago[deleted]
- JasonSage 9y agoI don't think so. From what I understand, calling WebAssembly functions from JavaScript (and vice-versa) incur a runtime penalty that's way worse than calling JavaScript functions from JavaScript. As such, WebAssembly makes sense for entire applications that would be compiled—think game engines targeting WebGL, or a font rasterizer targeting canvas, etc. Since this only supports a subset of TypeScript, you won't even be able to compile your dependencies to WebAssembly, meaning that literally any code you interact with that you did not write has this performance setback.
- forgotpw1123 9y ago... Until the first person ports QT or GTK and suddenly WASM is just pushing 60 PNG frames a second into a canvas.
- tyingq 9y agoIt may get there eventually, but currently, having to pass the JavaScript/wasm chasm for DOM manipulation is really slow. https://github.com/rust-webplatform/rust-webplatform/issues/20 https://github.com/rust-webplatform/rust-webplatform/issues/...
- paulddraper 9y agoBut canvas is faster.
- orange8 9y agoCanvas is part of the DOM. It is a DOM element that JS can draw graphics on.
- abecedarius 9y agoNot a problem: you can ask the canvas for an arraybuffer to draw on, and pass that to the wasm code. I did this with asm.js in place of wasm (which didn't exist yet) in http://wry.me/hacking/Turing-Drawings/ http://wry.me/hacking/Turing-Drawings/ and you can judge the speed yourself. (As that page describes, there was some overhead from calling from JS to asm.js at least when asm.js first came out. I don't know the current figures.)
- tyingq 9y agoI guess if you wanted source obfuscation that's deeper than a minifier it might be of some use? Not sure what decompiled WASM might look like.
- __s 9y agohttps://serprex.github.io/Befunge https://serprex.github.io/Befunge hit Run in Chrome & you can see the 500 instruction compilationg of Mandelbrot-in-Befunge to WASM
- themihai 9y agoIt's basically a new language very similar with TS. Think of CoffeScript without the JS legacy, interop and compilation mess.
- camus2 9y agoSo if I get things right : - ASM.js : basically assembly with a subset of javascript syntax - WebAssembly : assembly with a different format which doesn't require parsing javascript. - languages built on top of WebAssembly : C/C++ like languages with explicit memory management/ no garbage collection. - assemblyscript : C with a typescript syntax ?
- ihsw2 9y agoPreviously: * asm.js, LLVM output, Rust MIR->intermediate representation->WASM Now: * asm.js, LLVM output, Rust MIR, AssemblyScript->intermediate representation->WASM Presumably, the goal of AssemblyScript is to make WASM more accessible, as producing asm.js, LLVM output, and Rust MIR is out of reach for most people.
- orange8 9y ago- ASM.js: A faster, cut down version of JavaScript - WebAssembly: The successor to ASM.js, a compiled binary format (as opposed to plain text) with additional features - languages built on top of WebAssembly: More like languages that can be compiled to the WebAssembly binary format. currently C/C++ - assemblyscript: A subset of a languange (TypeScript) that compiles to JavaScript, but which compiles to WebAssembly instead.
- pjmlp 9y agoThere are already JVM and .NET prototypes. Rust also supports WebAssembly.
- pjmlp 9y agoYou can have GC languages already today on WebAssembly, the runtime will just be bigger. After all it is no different than targeting a real processor, I never get the point why people think it is a stumbling block.
- freechessclub 9y ago...where "A Subset of TypeScript" = JavaScript? If I am not using this, what are the other languages I can use today that compile down to WASM?
- chrismorgan 9y agoNo, a different subset. JavaScript is unsuited to WebAssembly because of its dynamic nature; this project is taking the type system of TypeScript and using it to allow compilation to WebAssembly, but the dynamic parts of TypeScript/JavaScript are disallowed. Just as asm.js is a subset of JavaScript that can be optimised more successfully, AssemblyScript is a subset of TypeScript that can be optimised more successfully.
- greggman 9y agoYou mean other than C/C++ where you cab take advantage of 30 years of libraries ? http://kripken.github.io/emscripten-site/ http://kripken.github.io/emscripten-site/
- BatFastard 9y agoYes, other than C++.
- disordinary 9y agoRust has a WASM target as well as ASM.JS. Although, it seems as though it compiles to ASM.JS and then compiles that ASM into WASM, so likely anything that compiles to ASM.JS can also then be further compiled into WASM.
- redgetan 9y agoJust noticed that quite a few browsers support WebAssembly already (http://caniuse.com/#search=webassembly http://caniuse.com/#search=webassembly) . I wonder whether compiling Unity game to WebAssembly is better (more stable) than Unity to ASM.js
- 6nf 9y agoThere is already a WASM Unity. http://webassembly.org/demo/ http://webassembly.org/demo/
- lomnakkus 9y agoI can't but think that this is such a "Hype Train" thing.
- aussieguy123 9y agoI thought WebAssembly didn't have a garbage collector yet.
- themihai 9y agoApparently the GC is compiled otherwise you have to manage memory somehow manually... >> Linking in the runtime adds up to 14kb to a module, but the optimizer is able to eliminate unused runtime code. Once WebAssembly exposes the garbage collector natively, there'll be other options as well.
- pjmlp 9y agoSo what, it just means one needs to ship one with the runtime. Commodity processors also don't have a GC.
- themihai 9y agoI assume it there is no DOM access, right?
- colordrops 9y agoNot yet. Once GC is available it should not be far off.
- Fifer82 9y agoI love TypeScript! Forgive my ignorance but what purpose does WebAssembly have in this context? I assumed that stuff like ASM was really for other non-native applications. Say for example a C++ game which then can run in the browser or stuff like that. So as a TypeScript guy with AssemblyScript at my fingertips, what doors does that open for me? I occasionally have to make HTML5 games in Canvas. Is this the kind of path where WebAssembly could be beneficial? One day will there simply be an end build step to turn everything into web assembly or is it never intended for use with the DOM?
- singularity2001 9y ago>> Is this the kind of path where WebAssembly could be beneficial? Yes but not exclusively. Quoth http://webassembly.org/docs/use-cases/ http://webassembly.org/docs/use-cases/ for use cases: Image / video editing. Games. Peer-to-peer applications. Music applications (streaming, caching). Image recognition. Live video augmentation (e.g. putting hats on people’s heads). VR and augmented reality (very low latency). CAD applications. Scientific visualization and simulation. Interactive educational software, and news articles. Platform simulation / emulation (ARC, DOSBox, QEMU, MAME, …). Language interpreters and virtual machines. POSIX user-space environment, allowing porting of existing POSIX applications. Developer tooling (editors, compilers, debuggers, …). Remote desktop. VPN. Encryption. Local web server. Common NPAPI users, within the web’s security model and APIs. Fat client for enterprise applications (e.g. databases).
- kartan 9y ago> Forgive my ignorance but what purpose does WebAssembly have in this context? Suppose a future web that is language agnostic. Your browser doesn't understand ECMAScript 2015, nor 2016, nor VBScript. It has an extremely optimized and fast virtual machine that works with WebAssembly. This reduces complexity. It brings diversity to the web ecosystem, you can use any language that compiles to WebAssembly. There are no second class languages on the web. But to build that future we need to create the tools. You can already use clang to compile many languages to WebAssembly, but ECMAScript nor Typescript are on that list. WebAssembly should be able to interact with the DOM. But also to more low level APIS like access to USB devices. (https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web https://developers.google.com/web/updates/2016/03/access-usb...) Many things can go wrong, or can be moved in other directions. But the big success of the Java Virtual Machine shows the power of compile once run everywhere approach. > Say for example a C++ game which then can run in the browser or stuff like that. That's already possible using EmScriptem (http://kripken.github.io/emscripten-site/ http://kripken.github.io/emscripten-site/). Game companies like King already use the same C++ code base for their mobile games and browser games. The problem is performance. With WebAssembly it will get more simple and faster.
- eyerow 9y agoYou should reconsider the name "AssemblyScript" if you want it to catch on.
- mhd 9y agoI'm still hoping that I'll end up on the "Hejlsberg roundabout", i.e. that this whole WebAssembly thingamajig will get me Turbo Pascal productivity again. (I know, we progressed since then in regular IDE land, but for the web, this would be a step forward)
- dakom 9y agoThis looks really cool to me for a learning environment. E.g. write some typescript, see how it compiles to s-expressions, etc.
- bernadus_edwin 9y agoMaybe someday xamarin can use this compiler
- johnhenry 9y ago> Instead of reimplementing TypeScript as closely as possible at the expense of performance, AssemblyScript tries to support its features as closely as reasonable while not supporting certain dynamic constructs intentionally: This sentences, and the examples given with it, show that AssemblyScript is not technically a subset of TypeScript. There are 'features' in the former that aren't available in the latter. For example, explicitly converting the results of binary boolean operators to boolean is something that does not exist in typescript. It's a subtle but important distinction, although I may be splitting hairs.