News for hackers. Stuff that matters.
Re:TypeScript: Branded Types by nosefurhairdo on Wednesday April 24, 2024 @03:14PM (#40148330)
If we needed a special Typescript runtime to use Typescript it would become nearly useless. The vast majority of Typescript becomes JavaScript running in Node or V8.

The web is stuck with JavaScript, and Typescript is a tool to help us write maintainable JavaScript.

Re:TypeScript: Branded Types by williamcotton on Wednesday April 24, 2024 @03:20PM (#40148429)
Could’t one write a TypeScript runtime in JavaScript or WASM?
Re:TypeScript: Branded Types by kevingadd on Wednesday April 24, 2024 @04:24PM (#40149133)
It wouldn't be very useful, since a TS-in-JS runtime would have significant performance overhead, and a TS-in-WASM runtime would have very expensive JS interop plus cross-language-GC hurdles. Might be less bad with WASM GC.
Re:TypeScript: Branded Types by DonHopkins on Wednesday April 24, 2024 @06:19PM (#40150531)
Does branding work in AssemblyScript?
Re:TypeScript: Branded Types by moritzwarhier on Wednesday April 24, 2024 @04:25PM (#40149143)
With horrible overhead, and in the case of WASM, lots of serialization and API glueing (DOM is just somewhere near the tip of the iceberg) woes, maybe?

Would be a fun thing to do for sure, but never as fast as the APIs built into the browser runtime.

Re:TypeScript: Branded Types by DanielHB on Thursday April 25, 2024 @03:57AM (#40154720)
Using any JIT language (most implementations of python, Java, ruby, JS, etc) in WASM means porting the runtime to WASM and then having the runtime (in WASM) parse and JIT-compile your code incurring a double-whammy of performance degradation (WASM runtime compiling your JIT language runtime and then your JIT language runtime compiling your actual code).

To do this kind of thing viable there are two ways I can think of:

1) proper ahead-of-time compiler for your language targeting WASM directly. But that means pretty much rebuilding the whole stack for the language as that is a completely different approach.

2) Do something like Android Runtime (ART) does which translates Java bytecode to native machine instructions whenever you install an android app. But in this case translate the bytecode to WASM and do it before distribution. This requires a new compiler-backend which is still quite complex.

Both of these mean you don't have a language runtime at all. There is a reason most WASM stuff you see is in written C/C++/Rust and it is not just the lack of GC.