New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAssembly support #737

Closed
GerjanOnline opened this Issue Mar 1, 2017 · 9 comments

Comments

Projects
None yet
4 participants
@GerjanOnline

GerjanOnline commented Mar 1, 2017

Now that WebAssembly is out of preview (https://lists.w3.org/Archives/Public/public-webassembly/2017Feb/0002.html), is this something you consider as an alternative output?

Personally, I think it can give F# a head start and maybe drive the F# adoption as a whole. You guys have done incredible job by building this "new webstack" but supporting WebAssembly may give it an extra enormous boost.

It is just a question, I have not read the specs of WebAssembly and did not look at the limitations. I am just curious what you think about this matter.

@alfonsogarciacaro

This comment has been minimized.

Member

alfonsogarciacaro commented Mar 1, 2017

There seems to be a lot of hype (and confusion) about WebAssembly ;) I've read a bit about it, but I haven't fully understand it yet and even if it's out of preview now (which just means browsers can enable it by default), I don't think it means that WebAssembly is already a finished product.

According to its high level goals right now WebAssembly only has the same functionality as asm.js, and if you look at its specs you'll see that's mainly designed to crunch numbers: only numeric types (no string, etc), no garbage collection, etc. This makes it very difficult to target WebAssembly from a higher level language like F#. For reference, see why Typescript cannot be compiled to asm.js.

The goals also say that there'll be more features coming and support for other languages than C/C++. I think also Icaza commented they want to port the .NET platform to WebAssembly someday. So I guess it's in the horizon, but we still have to wait :) Anyway, now that WebAssembly is supported by the browsers, there'll be more libraries coming for intensive computations and you should be able to use them from F#/JS.

@GerjanOnline

This comment has been minimized.

GerjanOnline commented Mar 1, 2017

Thanks for your answer, I also read scala-js/scala-js#1747 that was also mentioning the lack of GC.

Conclusion is: little more patience :)

@alfonsogarciacaro

This comment has been minimized.

Member

alfonsogarciacaro commented Mar 1, 2017

Yes, we must wait. But that's OK, we programmers are always waiting for the "next big thing" :)

Anyway, although any performance promise is always very appealing, take into account that the main benefits of WASM will be in the parsing and compilation times, which are not that bad for most applications (and JS execution performance in V8 keeps getting better and better). And as commented above, I'm pretty sure that there'll be many libraries coming for computational intensive tasks that'll you be able to consume from your JS/F# apps (three.js comes to mind).

@jslegers

This comment has been minimized.

jslegers commented Jun 22, 2017

I understand that TypeScript is not intented to be compiled to asm.js, C/C++ or WebAssembly (and I expect that), the ability to export a language like Flow or TypeScript to typed AST in some way or another would be a good first start. With the TypeScript core devs not interested in this feature, it would at least open up the possibility for other teams to implement TypeScript to WebAssembly, TypeScript to C/C++ or TypeScript to asm.js conversion wherever possible.

@jslegers

This comment has been minimized.

jslegers commented Jun 22, 2017

Those also interested in converting staticly typed variations of JavaScript to asm.js, WebAssembly or C might want to take a look at ThinScript, TurboScript or AssemblyScript.

ThinScript compiles to JavaScript, WebAssembly, and C. TurboScript compiles only to JavaScript and WebAssembly. AssemblyScript compiles to WebAssembly only.

Each of these languages have been inspired by TypeScript, and the latter is a subset of TypeScript.

I'd like to thank @RReverser for pointing me in the direction of these languages.

@alfonsogarciacaro

This comment has been minimized.

Member

alfonsogarciacaro commented Jun 22, 2017

@jslegers Now that's something very interesting 😉 If we just have a language very similar to typed JS/Typescript it should be easy to target it using Fable. We just need an AST specification like this one and a function to transform that AST to actual code.

@jslegers

This comment has been minimized.

jslegers commented Jun 22, 2017

I like where TurboScript is heading :

AssemblyScript is only two weeks old, so it's still too early to see where that one is heading... but that one sure does look promising as well!

@ShalokShalom

This comment has been minimized.

ShalokShalom commented Jan 3, 2018

Any news?

@alfonsogarciacaro

This comment has been minimized.

Member

alfonsogarciacaro commented Jan 3, 2018

@ShalokShalom Compiling Fable to WASM is not a priority at the moment, if it happens it would be, as discussed above, compiling to a JS-like language that targets WASM. Apparently the languages mentioned above haven't evolved much so I'm not sure. Recently I had a look at https://github.com/ballercat/walt but it seems to also be in an early stage too.

You may also want to have a look at https://github.com/ncave/dna-redux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment