r/programming • • Jul 08 '26

Announcing TypeScript 7.0

https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/
468 Upvotes

128 comments sorted by

View all comments

203

u/DigitalWizrd Jul 08 '26

The speed increase on compile is crazy fast here. 

57

u/MehYam Jul 08 '26

That'll happen porting a v8-based compiler to native.

7

u/CherryLongjump1989 Jul 09 '26 edited Jul 09 '26

Go is not native any more than V8 is. It’s a managed language that bundles a runtime together with your code in a single executable binary. Just like JavaScript can and does these days. The only difference is JIT versus AOT. The other main difference is that JavaScript is dynamically typed and it prevents the compiler from implementing numerous performance optimizations. And the final difference is the runtimes support different threading implementations, which is where the bulk of the actual performance gains were made by porting from V8 to Go.

Theoretically if TypeScript had a dedicated runtime instead of using type erasure to turn it back into JavaScript, it could also be faster than V8 is today.

24

u/vplatt Jul 11 '26

Go is not native any more than V8 is.

I have to push back here because Go absolutely is "native".

By "native", most programmers mean one of these:

  • Native machine code (x86-64, ARM64, etc.)
  • Doesn't require an external VM like the JVM or .NET CLR or V8

In other words, the code is compiled so that the binary runs directly on the operating system without help from anything else. That's the very essence of "native", and Go absolutely is a native language.

A Go compiler emits machine instructions ahead of time, sure, and JIT will get us to machine instructions too, but there are huge differences in how those perform so pretending they're on the same level is just not helpful.

1

u/CherryLongjump1989 Jul 11 '26 edited Jul 11 '26

Go still ships with a runtime - scheduler, garbage collector, the whole nine yards. You can do the same exact thing with C# -- AOT compile to native and package it up in a fully self contained runtime. No external dependencies needed. Anytime you have a self-contained executable, whether Go or JavaScript or C#, your executable binary is going to be platform specific - x86, ARM64, etc. That's exactly how it works. You can't say the jitter is where the performance bottlenecks are -- C# is normally jitted and still just as fast as Go. Jitters can be more efficient than AOT under many scenarios. Which is why you don't see people falling over themselves to use AOT with C# in everyday situations. It's nice to ship small, cross-platform binaries, too, and you normally don't give up much of anything.

When you've got a managed language with an extensive runtime, "native" is just jargon, it's not technically significant. The Go runtime is hefty -- one of the reasons why go WASM modules are huge. Compare it to languages with little or no runtime artifacts - C, C++, Rust, Zig, etc -- there you can see what true "native" looks like. Small binaries, fastest possible performance, WASM modules that are suitable for shipping across a network, etc. There native means something more than just AOT compilation.

10

u/vplatt Jul 11 '26

Go does not use a VM. Go programs are always shipped as binaries instead of with bytecode that must be JIT'ed. They are therefore "native" and they are just as native as any C, C++, or Zig program. Yes, it's a "managed" language because it has GC, an allocator, and a scheduler but that's all linked directly into the executable. Yes, that does make them somewhat larger than C binaries for example, but they're both native.

→ More replies (7)

2

u/afl_ext Jul 10 '26

Wonder if subset ts to llvm ir compiler is feasible

2

u/CherryLongjump1989 Jul 10 '26

People have done something like compiling TS to Clang before.

7

u/NotTJButCJ Jul 08 '26

Is this not just because of the switch to using multiple workers? I might be misunderstanding

30

u/vincentofearth Jul 08 '26

Yes, back when they first announced this, Anders mentioned that some of the biggest performance gains were due to shared memory concurrency. You simply can’t do that in JS. (You could run multiple processes but the overhead of passing data between them erased any perf gains)

1

u/YeOldeMemeShoppe Jul 10 '26

SharedArrayBuffer works, but yeah it probably wouldn’t be as much gains.

1

u/MediocreAnalyst2121 Jul 09 '26

Happen to know how it works now, goroutines?

6

u/TwoWeeks90DaysTops Jul 09 '26

Probably from more efficient code *and* from multi threading.

edit: from their table it's very clear that there's more than just workers going on since a x8 number of workers produced x11-x16 speedup.

0

u/DigitalWizrd Jul 08 '26

Honestly, no clue how it works. But the speed increase is impressive regardless of how it was done.

21

u/javascript Jul 08 '26

Last I heard there was a memory leak in the Go implementation. Has that been fixed?

0

u/[deleted] Jul 08 '26

[deleted] — view deleted comment

51

u/Veranova Jul 08 '26

It also drives the LSP which is running permanently in your editor. And there’s watch mode too which is more incremental

1

u/Maybe-monad Jul 09 '26

Very likely, I have been using it in the past month and didn't encounter any leak

-5

u/pjmlp Jul 09 '26

Expected by anyone that understands how compilers go.

There is no surprise rewriting the trendy scripting languages, into the traditional AOT compiled languages approach that predated Web taking off, for those of us that started with BASIC, C, C++, Pascal, Modula-2, Delphi,...

5

u/DigitalWizrd Jul 09 '26

Congrats on your years of wisdom. 

2

u/ChocomelP Jul 09 '26

What do you mean? This is obvious to anyone who already knows it. /s

1

u/frankster Jul 09 '26

I'm sure you could also speed up a compiler written in most forms of BASIC by 8-12x by rewriting it in go

→ More replies (1)

1

u/TheKrumpet Jul 09 '26

I mean JS is generally jitted these days as much as it's a 'scripting' language. AOT tends to win out in first startup times but jitted languages can be faster over time with PGO.

It's not one size fits all, some tools are better in some domains.

4

u/pjmlp Jul 09 '26

Yes, but there is only so much a JIT can make with a dynamic language, and that already includes plenty of heroic efforts in V8.

Typescript rewrite happened exactly because the team could not improve performance any further.

PGO also exists for AOT tooling, in fact it started there.

→ More replies (10)