Live data from Hacker News

How I went about learning Rust

eli.thegreenplace.net

191–200 of 303 posts

Re: How I went about learning Rust

#191
post #128

Earlier quoted context omitted.

What Rust web libraries/frameworks do you use and recommend? How long does your Rust project take to compile?

> What Rust web libraries/frameworks do you use and recommend? This might not be a satisfying answer for you, but I use my own framework. Its main selling point is that it can be compiled in two modes: during development it has zero dependencies and is blazingly fast to compile (it has its own minimal HTTP implementation, its own minimal executor, etc.), and for production it switches to use production-ready crates w…

Anywhere you picked this up from I could read more about?

Fellow npm-syndrome avoider.

Re: How I went about learning Rust

#192

I love rust. I didn’t find it difficult to learn and at this point several others I’ve introduced it to also haven’t. I’m baffled as to where that reputation comes from. I get that it makes you think about what you’re building a little more than something you can throw together like Python or Ruby but if the end goal is software that works correctly, getting there definitely isn’t harder with rust. It’s the complete…

I use Rust for more or less everything these days, but I found the learning curve to be fairly tough up front. That was in 2019, though; maybe it's easier today with all the improved compiler diagnostics and new books and whatnot.

> if the end goal is software that works correctly, getting there definitely isn’t harder with rust. It’s the complete opposite :/.

Strongly agree with you here. It takes me a lot less time to put something that functions correctly together with Rust than it does with Python or Go. Maintenance also gets a lot easier as the codebase grows.

I recently started a job at a Python shop, and the kinds of bugs/regressions we hit are super annoying because a compiler with a type system would have had them simply be build errors up front.

Re: How I went about learning Rust

#193

Earlier quoted context omitted.

> they won’t reference each other directly with references/pointers I'm not sure if I understood your reply correctly, but there seems to be nothing in Rust stopping one dynamic trait (interface-based) object directly referencing another dynamic trait (interface-based) object. The main difference between C++ O-O and Rust trait-oriented programming is C++ inheritance of implementation vs. Rust inheritance of interface…

You can do references in Rust. But you can only have one mutable reference to an object at once unless you work around this with locks (Mutex, RefCell, etc). So for anything other than trivial child object references, you can quickly paint yourself into a corner of compilation errors by using webs of references. And this seems to be the basis of a lot of people's frustrations with Rust. It's true that you also can't…

I definitely see your point about the interconnection of references, mutability and lifetime in Rust, but I guess the issue of whether Rust has a problem with the classic O-O comes down to the question of what you are trying to implement. If you are implementing a graph-like data structure (for example, UI widgets in a window), you need to keep track of multiple mutable constituent structures; in that situation, Rust references indeed are problematic for the classic O-O and you need Rc/RefCell smart pointer shenanigans. If you are implementing an actor (an algorithm, a subsystem, a process, etc. - for example, a Product, a Customer and an Order), you usually need to keep track of only a handful of structures representing the input to an actor, all of them likely immutable (a mutable actor with its input kept immutable to eliminate unexpected input side-effects); in that situation, Rust has no problem with the classic O-O, since abstractions can be expressed through references to trait objects.

Re: How I went about learning Rust

#194
post #182

Earlier quoted context omitted.

But that's just the default, you can tell it to use dynamic linking. What libraries were you missing? I find the rust standard library is better in many ways, and it doesn't have the same performance footguns.

I don't feel Rust has any performance advantage to c and c++ per my own tests. yes I can dynamically link to stdlib in Rust but I don't think Rust has a versioned dynamic library released for multiple architectures(still many embedded archs are not fully supported in Rust), that leads to problems in the field at depolyment and upgrade phases. Plus the dynamic library after strip is still close to 6MB, I can have a fu…

6MB is quite large. Makes me question if you were even building in release mode.

You may want to see https://github.com/johnthagen/min-sized-rust

It's not difficult to get binaries down into the 50KB range. And for embedded applications, less than 10KB is totally possible.

Re: How I went about learning Rust

#195
post #125
post #60

Earlier quoted context omitted.

> slow to compile In my experience it's the slowest language to compile ever , and the binaries generated are gargantuan. I was super excited to learn Rust, but that excitement is now 100% gone.

Same. I was about to jump into learning Rust and make it my no.1 language for new projects instead of node.js + TypeScript, but once I learned about the slow compile times I stopped that thought immediately.

For me it was a choice between slow compile times now when it’s safe, or unbounded time solving security and stability issues later when it’s critical.

Re: How I went about learning Rust

#196

Earlier quoted context omitted.

Having studied mostly OOP/Java at the uni, and been using mostly C# at work, I realized I might actually start to find programming fun again through Go. I've studied it a bit recently and this idea of interfaces with composition over inheritance etc. made somehow a lot more sense to me, and gave me this boost to try and learn it more because it felt so enjoyable. Not even with some practical problem at hand to solve,…

Go is fun at first, and then it becomes soul sucking. It's all boiler plate. Many large scale projects have a lack of adequate unit testing, so large code bases are particularly painful to maintain. I attribute this lack of tests due to how the code needs to be structured, you have to needlessly add 'interfaces' throughout your code to accomplish things. Go has it's strengths, but IMO fun isn't one of them. It turns…

I'm in the same position as OP and was wondering the same thing; finding a job using Go. Is the bloat that you see the most related to error checking? If not what else is it?

Re: How I went about learning Rust

#197
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 think rust is the new haskell. After spending 7 months learning it, I can say I really enjoy the language, but there's no job in it and in my opinion, they take academic decisions that make the language way more complex than it should. Also, the community is toxic. For example, generics in Go were criticized by some, praised by others. You have the feeling that you can freely share your opinion in the go community…

> Also, the community is toxic.

I've found the complete opposite, Rust communities are the least hostile programming environments I've come across.

There's also a huge amount of irony about saying a community is toxic on this site

Re: How I went about learning Rust

#198
post #43

I tried to pick up Rust a few years ago, but there were too many sharp edges. I thought it was a nice language, but was too early for actual use. I played with some libraries (Apache Arrow, etc) and it was nice. About 2 months ago I wanted to use Arrow within Elixir, which required me to start using Rust again (Elixir uses Rustler to safely convert from Rust Elixir without theoretically crashing the beam). I am amaze…

I had a very similar experience; thought it was an interesting language but I got discouraged around the time the small stuff I was working on required lifetimes, or had weird reference errors (or at least, what I thought was weird at the time).

When I tried again recently I started with the Too Many Linked Lists, which I felt did a better job of explaining both lifetimes and how the compiler views , &, and &ref as completely different types, and that helped a ton.

Combine that with spending more time understanding how Rust handles object composition (compared to "traditional" OOP), the massive compiler improvements W/R/T lifetime elision and auto-derefing within the past several years, and realizing just how damn helpful the compiler and documentation is compared to other languages (again, thanks to TMLL for explicitly showing this), and it's been a downright pleasure to use this time around.

Re: How I went about learning Rust

#199
post #194

Earlier quoted context omitted.

I don't feel Rust has any performance advantage to c and c++ per my own tests. yes I can dynamically link to stdlib in Rust but I don't think Rust has a versioned dynamic library released for multiple architectures(still many embedded archs are not fully supported in Rust), that leads to problems in the field at depolyment and upgrade phases. Plus the dynamic library after strip is still close to 6MB, I can have a fu…

6MB is quite large. Makes me question if you were even building in release mode. You may want to see https://github.com/johnthagen/min-sized-rust It's not difficult to get binaries down into the 50KB range. And for embedded applications, less than 10KB is totally possible.

Yes I tried all those 'minimize rust' approaches including the above one.

they worked fine if you're statically link to its stdlib.

but if you have a few complex rust binaries, static link for each of them is not going to help on the overall combined size.

I did use a released library and build everything for release(per those minimize projects), I can easily cut a small program from 3M to 290KB but again, it is either static link, or you need a 6MB dynamic library to go with it.

the key question is, what's the smallest size for Rust shared library? so far my finding is around 6MB(after strip, otherwise it's about 11~12MB)

Re: How I went about learning Rust

#200
post #149

Earlier quoted context omitted.

https://old.lispcast.com/what-are-product-and-sum-types/ That was easy to understand. > You can have 100% type-safe, guaranteed at compile time code without null that can still represent the absence of data. If it's a single score, I'd still want to use null / int. There no invalid states being represented, anything else is still unnecessary complexity. > Nullness infects your data model and always comes out of nowhe…

>If it's a single score, I'd still want to use null / int. In your example, you still have to manually check if there's a value every time, but this is not compiler-enforced. Should you forget, you will get a runtime crash at some point (likely in production at a critical time) with some kind of arithmetic error. This wouldn't be possible with a simple sum type. Also, a sum type with units of Score(Int) and NoScore w…

The compiler would enforce Number-ness every time I try and run a function that takes a number, right?

Wouldn’t I still have to check for NoScore?

> a sum type with units of Score(Int) and NoScore won't allow assignments of any other "null" instances.

I get this part - I wouldn’t be able to assign ‘NewBornBaby’ (my name null) to ‘NoScore’ (my score null)

Post reply on HN