News for hackers. Stuff that matters.
Re:My negative views on Rust by mhaberl on Thursday December 23, 2021 @02:40AM (#29659573)
> I predict that garbage collectors will become popular in Rust eventually.

Not having a GC and not freeing memory by hand is one of the features that makes Rust special. What would be the point of this?

> I feel like Rust is self-defined as a “systems” language, but it’s being used to write web apps and command-line tools and all sorts of things. This is a little disappointing

Why would using the language for non-system programming be disappointing?

I have a feeeling that it has become popular lately to criticize Rust for whatever reason, I guess that's what happens when more people use the language

Re:My negative views on Rust by hawk_ on Thursday December 23, 2021 @02:55AM (#29659660)
“There are only two kinds of programming languages: those people always complain about, and those nobody uses.”
Re:My negative views on Rust by pkdpic on Thursday December 23, 2021 @02:58AM (#29659674)
Thats a keeper :) Does this quote have a history?
Re:My negative views on Rust by imron on Thursday December 23, 2021 @03:02AM (#29659703)
It’s from Bjarne Stroustrup regarding people hating on c++
Re:My negative views on Rust by erk__ on Thursday December 23, 2021 @02:47AM (#29659606)
A interesting paper I saw about adding a GC to Rust is this[0] where they made some programming challenges and showed that the ones who used a GC finished the task faster.

[0]: https://arxiv.org/abs/2110.01098

Re:My negative views on Rust by mhaberl on Thursday December 23, 2021 @03:00AM (#29659690)
> a randomized controlled trial with volunteers from a 633-person class, collecting data from 428 students in total

If I understand this experiment, college students i.e. in average completely inexperienced programmers, where tested. IMHO, this only points to the fact that Rust has a steep learning curve. I can imagine that using javascript instead of Rust would have them finish their tasks even faster, but doesn't tell us that GC in Rust is a great idea.

Re:My negative views on Rust by nefitty on Thursday December 23, 2021 @03:13AM (#29659754)
What aspect is steep?

From the code I've seen, Rust is intuitive when coming from the classical languages like Java, C or JS. It's not lisp or Haskell.

To clarify, I don't intend to come off dismissive. I'm genuinely curious what the scary parts are so I can better plan my own studies.

Re:My negative views on Rust by woile on Thursday December 23, 2021 @04:05AM (#29660050)
The borrow checker and lifetimes have been my pain points. Also understanding Some and Result, which after practicing I understood them, and now they are ok. They were foreign concepts to me.

I still struggle with lifetimes, but I do understand them better.

Re:My negative views on Rust by wiz21c on Thursday December 23, 2021 @03:27AM (#29659839)
I personnaly find the ownership thing really hard to get. That's the thing that protexts you from screwing memory in parallel code but the thing is you have to use it even in non parallel code. The other thing is that it's a set of rule which mixes with the type system, so at the beginning, I had hard times understanding if I had issues with my types or with the ownership (eventhough, I know, ownership issues are reported as such by the compiler). So in the end, you have to think about memory safety much more deeply. I get that my code really feels right once it's written with ownership principles but somehow, it makes Rust hard to start with. Now, this ownership part is something really new to me (I have ASM,C++,Python,Java real life experience), it makes me think better about about my programs. So it's a tough but fruitful experience.
Re:My negative views on Rust by Measter on Thursday December 23, 2021 @07:53AM (#29661359)
The most common issues are with ownership, lifetimes, and the borrow checker.

If the person is an experienced C or C++ programmer they'll probably have an easier time as you need some understanding of ownership and lifetimes to correctly use pointer-likes in those languages. The most likely issue here is that their mental model of ownership and lifetimes does not exactly match the borrow checker's.

If they're coming from a language such as C# or Python, where you don't need to deal with these to anywhere near the same extent, suddenly being forced to reason about it just to pass the compiler can be bit of a hurdle.

Re:My negative views on Rust by meheleventyone on Thursday December 23, 2021 @03:03AM (#29659710)
Would be interesting to see this repeated with people that had significant Rust experience rather than a class of students mostly coming to the language for the first time.
Re:My negative views on Rust by linspace on Thursday December 23, 2021 @03:01AM (#29659695)
The interesting part is putting a number to this: 4 vs 12 hours. Just the direction of the inequality is of course unsurprising.

I have looked superficially at Rust since I have no use case for me right now and it's truly complex but people downplay the importance of not having GC. There are plenty of languages with GC, for a reason. People use C, C++ or similar for a reason too, not out of masochism.

Re:My negative views on Rust by DrMeepster on Monday January 03, 2022 @04:49PM (#29787447)
this study is extremely flawed. It is impossible to tell if these results are from the garbage collection or how bronze violates rust aliasing
Re:My negative views on Rust by Xylakant on Thursday December 23, 2021 @02:59AM (#29659681)
The counterpoint is that using a GC makes the workload unpredictable. The GC may kick in at any time. Rust has a predictable performance profile and that’s important in some applications.
Re:My negative views on Rust by alblue on Thursday December 23, 2021 @05:15AM (#29660420)
Note that GC makes explicit the costs associated with memory allocation and freeing; languages that use manual memory management (or semi automated memory management as in Swift/Rust) simply un-amortise the cost and distribute it all over the program.

While Rust may have less issues than other languages in this regard, it doesn’t change the fact that destruction of a “thing” can result in a transitive set of “other things” being destroyed as well, and depending on the state of the program, this set could have a pretty high bound.

Even in a “predictable” language like Rust, a data entry containing a map like structure is going to have a different destruction time if the map is empty vs if it is full.

The other aspect of “predictable” delays in a program completely ignores the runtime issues that can happen at the OS layer, such as swapping/page cache invalidations/migrations between cores of numa regions etc. so it is rarely the case that any program in any language is going to have predictable behaviour. Even trivial things, like the number/size of environment variables user at program startup can have a performance delta.

Anyway, the point is that when programmers talk about “predictable” behaviour in a program, what they generally mean is “invisible performance problems” and so it gets swept under the carpet.

That’s not to say that GC doesn’t introduce variance into measurements, but it is not the only thing that causes variance and many of the good GCs are capable of using multiple cores and can avoid interrupting the program runtime without significant overhead, although obviously tracing collectors will increase pressure on a memory system in a way that explicit/automatic memory management does not.

Re:My negative views on Rust by Xylakant on Thursday December 23, 2021 @07:56AM (#29661380)
> Note that GC makes explicit the costs associated with memory allocation and freeing; languages that use manual memory management (or semi automated memory management as in Swift/Rust) simply un-amortise the cost and distribute it all over the program

This is generally an interesting feature of garbage collected languages, and it's often more efficient than manual memory management - but it does come with downsides.

> Even in a “predictable” language like Rust, a data entry containing a map like structure is going to have a different destruction time if the map is empty vs if it is full.

"Predictable" does not mean "always the same". It means that given a map with the same size and fill level, destroying it will take the same time. What's more important is that the point in the program where the destruction happens can be controlled - and, if necessary, moved out of the critical path of something that requires response within a certain bound. This may introduces an overall inefficiency in the program, but if you have software that needs to fulfill certain time bounds, that's the tradeoff you choose. Doing so in a garbage collected language is much harder.

And rust targets environments where (near)-realtime behavior and predictable performance is important, or where garbage collection is not truly possible since allocation isn't even possible (think embedded systems).

> Anyway, the point is that when programmers talk about “predictable” behaviour in a program, what they generally mean is “invisible performance problems” and so it gets swept under the carpet.

I don't see how this is a counterpoint to what I said - programmers blaming other things for performance problem has been a thing like forever.

Re:My negative views on Rust by vegai_ on Thursday December 23, 2021 @02:49AM (#29659618)
>Not having a GC and not freeing memory by hand is one of the features that makes Rust special. What would be the point of this?

To put it bluntly: to make writing Rust fast and fun. If you think it's fast and fun right now, you're either very good at it or somehow delusional.

Re:My negative views on Rust by DarkCrusader2 on Thursday December 23, 2021 @03:08AM (#29659734)
Agree with this. I wrote some non-trivial amount of code in Rust just to give is a proper try. After countless hours spent in understanding borrow checker, life times and waiting for compilation to finish, I still have to constantly fight borrow checker. When working with Rust, I am not "making thing X" but instead "writing Rust which happens to be X". The code is littered with either `unwrap` of `?` which is just exception management done manually with hardly any benefit.

On systems programming front, last time I checked there were two options to make system calls (apart from writing inline assembly), the `libc` or the `nix` crate. `libc` is just a wrapper so exposes `unsafe` C like API which doesn't make for idiomatic Rust code. `nix` was incomplete on lots of front, not sure if things have changed now since it has been a while I tried Rust. So much for a systems programming language.

Re:My negative views on Rust by timeon on Thursday December 23, 2021 @04:18AM (#29660122)
What is wrong with `?`? I consider Option<T> as a plus. Unwrap is hack but '?' is good error handling. Better then littered code with unnecessary ifs (which you need to use even in GC languages).
Re:My negative views on Rust by alice-i-cecile on Thursday December 23, 2021 @02:53AM (#29659640)
Honestly, if you're working within a well-architected framework, writing Rust is genuinely a joy (except perhaps async). The painful challenges of "how do I design something that plays nice with the borrow checker" can be solved once, and then you just stick to convention and enjoy the expressiveness of the trait system.
Re:My negative views on Rust by lewantmontreal on Thursday December 23, 2021 @03:07AM (#29659731)
Is GC for Rust possible in the future? I’d love that if it means simpler compiler error messages for e.g. closures.
Re:My negative views on Rust by duped on Thursday December 23, 2021 @02:59AM (#29659682)
What would garbage collection buy you in a language like Rust?
Re:My negative views on Rust by coldtea on Thursday December 23, 2021 @03:14AM (#29659758)
>Not having a GC and not freeing memory by hand is one of the features that makes Rust special. What would be the point of this?

That some people don't care what makes a language "special", but e.g. like its syntax, ergonomics, ecosystem, and so on.