Live data from Hacker News

How I went about learning Rust

eli.thegreenplace.net

111–120 of 303 posts

Re: How I went about learning Rust

#111
post #82
post #46

Earlier quoted context omitted.

While Go is definitely fast enough for most scenarios, it is not the best language for low level code like drivers or kernel development. Go was never ever intended for this purpose.

Yes, I know (although they promoted it as a "systems language", but it was not really defined what that should mean in the beginning), but it is a restriction, you don't have in Rust. Basically, Rust can do everything Go can do, but not the other way around. That _might_ help to make a decision for a language.

Technically, assembly can do everything Rust can do, yet that doesn't help to make a decision for a language. Ergonomics matter.

Re: How I went about learning Rust

#112
post #3

I have been thinking to myself whether I should pick up Go or Rust as a new language this year. Coming from a NodeJS background, Rust looks a tad more complicated but it looks cooler. There are also more job listings looking for Golang than Rust which makes me wonder if Golang might be a more rewarding investment? What would be a good use case of Rust than Golang cannot do given its extra complexity and potentially l…

I figured I should have given some context to my question on deciding to learn either Rust or Go.

One of the reasons I started thinking which language to pick is when I started diving into web3 development. It seems like there is a trend into either using Go or Rust or both in some of the ecosystems. Think Tendermint, Cosmwasm, Solana, etc. While it makes sense to just learn both languages, I don’t think I have the mental capacity to learn both together quickly. It might work better to learn the one that has the most potential in the long run based on the trend.

Re: How I went about learning Rust

#113
post #3

I have been thinking to myself whether I should pick up Go or Rust as a new language this year. Coming from a NodeJS background, Rust looks a tad more complicated but it looks cooler. There are also more job listings looking for Golang than Rust which makes me wonder if Golang might be a more rewarding investment? What would be a good use case of Rust than Golang cannot do given its extra complexity and potentially l…

Since you're coming from a NodeJS background, you'll want to pick up an introductory textbook about C as well. Rust implicitly relies quite closely on the C machine model, and introductory books about Rust (such as "The Rust Programming Language") don't do a very good job of conveying the nitty-gritty details of that model to novice coders. This is a pretty nasty pitfall when trying to code in Rust, and it's importan…

I'm self-publishing "Rust From the Ground Up" which takes this approach: each chapter rewrites a classic Unix utility (head, cat, wc, ...) from the original BSD C source into Rust. I find for systems programming it's easier to understand how things work in C, and then teach the idiomatic way of doing it in Rust. C is pretty easy to follow along in "read-only" mode with some explanations.

https://rftgu.rs/

Re: How I went about learning Rust

#114
post #49

Earlier quoted context omitted.

> Also, the community is toxic. How so? I've seen the random drama crop up here and there, but it always seemed to mostly be about the "political" side of things, as opposed to the technical development. What few interactions I've had with library maintainers and the tokio project have always been positive, and the people always seemed helpful.

Comments like this one below are often downvoted without reply just because they criticise rust: > I founf myself in your same situation a few months ago. I chose Rust and regret it... https://news.ycombinator.com/item?id=32105336 GP puts it well: > Just like in any sect. As long as you agree everything is perfect, the community is the friendliest indeed. The community isn't toxic as long as you happen to agree with…

GP is also wrong.

At this point it's mostly a meme. Rust is slow to compile. I mean, yeah if you abuse meta programming or monomorphisation.

I've been programming in it, and while I like the language, I'm not on the language community bandwagon. E.g. CoC and it's enforcement (I think it's just pointless grandstanding).

Re: How I went about learning Rust

#115
post #62

Earlier quoted context omitted.

I founf myself in your same situation a few months ago. I chose Rust and regret it Rust is a better c++. It's not appropriate for anything you wouldn't program in c++. The coding speed is slow So if you are thinking about learning a new language to program your future apps you currently code in node, choose Go

> Rust is a better c++ The Rust language is a far better C++. In practice, the compile time and binary size of Rust are out of control, which makes Rust far from being a slam dunk over C++. Crossing my fingers this will change!

I get the sentiment, but like to nuance it a bit.

The compile time story of rust and C++ is comparable, if you use it the same way. If you use deep include hierarchies and no precompiled headers, if you start using template heavy code like boost, or if you do code generation, the C++ compile times will quickly spiral out of control. Rust does not have the include problem, but the specialization/templating idea is shared with C++, and the code generation problem has an equivalent in the macro mechanism as used by e.g. serde.

In theory, you can get comparable compile times from both. Main difference is rust heavily emphasizes a programming strategy that depends on these 2, and it has a heavy cost in compile time. Meanwhile, a lot of the C++ code is still in the 'C-with-classes-and-every-vendor-creates-a-string-class' camp and while the abstraction level is lower, so is the compile time.

For the binary size, C++ can hide a lot of stuff in libraries, while rust compiles it in and duplicates it for each executable. So you pay a higher fixed cost per application. As long as rust has no stable ABI, rust will stay behind at this point. But it gets better optimization opportunities as it can merge the standard library code with yours, and inter library calls are more costly so runs wins there too. Presumably it's early day for a stable ABI in rust, big wins are still made. Long term, I'd personally like to see some ABI stability in the rust world.

Re: How I went about learning Rust

#116

Earlier quoted context omitted.

Rust actually supports most OOP features, with the main exception of implementation inheritance. And implementation inheritance is a nasty footgun in large-scale software systems (search around for: "fragile base class problem"), in a way that just doesn't apply to simple composition and pure interfaces (traits). So it's hard to fault Rust for including the latter and not the former.

For me, one of the main reasons to use OOP is dynamic dispatch / runtime polymorphism. I have not spent much time with Rust, but it seems like that is a bit cumbersome there, and doesn't exactly work like you would expect from Java, C++, Python, .... I mostly use OOP when I have a bunch of Foos and Bars, and want to treat them differently in some places. Instead of having ifs in each function, I use inheritance, and…

Not a Rust expert but: doesn't Rust support this use-case via Box , and leveraging default Trait methods, only overriding the defaults you want to for each type implementing the Trait?

Re: How I went about learning Rust

#117

Earlier quoted context omitted.

> Also, the community is toxic. The Rust community has been the friendliest PL community I've seen so far.

Just like in any sect. As long as you agree everything is perfect, the community is the friendliest indeed.

That's not fair to Rust. I think it's feature of community size and genuine interest/innovation in Rust.

Re: How I went about learning Rust

#118

I am currently starting with rust too. I'm coming from a C#/ASP.NET/Angular/SQL background. I really like the official documentation so far. https://doc.rust-lang.org/book/ch00-00-introduction.html I also really like this quick introduction. https://fasterthanli.me/articles/a-half-hour-to-learn-rust You won't "learn" rust by reading it but you get a pretty good picture of the basics in my opinion. Maybe someone more…

I liked that fasterthanlime article a lot too. The main thing it gave me was enough context to get enthusiastic enough about the language to sit down and read through the O'Reilly book¹ (which I thought was excellent).

I'm still very much a Rust beginner, but I've managed to build a couple of useful tiny projects and to hack a feature I wanted into someone else's big 'ol codebase!

¹https://www.oreilly.com/library/view/programming-rust-2nd/97...

Re: How I went about learning Rust

#119
post #70

Earlier quoted context omitted.

Minor nitpick but goroutines are absolutely not preemptable, they’re cooperative. The go compiler regularly sticks in yield statements around IO, and certain function calls, but you absolutely can starve the runtime by running a number of goroutines equal to the number of cores doing heavy computation, just like Node.JS’s event loop.

This changed in Go 1.14 on most platforms: https://go.dev/doc/go1.14#runtime

TIL

Re: How I went about learning Rust

#120
post #3

I have been thinking to myself whether I should pick up Go or Rust as a new language this year. Coming from a NodeJS background, Rust looks a tad more complicated but it looks cooler. There are also more job listings looking for Golang than Rust which makes me wonder if Golang might be a more rewarding investment? What would be a good use case of Rust than Golang cannot do given its extra complexity and potentially l…

For someone writing node apps, Go is a better fit. Go is much simpler than Typescript and almost performs as well as Rust. The reality is most Rust apps written by average Rust programmers do not noticeably outperform Go apps. Getting Rust to outperform Go requires a high level of proficiency in Rust. The effort vs reward definitely favors Go for node type of apps.
Post reply on HN