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

Show parent comment

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.

-3

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

A VM is just a type of runtime. Go still has an extensive runtime. A purist would even draw the line at C++ -- it too still has an extensive runtime, but nowhere near as hefty as Go. C and Zig are your purist native languages. But Go will never cross that threshold to sit next to C or Zig simply because it can't. Go will always rely on existing C libraries wherever performance truly matters -- precisely because it's not part of the same club of "native" languages as people colloquially call them.

6

u/vplatt Jul 11 '26

A VM is just a variant of a runtime that happens to take in bytecode.

Yup. And they will JIT that bytecode to machine code.

And that performance cost and those extra steps are what distinguish them as VM programs that are not native. ;)

-1

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

No -- you see this is just upside-down backwards. You're never going to run Go on a real-time microcontroller precisely because that's what distinguishes a runtime from a truly native program. In the world of costly abstractions, the VM part is not the bridge too far -- you've already crossed it long ago with Go's runtime.

If you're comfortable with having a runtime for your use case, a VM is not a bridge too far and can even be faster than AOT. A jitter is exactly what you want for frequently executed code paths in a long-running process. Jitters can and do cache the native code, so the long running process will settle into a highly optimized natively-compiled execution loop eventually. Jitters are not interpreters after all.

Go tries to make a stand on the AOT hill and this is mostly fine for short-running tasks most of the time. But that's not even why people use it in the end. Go's greatest strength is its threading model, which is vastly superior to Java's in all of the areas where Go is chosen over Java. Go's concurrency is really good. But that's not because Go is "native", and the "native" part really doesn't give you as much of an advantage as you think. Bytecode languages on the JVM or .NET are very competitive with Go in terms of performance.

C# bytecode has gone head to head with C++ for "world's fastest language" in the Software Drag Racing competition, for example, whereas Go was and continues to be a "middle of the pack" result.

3

u/vplatt Jul 11 '26

VMs are VMs and they aren't native, and JIT isn't going to be on a microcontroller either. You think by arguing against the case for Go on a microcontroller that would possibly even support the case you're making for JIT and VMs?

In the end, what I said stands: Go executables absolutely are native. Nothing you said changes that. Whether or not you'd ever want to run it on a microcontroller is up to you, but it has been done anyway, AND I've seen C# and Java used that way too, so I don't know what makes you think Go couldn't do the same.

-1

u/CherryLongjump1989 Jul 12 '26 edited Jul 12 '26

You are special pleading and then trying to put words in my mouth. Bad faith, bad faith.

The Go runtime and a VM is NOT THAT DIFFERENT and your attempt to distinguish Go from other runtimes by claiming that Go is “native” is not carrying the water that you want it to carry. It doesn’t get Go into places where a VM won’t fit. You’re still stuck competing with VM runtimes for use cases. You are not competing with native languages or things that only native languages can do. You are not competing with native languages for performance, either, because you really can’t — whereas VM runtimes have already shown that they can eat Go’s lunch.

In the end, you have made an argument that has zero substance. It adds no value than what was already stated - that Go is compiled AOT. Yes, AOT generated machine code that goes directly into your binary. This is a captain-obvious level of observation when it literally adds no value to the conversation. You have utterly failed to make any notable points or compelling arguments by pointing out that Go is “native”. Which is what I have warned you about not doing. But instead you doubled down. In the end you’ve given a master class in cargo culting. Congratulations.

EDIT: LMAO as if I needed any more proof of a bad faith argument -- he tried to win it by having the last word.

3

u/vplatt Jul 12 '26

I think we're talking past each other because we're answering different questions.

My point was never that Go outperforms every VM language or that a runtime is somehow "bad." My point was simply that "Go isn't native because it has a runtime" is not a technically accurate statement.

Again: a native executable is one whose deployed artifact is machine code executed directly by the CPU. A VM-based executable is one whose deployed artifact is source or bytecode executed by a virtual machine (whether interpreted, JIT-compiled, or both).

By that definition:

C, C++, Rust, Zig, and Go are native. Java, C#, Python, and JavaScript are VM-based.

Go's runtime is a linked library providing services such as GC, scheduling, and stack management. It is not an execution engine for Go bytecode because Go doesn't deploy bytecode.

Whether Java's HotSpot or V8 can outperform Go on particular workloads is an entirely separate discussion. VM languages can absolutely beat Go in some cases due to sophisticated JIT optimization. That doesn't change the execution model or make Go "not native."

So I'm not arguing that "native" implies "faster" or "better." I'm arguing that "native" describes how the program is deployed and executed, not whether it happens to include a runtime library.

I don't mind technical disagreement, but your replies have become increasingly dismissive and insulting. Calling my arguments "cargo culting," "captain obvious," and "a master class" isn't advancing the discussion, so "congratulations!" back to you because you've now have a textbook example of how to fail at having a technical discussion. Replacing the terms of a technical discussion with insults is a clear type mismatch, but I'm not a compiler with infinite patience so consider this bridge burned.

::plonk::

→ More replies

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.