top | item 43413702

(no title)

Keyb0ardWarri0r | 11 months ago

This is the true power of Rust that many are missing (like Microsoft with its TypeScript rewrite in Go): a gradual migration towards safety and the capability of being embedded in existing project.

You don't have to do the Big Rewrite™, you can simply migrate components one by one instead.

discuss

order

TheCoreh|11 months ago

> like Microsoft with its TypeScript rewrite in Go

My understanding is that Microsoft chose Go precisely to avoid having to do a full rewrite. Of all the “modern” native/AoT compiled languages (Rust, Swift, Go, Zig) Go has the most straightforward 1:1 mapping in semantics with the original TypeScript/JavaScript, so that a tool-assisted translation of the whole codebase is feasible with bug-for-bug compatibility, and minimal support/utility code.

It would be of course _possible_ to port/translate it to any language (Including Rust) but you would essentially end up implementing a small JavaScript runtime and GC, with none or very little of the safety guarantees provided by Rust. (Rust's ownership model generally favors drastically different architectures.)

jeppester|11 months ago

As I understood their arguments it was not about the effort needed to rewrite the project.

It was about being able to have two codebases (old and new) that are so structurally similar, that it won't be a big deal to keep updating both

mdriley|11 months ago

Hi, I lead Chrome's Rust efforts. I think the Typescript folks made a great and well-reasoned decision.

aapoalas|11 months ago

Thank you, it's really nice seeing cooler heads prevail on the question of "why didn't they build in my favourite thing X?"

In entirely unrelated news, I think Chrome should totally switch engines from V8 to a Rust built one, like hmm... our / my Nova JavaScript engine! j/k

Great stuff on the font front, thank you for the articles, Rust/C++ interop work, and keep it up!

K0nserv|11 months ago

In a similar way Rust can be very useful for the hot path in programs written in Python, Ruby, etc. You don't have to throw out and rewrite everything, but because Rust can look like C you can use it easily anywhere C FFI is supported.

steveklabnik|11 months ago

> like Microsoft with its TypeScript rewrite in Go

Go is also memory safe.

gpm|11 months ago

I'd argue technically not due to data races on interface values, maps, slices, and strings... but close enough for almost all purposes.

PS. Note that unlike most languages, a datarace on something like an int in go isn't undefined behavior, just non-deterministic and discouraged.

GaggiX|11 months ago

Go can have data races, so I would not consider it memory safe.

tedunangst|11 months ago

Since you've mentioned that you never see the annoying strike force threads that others complain about, you're in one.

Keyb0ardWarri0r|11 months ago

But can't be embedded in other projects as easily as Rust (FFI, WASM).

raggi|11 months ago

Odd comparison / statement in the context of MS rewriting GDI in Rust

wavemode|11 months ago

You're saying choosing Go over Rust was a mistake? Why?

timewizard|11 months ago

"If you build it they will come."