by wokwokwok · 4y ago · 0 comments
> Basically, the question "when targeting WASM, why should I use C++ and Rust instead of AssemblyScript" is just as valid.
…but, if you want to write typescript then why not just write typescript?
If you want better performance surely tier 1 support for wasm, for example, for typescript, it a categorically better solution for everyone, with no need for an entirely new language?
A good comparison is rust-gpu: this is an approach to let you write gpu shaders in rust. The toolchain is different, but you write rust. You compile it. It runs on gpus.
Not everyone needs, or wants to do this, but for people who need a) very high performance, b) existing tooling, you can do it, and it saves you writing shaders in c.
When rust releases a new version, the same rust compiler compiles new rust code and new rust syntax for gpu.
So… the parallels are clear, except assemblyscript seems to have missed the boat by deciding to invent a new language with high level similarity but not quite the same” semantics.
..and when typescript continues to evolve? Will assemblyscript forever be playing catch-up to new typescript syntax? Or fall behind the rentless march of the Microsoft/typescript release cycle?
What about when Microsoft decides to make this a first class feature of typescript itself? I think that’s not really that unlikely if it means significant performance gains.
I feel this is a missed opportunity. What you wanted was to be able to compile typescript to wasm, not a new language.
There is something to gain from writing in a much lower level language though, be it C, C++, Rust, or, yes, AssemblyScript.
https://github.com/microsoft/TypeScript/issues/9202#issuecom... https://github.com/microsoft/TypeScript/issues/10386#issueco... https://github.com/microsoft/TypeScript/issues/375#issuecomm...
Assemblyscript is essentially a very restricted, low level variant of TS.
If you really want JavaScript in WASM, you can already get that by using Spidermonkey compiled to WASM as an interpreter. A compiled version of TS could be interesting, but would be a lot of work and would come with a lot of difficult challenges for getting could performance.
I will say though that I'd much rather use Rust than AS though, so I do see how the language has limited appeal.