Live data from Hacker News

How I went about learning Rust

eli.thegreenplace.net

171–180 of 303 posts

Re: How I went about learning Rust

#171
as an embedded c/c++ developer I tried Rust briefly a few times over the years, don't feel it's the right fit, due to the way it's static build by default the binary size is just too large, plus the library pool is still much small, and there is no equivalent to c++'s STL for speedy coding when I need it.

yes I can trick for size etc, but overall it just did not fit well so far, for the embedded space that is, but, 'system-programming language' has many use cases in embedded field.

Re: How I went about learning Rust

#172
post #163

Earlier quoted context omitted.

I've encountered this pretty-much every time that I've learned a new language or framework. I start out trying to use it the way I've used things before, and then I slowly learn how the people who wrote it expect me to work, and then things get a lot easier.

That too and I don't think I'm even done with that, myself :) What I meant is the step away from the notion that things are objects, stuff gets done with methods, methods are available via mixins/ inheritance/ magic, etc. I've seen the notion of using values and pure functions as data oriented programming recently but never understood what that moniker adds.

I think that going with pure functions/functional programming simplifies things, because it makes it much easier to test that things work as you'd expect when you don't have side-effects/state to think about.

Re: How I went about learning Rust

#173
post #71

Earlier quoted context omitted.

I mean it depends . Many of aspects of Rust that are perceived as sharp edges are in fact the programmer bringing in their preferences and paradigms from other languages and trying to program that way in Rust. I was one of those and tried to do OOP in Rust. It was a pain. At some point I gave up and was like: "Okay Rust, I do it your way, I just want this to work". And it worked flawlessly and easy. I literally had t…

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.

> fragile base class problem

I do wonder whether this is as much of a problem as people think. Most of the time it only becomes a problem when people start doing stupid things to override the parent instead of refactoring a new class out from under it.

Re: How I went about learning Rust

#174
post #158
post #147

Earlier quoted context omitted.

Yes it does, OOP is a spectrum not "like Java does it".

I'd consider something OOP if it has the same expressive power i.e. things expressible in OOP languages are easily expressible in another OOP language as well. And for Rust that's not the case. Otherwise you end up with Haskell is an OOP language.

To me, OOP always meant passing messages to objects, but it seems everyone has their own definition depending on experience.

Re: How I went about learning Rust

#175
I've spent some time casually learning Rust in the past few weeks, and I'd really like to start incorporating it into my serious C++ projects. Rust itself is nice, but having a reliable package manager & build system in the form of cargo is absolutely the killer feature for me.

If I could use Cargo/cxx_build as my C++ build system (which I think may be possible, but I haven't seen a good example), I would fully embrace rust & start incorporating it into my professional work today.

Re: How I went about learning Rust

#176

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 it was the web-of-pointers strategy I had to unlearn. A child object keeping a pointer to its parent is misery in Rust. It forces you to either make the child completely independent or really prove the parent will be around until the child disappears. 90% of the time this is dumb overhead, but 10% of the time it found a bug in some edge case, so I learned to appreciate it as a tough teacher, and my designs got…

>"90% of the time this is dumb overhead, but 10% of the time it found a bug in some edge case, so I learned to appreciate it as a tough teacher, and my designs got better for it."

Sounds kind of like Stockholm syndrome

Re: How I went about learning Rust

#178
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…

Amazing! Thanks for explaining that.

I think that's a great solution because the biggest thing that makes me afraid of Rust webdev is compile times. Your solution seems perfect as you can get quick compile times during development.

Re: How I went about learning Rust

#179
post #71

Earlier quoted context omitted.

I mean it depends . Many of aspects of Rust that are perceived as sharp edges are in fact the programmer bringing in their preferences and paradigms from other languages and trying to program that way in Rust. I was one of those and tried to do OOP in Rust. It was a pain. At some point I gave up and was like: "Okay Rust, I do it your way, I just want this to work". And it worked flawlessly and easy. I literally had t…

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 into soul-suck quickly.

Re: How I went about learning Rust

#180
post #146

Earlier quoted context omitted.

It is no different than using interfaces, protocols, pure virtual base classes....

It's similar, but there are some differences. Notably, my package can implement my trait for your type, while my package (usually? always?) cannot make your type inherit from my virtual base class.

Depends on the flexibitly of the language, there isn't a golden way to do that across all variations of OOP.
Post reply on HN