DanRosenwasser
4 days ago
Hey there, TypeScript team member here. The tsrs project has been extremely interesting to see come together. We've been working with the maintainers to better understand how tsrs is fast and what sorts of optimizations it uses are safe. We even did our own Rust vibe port and what we currently suspect is that a lot of the speed does not just come down to language choice, and some of what is going to make TS 7.1 faster and leaner (see the charts in the blog post) actually comes from optimizations discovered in tsrs.
We think the wasm and oxlint integration makes a lot of sense for Cloudflare's needs, so this investment makes sense. At the same time, we'll be working hard and collaborating to make the official TypeScript toolset faster and even more efficient.
Congrats to the tsrs team on making this official. We're excited and we look forward to continuing on collaboration!
samuelstros
4 days ago
At this point, why invest further in TSGO?
No matter how many optimizations can be ported from tsrs to ts-go, Rust will be more efficient and enable the WASM use case.
The premise of porting the compiler from TS to GO was ease of migration due to Go's garbage collector. That doesn't hold anymore? AI doesn't care how hard or easy a migration is if a test suite exists.
magicalist
4 days ago
> That doesn't hold anymore? AI doesn't care how hard or easy a migration is if a test suite exists.
Sure, but that only matters if migration is going to be the last thing anyone does on a project. Unless you think typescript 7.1 ought to be enough for anybody, it also matters what the typescript team wants to write/read/reason in.
collabs
4 days ago
I would love this to be typescript 8 and 8.1 story (:
user
4 days ago
platinumrad
4 days ago
I just vibecofed tsasm. tsrs is obsolete now and anyone who still uses it is hopelessly behind the times. The tsrs team should delete the repository immediately and join my project.
written-beyond
4 days ago
Too late I just shipped tsvhdl so you have a hardware implementation of the actual TS compiler. Why steal valuable CPU cycles from agent workflows, off load all transpilation and type checking to a dedicated TSC chip.
simplesocieties
4 days ago
Too late I just shipped tsasic so you can have a custom-made board for every single application you will ever write.
fmbb
4 days ago
I already started manufacturing 100 shipping containers of left pad machines. Taking orders.
hdjdnxjzhzhs
4 days ago
Too late, I just shipped tsqntm, who needs silicon when you can use qubits to accelerate every state of every program all at once
z3t4
3 days ago
Too late, I just encoded a quantum spin oscillator crystal that can infer the types of all existing and future programs
huddo121
4 days ago
Egg upon all your faces! I have released tsoracle, which knows (by unknown means) whether your ts compiles correctly, instantly!
cute_boi
4 days ago
I am okay if agents can write code that is very safe in ASM. I am sure code written in Rust are naturally safe compared to asm or c. Waiting for tsasm to be significantly faster and safer than tsrs.
afdbcreid
4 days ago
I'm pretty sure a program written in asm by agents will not only be very unsafe, but also very slow compared to Rust, or even Go or Java.
awesome_dude
4 days ago
People massively overestimate Rust's "safety" - it has a very nice approach to managing data races, and. that's it.
It still, like every other language/tool we have that shares state between threads, has race conditions, for example.
RussianCow
4 days ago
Borrow checker aside, I would like to think that its type system inherently makes it safer than a language like C.
vovavili
4 days ago
That is a confidently incorrect assertion.
Kamq
4 days ago
They said race conditions and specifically exempted data races. You can absolutely write race conditions in rust, they're a logic bug.
As an example, let's say you have two functions A and B. A only works properly if B has never ran for some reason. Let's say they both accept a reference to a value C, and B changes C's value somehow. Because this is rust, we can't have data races, so we wrap it in an ArcMutex or what have you. That doesn't impact the ordering of A and B at all.
If we spawn threads that execute A and B at the same time, it's up to the scheduler if A functions properly.
awesome_dude
3 days ago
Thanks, I think that most people read "data races" and jump to "race conditions in general"
And that is my core complaint - data races are well-understood and preventable now, whether statically via Rust's borrow checker (or pure immutability in functional languages) or dynamically with tools like Go's -race detector.
Logic races remain an application-level problem regardless of language design.
rrvsh
4 days ago
You are being downvoted but you are absolutely correct. I have never seen someone assert Rust is a 100% safe. Its touted purely as a _memory_ safe language. To claim otherwise is absurd and very telling of the writer's biases
awesome_dude
4 days ago
> I have never seen someone assert Rust is a 100% safe
Please copy and paste from my post where that's being asserted
> Its touted purely as a _memory_ safe language
Which is different from what was said... how?
> To claim otherwise is absurd and very telling of the writer's biases
To pretend that those claims were made is what's actually telling of biases.
afdbcreid
4 days ago
> How can Codex write fast-to-compile Rust code, do tell?? Do tell!
Because memory safety isn't just about data races. In fact data races are far from Rust's most innovative or important feature. They are a side-effect, the designers had a nice system and saw it can also prevent data-races, so they said "sure, why not".
dnautics
4 days ago
> I have never seen someone assert Rust is a 100% safe
Maybe I spend too much time on tech internet...
Too
4 days ago
Can someone please instead spend their tokens on vibe coding an electron2rust.
jon-wood
4 days ago
Its called Tauri: https://tauri.app/
cpursley
3 days ago
https://github.com/redbadger/crux
Native UI with Crux backend. Best of both worlds.
solyin
4 days ago
Did you? GitHub link? because that would be awesome! which asm target did you pick? I looked at using LLVMs' LVM because I didn't want to have to choose ARM or x86? What are some of the trade-offs you made along the way? Wait, are you making a joke and think you're funny? (Hate to be the bearer of bad news but you're not.)
wavemode
4 days ago
Your answer is within the comment you wrote. AI is maintaining tsrs whereas humans are maintaining tsgo.
Your question boils down to "why would humans maintain something?" which could have a variety of answers depending on context.
pjmlp
3 days ago
There are plenty of CoPilot contributions on tsgo repo, forgotten which company Typescript development is sponsored by?
user
4 days ago
greenavocado
4 days ago
No, the question is now: "How much human mental momentum, ego, and investment is there in and behind any particular project or its forks?"
stephbook
4 days ago
I for one would be demotivated. Why maintain an official compiler that's not even half as fast as the vibe-coded one?
"Just" publish the language specs and be done.
Rapzid
4 days ago
These ports are borrowing large parts of the architecture, algorithms, and data structures from the official implementation.
I don't think a spec would facilitate them at such a low effort level and cost.
mrgoldenbrown
4 days ago
You need the experience of building and maintaining a compiler to make a great language spec. The tsrs team specifically said they don't want to be trying to change the spec.
greenavocado
4 days ago
> Why maintain an official compiler that's not even half as fast as the vibe-coded one?
Because at the end of the day, someone has to actually care and put in effort, even if the thing is machine generated, because it can go off the rails.
lifeisloving
4 days ago
[flagged]
melodyogonna
4 days ago
I never understand why people say things like this. It is not uncommon for languages to have multiple implementations, everything must not be abandoned for Rust man.
zarzavat
4 days ago
There are precisely two languages that make the most sense to implement the TypeScript compiler in: Rust and TypeScript itself.
A Rust implementation will have the fastest compilation speeds, memory safety, can easily be compiled to WASM, or compiled to a native node module.
A TypeScript implementation provides the most convenient way for TypeScript code to use the typescript package as a library. Pure JS, no native code or WASM dependencies. No FFI tax, can be jitted.
Go was always a compromise to make a port easier for humans. Go's GC makes it easier to keep the general code structure from the TS implementation. However that GC is also a liability, you sacrifice speed and embeddability.
Personally I'd prefer they went back to TypeScript for the reference implementation, and used Rust for the performance implementation. Go doesn't bring anything to the table anymore.
afdbcreid
4 days ago
> There are precisely two languages that make the most sense to implement the TypeScript compiler in: Rust and TypeScript itself.
Incorrect. I can maybe agree that those are the only perfect languages to implement tsc in them (if there is such thing). But in the real world, "perfect" does not actually mean "it's a good idea". Go made the most sense to port to (especially before agents), more than Rust (although C# could also be a good idea IMO).
ameliaquining
4 days ago
C#'s embeddability/interop story is even worse than Go's; IIUC this was the primary reason they chose not to use it.
WorldMaker
4 days ago
C#'s embeddability/interop story is as good or better than Golang's. The primary reason they chose not to use it was that C# was seen as too verbose compared to the TS original source. In particular TS used a lot of top level functions and bare/anonymous data types and while C# has picked up top level function support it's still not "idiomatic" and while C# has a long standing anonymous data type support it's not very "ergonomic", certainly not compared to TS structural typing. Golang's traits are a bit more ergonomic by comparison, unfortunately.
I also still think C# would have been a better long term option for maintainability, but I'm not on the Typescript team and didn't get a vote, and I can understand their methodology even if I don't agree with it.
anonymous908213
3 days ago
> while C# has picked up top level function support it's still not "idiomatic"
It has no such thing. C# has top-level statements in one file per project, which omit the usual entrypoint Main boilerplate, but that's the extent of it.
fallingbananna
4 days ago
Because TSGO is stable and compatible?
I assume that most of the speedup in ts-rs does not simply stem from using a language without garbage collection, but actually from doing smart optimizations that can be done in any langauge.
Similar to how uv in the Python world explained that their implementation being in Rust has very little to do with the most impactful speedups they did.
user
4 days ago
throw567643u8
4 days ago
The reason Anders gave at the time was Rust effectively outlaws cyclic data structures, which was not fitting of their implementation.
pier25
4 days ago
TSGO is already plenty fast and overkill for most projects.
Sure the Rust version is faster but the difference is probably only noticeable in the top 1% largest projects.
theappsecguy
4 days ago
Fast is one thing, TSGO is fast enough I think, but my god does it suck up memory
alain_gilbert
4 days ago
I'm always mind-blown when I read stuff like "speed is overkill". Speechless!
pier25
4 days ago
do you go to the supermarket with an F1 car?
tialaramex
4 days ago
I walk to the supermarket. I'm pretty sure an F1 car would be noticeably slower.
On foot I cross the little residential street where I live, walk to the corner, cross the busier road using a Zebra that was installed by thoughtful "pedestrian first" local government, then walk to the next corner where the main entrance to the supermarket is.
In the F1 car lets assume somebody already pre-warmed it and so it's ready to go (F1 cars do not "just work" like your family car because that's not required in the F1 rules) I walk to the car park and get in, I need to accelerate quite hard to get the slippery F1 car up the steep drive, but then brake hard to stop and have somebody else check both ways since an F1 car isn't equipped for this in a side street. Now I pull out, takes no time to reach that street where pedestrian me crossed but I can't use that route in a car, so, go through another residential area, turn onto an old main road, turn again, to a roundabout, go into the underground carpark of the supermarket. Once I've parked I'm about as close to the front door as if I were walking from the Zebra. Huh.
sophacles
4 days ago
Bad comparrison. The less time my computer spends doing things the less battery I use.
An F1 car goes faster but also uses more fuel to do so.
Any one tool being a bit faster doesn't make my batter last noticeably longer, but defaulting to using the efficient tooling gets me results I can see.
suriyaG
4 days ago
the cost between an F1 car and a "regular" car is high, both financially and functionally.
but tsrs and tsgo are not a similar comparison. they cost the same (you download a binary and run it) and are functionally identical. in that case why would you not use the faster & better one?
the question should be, do you always want your groceries 50% faster ?
wiseowise
4 days ago
No, but I sure wouldn’t mind if I opened my fridge and the food was already there.
riknos314
4 days ago
My car doesn't require a dedicated team of engineers to start and has a trunk to hold groceries :P
The question isn't really if the speed is bad, it's what tradeoffs you need to make to realize it. The F1 car has a very narrow operating condition and so can make tradeoffs that are completely unreasonable for vehicles that need to do other things.
From what cloudflare is claiming, Tsrs gives me more speed without tradeoffs I care about, so why not have the free speed?
baq
4 days ago
Oh boy that’s about the most off the mark car analogy I’ve ever seen and I’ve seen some
solyin
4 days ago
If I could afford one, I absolutely would! I'd add a tow hitch so it had some storage and get it all street legal and add blinkers.
AnnikaL
4 days ago
If you are travelling a long distance, say over 1000 miles/km, do you always drive? Or do you take an airplane (or a train)?
user
4 days ago
alain_gilbert
4 days ago
Do you usually dig up your garden by hand with a shovel, or do you use a rototiller?
pier25
4 days ago
Now we're getting somewhere. This is a great example because obviously speed depends on the context.
Obviously a shovel is quite an improvement for home gardeners but big constructions need a completely different tool.
For +99% of TS projects going from eg 10ms to 1ms is not going to make any difference even though it's a 10x improvement. In part because most monitors refresh at 60hz (16ms per frame) but even with +120hz monitors this is not going to have an impact on any workflow. Even for CI network latency is going to be a much bigger factor than improving TS compilation beyond the performance that TSGO already provides.
eyelidlessness
4 days ago
I think it might have more meaningful impact on high volume use cases, i.e. where cumulative run time is still significant.
That’s already meaningful for at least a couple of companies I’ve seen investing in these ports. It might be niche for individual dev workflows now, but as those evolve it could become less niche (albeit probably still less uniform).
pier25
4 days ago
> I think it might have more meaningful impact on high volume use cases, i.e. where cumulative run time is still significant
For sure but those high volume use cases are extremely rare.
seanw444
4 days ago
Do you dig your garden with an excavator?
wiseowise
4 days ago
Why are bringing Java into this?
Tadpole9181
4 days ago
I mean... If I had an excavator it beats using a shovel? This is such a silly "gotcha" analogy because the only reason I wouldn't is cost. And cost is not a reason for tsgo to be slower?
"Would you rather have worse software for literally no benefit?"
We should aim to make software as performant, bug free, feature-complete, and maintainable as is cost effective. It's asinine to argue that software shouldn't be fast, not because of some trade off, but just because someone doesn't need it to be fast for small tasks.
Which, mind you, isn't even the case here. Thousands of businesses use typescript for millions of lines of code. Performance gains can mean tens of thousands of dollars in compute or hardware or time; tons of carbon saved from being emitted.
afiori
4 days ago
Yep cost is the reason, allegedly the ts team found go a better language for a port and both using a less ergonomic language and switching target every six months have associated costs
Tadpole9181
4 days ago
And that's a fine argument to make! But this stupid garden analogy is nonsense.
afiori
4 days ago
no, it is the same idea, even if the excavator was magically free there are associated costs like keeping an industrial machine in your garden, danger or heavy machinery and possibly it is going to destroy you garden.
the analogy is not between each specific consequence/cost, it is relative to "single axis optimization" not being a solid strategy
user
4 days ago
com2kid
4 days ago
By hand. I've been gardening for years now and I only have a loose idea what a rototiller is.
But in any given year I maybe plant a dozen new plants tops. 6 tomato plants and half a dozen other random things.
norman784
4 days ago
tsrs also has an LSP, so will be interesting to see how much memory it consumes vs tsgo.
lifeisloving
4 days ago
Please you port it if its so easy, the tests are available on gh. I wont be using an llm ported ts compiler anyways, and neither would many others
Its a great way to divide and kill the popularity of your project. I made sure bun is no longer used in my devices or projects that depend on it for example, I'm not alone in this.
jbellis
4 days ago
As someone maintaining a close to 3M life Rust codebase, the downsides are real, especially rustc speed. I contribute to the mbx cache project but it only helps so much. It's only a small exaggeration to say that I fantasize daily about pursuing to Go.
skybrian
4 days ago
Another advantage of AI, though, is that it becomes easier to maintain more than one TypeScript compiler. Perhaps there's some benefits to having some diversity?
user
2 days ago
madeofpalk
4 days ago
If an AI agent could vibe-optimise tsgo, why port it all again over to rust?
samuelstros
4 days ago
because Rust will be faster and can compile to WASM which the TS ecosystem needs
egonschiele
4 days ago
Thanks for the response and it is encouraging to hear that there's more to this project than vibe coding! Sounds like some interesting things were found in the process, and I'm all for vibe coding as a way to learn new things.
lifeisloving
4 days ago
Im not because nobody actually ever learns anything. For every one person that learns something the other 99% of the population gets lazier and dumber, ponder how that might play itself out.
This is probably the most harmful tech ever created simply because how many people trick themselves into thinking they're smarter while actually becoming much dumber. We're actually cooked.
lemagedurage
4 days ago
Thanks for the input, glad to hear both parties benefit.
Could you elaborate on what type of optimizations were added to TS 7.1? As in, were they more algorithmic or related to memory management?
DanRosenwasser
4 days ago
If I recall correctly, a few of both - there were instances where some work could be done more lazily/minimally (https://github.com/microsoft/TypeScript/pull/64476), and there were instances where we changed our allocation patterns and played around with some struct layouts. We originally strived not to drastically reorganize our data structures to make things easier to port, and we have more flexibility now. We're continuing to experiment more here.
zyf
4 days ago
Been with TS for many years now and the work your team's done over the years is amazing. Thank you
zylepe
4 days ago
+1 from what I’ve seen, porting apples to apples to rust only impacts performance by a few % (sometimes in the wrong direction). The main speed up comes from algorithmic improvements that can also be applied to the original project.
satvikpendem
4 days ago
Ah I was gonna ask what happened with tsc-rs by Theo but looks like you guys are merging it in, at least it won't be a waste of his $500k in token spend, lol.