Live data from Hacker News

Should I Rust or Should I Go?

kerkour.com

61–70 of 178 posts

Re: Should I Rust or Should I Go?

#61

You should Typescript. Performance comparable to Go. A more flexible typing system than both. Easier to learn than both. A worse package system, but that can be mitigated with discipline. What Typescript currently lacks the most is affordances for embedded or performance intensive work as it's single threaded, but when performance matters use NAPI to use Rust in your Typescript, but the trajectory of performance of V…

I love TypeScript for back-end work. Node.js is astonishingly fast, thanks to V8. TS is concise, has a wonderful/expressive type system, can share code/types with the front-end, and has libraries for damn near everything.

It's the easy choice for new projects. And yeah, if/when it's time to optimize later, and the raw performance of V8 ain't enough, you can reach for threads, WASM, or Rust. 10/10 experience.

Re: Should I Rust or Should I Go?

#62
post #20

Earlier quoted context omitted.

They do?? Sauce?

I remember reading years ago that the hack compiler was built in ocaml. compilers and such are often built using languages with nice ADTs afaik.

The Rust compiler was bootstrapped from OCaml as well!

Re: Should I Rust or Should I Go?

#63
I don't agree with much of this - especially if the alternative is Go. I'm a semi-fan of Go but there are really very few situations I'd pick it over Rust.

> Rust is the 14th most used language

I think the author is a bit confused about "most loved" - that means that people who already use it want to keep using it. 14th most used language is great for such a young and not beginner friendly language. It's only 1 place behind Go and that is 3 years older.

Additionally Rust is mainly replacing C/C++ codebases which are generally much older and slower moving than other languages.

> Now imagine being the developer tasked with updating the dependencies of a service that is 31 versions behind... > During the same period, there was 8 Go releases, 7 Node.js releases (but only 2 LTS) and 3 Python releases.

This is obvious nonsense. The stability of a language is not measured by the number of releases. Come on, did this guy really write a successful book about Rust? Is this satire?

> Rust is actually still in the beta phase, with some important features such as async Traits still missing, which brings more churn to the ecosystem.

Really? Is C++ "still in beta" because it doesn't have async?

> The standard library is anemic

Sure that is an issue in C++ where using third party libraries is a huge pain. Doesn't really matter so much when you can just `cargo add regex`.

> async is hard

This is the only vaguely valid point. But on the other hand 90% of the time the solution is simple: don't use async.

Very disappointing article. I was expecting an actual good comparison of the pros and cons. Go does have some notable advantages over Rust - compile time, ease of cross compilation, simplicity, goroutines, built in fuzzing support, arguably better dependency management. Why not talk about them?

Re: Should I Rust or Should I Go?

#64
> I think that a modular and rich standard library such as Go's or Node.js's offers way higher productivity to developers, consistency to the ecosystem and reduced costs for businesses.

Is the Go standard library really considered rich? Coming from languages like python or ruby I found it pretty lacking. Admittedly I haven't used Go in 3 years.

Re: Should I Rust or Should I Go?

#66
post #10

> As far as I know, today, Rust is the only programming language (other than C) able to create efficient WebAssembly (wasm) libraries Zig is also a good option for that, but the language is still in development.

Maybe once Zig supports WASIX

wasm is enough to do fancy things in the browser, games for example, with Rust or Zig. WASIX is not necessary for this.

Re: Should I Rust or Should I Go?

#68
post #25

Earlier quoted context omitted.

Why Go for web and not Typescript with nodejs/deno. The ecosystem is also huge and widely used. The type system is miles ahead of Go and is closer to rust. The async await is single threaded too.

Why use an ecosystem that needs 2-3 layers of build tooling, none of which is designed to work together when you can use any of the sane stacks instead? Not to mention the hell that is Jest, Eslint and trying to make those play with aforementioned 2-3 layers of crap. Then you also have to put up all the downsides of purely single threaded concurrent programming instead of Go M:N model which is much less prone to prob…

[deleted]

Re: Should I Rust or Should I Go?

#69
So Ive been tugging on this myself. I came up with one heuristic for myself.

If you need to write microservices (especially for control planes where there good concurrency and distributed system patterns needed) - I find Go be a fine combination of performance (GC hit will be there over Rust), ease of deployment, programming model (CSP) - at a slight expense on verbosity (say compared to python and you also get used to this with your patterns).

If you need high perf/low latency/near C (embedded systems level) performance - with a type system assisted memory management - then Rust.

I have found Go's stdlib to be pretty thorough (and the ecosystem to be awesome too). Yes you will always find that set of X things hard to find that others dont care about. But horses for courses.

I have invested in learning both (but I also find learning languages a joy). But if you absolutely only have time for one consider your use case and pick appropriately. Yes you can do Rust for services too but given all this dual asyn model discussion still ongoing and a lot of real world services/control planes in Go there are already good Go patterns you can leverage right away at a much lower learning curve.

Re: Should I Rust or Should I Go?

#70
Honestly? Though I am forced to write go at work, I take Rust in a heartbeat(and it is a constant moaning from my end to ditch go and use Rust all the way almost every day). First thing to keep in mind is that Rust today is nothing like the Rust of 2015, even 2020. Way too many things are wrong with go: The packaging is one thing which I absolutely hate. I can't find words to express how much I hate the import "github.com/whatever" and that is a clear indication of the fact that packaging is an afterthought, which historically was a problem the language designers chose to ignore and kick the bucket down the road, hoping the community figures it out. Another clear indication of this is everything around the environmental variable hell: GOROOT, GOPATH and all that. Error handling is another horrible thing: ok, err := whatever() is absolutely wretched, even more so when you have to write the function definitions. Even when all linters are happy with the code, I can't look at it without thinking "this looks as beautiful and idiomatic as a roadkill". While coroutines(I hate the name goroutines) are cheap, they are not a universal solution to all problems and with that in mind, having a compiled language with no actual threading is ridiculous: threads are a great thing to have(I know this goes much deeper but let's not turn this into a novel). While both languages don't have inheritance, at least with Rust you have some tools to help you generalize basic things: macros. The statement that golang has all you need in it's standard library is a complete joke. While the ecosystem has grown immensely over the years, I feel like it's reaching the point where it's comparable to the npm hellhole.

With Rust you get a perfectly thought out packaging. You also get the best of both worlds - runtimes and threads. By design you are pushed hard to properly handle errors. Some of my large Rust projects take forever to compile, I'll give you that, but there is a good reason for it. The compiler is actually helpful and in a lot of the cases it tells you exactly what you need to fix when you mess up. And don't even get me started on performance. I have the exact same microservice implemented in both go and rust. And while I did not opt for the most performant rust web framework (poem), it's not even a race, it's a straight up massacre: when I benchmark the two with wrk, the difference in performance is literally 11 times - same database, same openapi specification, same logic. While the Rust standard library lacks a lot of things, even some basic functionalities, cargo takes care of it for you with 0 effort: cargo new whatever, echo 'rand = "0.8.4"' >> whatever/Cargo.toml and you are done.

Don't get me wrong, this is not a "bash-golang" comment. But I can't deny that when I put the two side by side, go looks like a toy language.

Post reply on HN