5 ms·
Hm. > 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 type
by wokwokwok 4y ago
Hm.
> 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.
- the_duke 4y agoTypescript doesn't have semantics on its own. It's a syntax for JavaScript with a static type checker on top. A lot of JavaScript isn't really suitable for a low level language because of GC, heavy use of very flexible objects, any, only a number type instead of int8/16/... and float32/64, ... 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.
- mort96 4y agoTypeScript is an extremely dynamic language which supports dynamic typing and has a very flexible type system. It has a type system that's designed for human productivity, not for machine efficiency. Compiling Typescript down to wasm in an efficient way isn't really possible. Modern JavaScript engines are the fastest ways to run a TypeScript-like language, there's very little if anything to be gained from compiling to wasm. There is something to gain from writing in a much lower level language though, be it C, C++, Rust, or, yes, AssemblyScript.
- flohofwoe 4y agoTypescript's main design goal is not to be a statically typed, compiled language but to gradually add type hints to massive legacy Javascript code bases. This is a very different goal than just having a simple language which compiles to WASM, but still looks familiar to web devs, and I bet if Typescript would add WASM output as official feature, it would have to restrict itself to a 'static' subset - it could never be all of Typescript, because this also would include all of Javascript, including all the 'dynamism' that's hard to bring over to WASM.
- maxgraey 4y agoTypeScript has completely different goals. It will always just be a semantic checker on top of JS and nothing more. This has been mentioned more than once: https://github.com/microsoft/TypeScript/issues/9202#issuecomment-226359970 https://github.com/microsoft/TypeScript/issues/9202#issuecom... https://github.com/microsoft/TypeScript/issues/10386#issuecomment-240473434 https://github.com/microsoft/TypeScript/issues/10386#issueco... https://github.com/microsoft/TypeScript/issues/375#issuecomment-51371676 https://github.com/microsoft/TypeScript/issues/375#issuecomm...