News for hackers. Stuff that matters.
Re:I can't keep up with idiomatic Rust by pornel on Thursday April 09, 2020 @05:44AM (#22821059)
Rust seems to change constantly, because it's changing so slowly. The 1.0 release has held back a lot of stuff to avoid stabilizing wrong things, and it's now slowly backfilling the missing features bit by bit.

Instead of starting with a fat standard library, it started with minimal one and now each release adds 2-3 functions that could have been there in 2015. But none of it is idiom-changing revolution. These are mostly convenience functions, and you don't have to use them all just because they're there.

Every addition to the language is bikeshedded to death, goes through betas, revisions, refinements, before being stabilized years later. The first experimental release of async was 4 years ago and it has landed last November. So you may hear about new features a lot and they churn in nightlies, but actual big changes reach stable rarely.

Apart from async/await, since 2015 Rust made only 2 changes to how idiomatic code looks like (? for errors, and 2018 modules), and both of them can be applied to code automatically. I maintain over 60 Rust crates, some of them as old as Rust itself. All work fine as they are, and running `cargo fix` once was enough to keep them looking idiomatic.

Re:I can't keep up with idiomatic Rust by twic on Thursday April 09, 2020 @07:35AM (#22821546)
> it's now slowly backfilling the missing features bit by bit

This isn't slow.

Java went three years, from December 1998 to February 2002, without any language changes. And to be honest, even that wasn't that slow!

> Every addition to the language is bikeshedded to death

Not to death, because many of them don't die!

What i find annoying about Rust's changes is that some of them are so trivial - they change the language for such small improvements. async/await is not in that category, for sure. But Ok-wrapping actually is. The need to Ok-wrap results is a minor annoyance at most. Ditto a bunch of the problems solved by match ergonomics changes.

I think the root of the problem is that the changes are driven by a small core of Rust programmers - many working on Rust itself or some of its flagship projects - who are actively involved in the discussions around Rust. They tend to view change as natural, and the cost of change as low. I believe there is a larger group of Rust programmers who are not actively involved in these discussions, and are maybe not spending 100% of their time on Rust, for who the cost is higher. But we don't hear as much from them.

Re:I can't keep up with idiomatic Rust by hinkley on Thursday April 09, 2020 @10:00AM (#22822601)
> Java went three years, from December 1998 to February 2002

Oh hell no.

Sun was widely criticized for that boneheaded move, and for the whiplash everyone experienced in Java 5 when they changed that policy too fast.

The mass of changes in 5 left a lot of tools and thus people stuck in 1.4 for years. I started on a project a bit before 6 came out. It was processing data and I couldn’t use the collections API, because it had to run on an embedded system and Aicas was taking their sweet time catching up with all those changes. Four years later I was still using arrays for everything.

Re:I can't keep up with idiomatic Rust by lmilcin on Thursday April 09, 2020 @11:45AM (#22823634)
One problem with not changing at all for a long time is that everybody forgets what it means to change. Teams stop planning for it, developers get too used for things being they way they got to know over the years.

Then you get huge pills like Java 8 which took forever to be adopted in large corporations.

I have witnessed most of Java history play out, starting with Java 1.3 in 2000.

Looking back, I wish we had regular change cadence where new features are being slowly added at a regular pace so the versions don't feel like a completely new language and developers have time to digest the new possibilities.

It is interesting when you spend multiple years on various projects, each being in a state of migrating from 1.6 to 8. Or coming to interviews and the first question being asked is "Which version of Java are you working on right now?".

Re:I can't keep up with idiomatic Rust by touisteur on Friday April 10, 2020 @07:30PM (#22838443)
Similar problem with Ada. 2012 standard came and for a long time only AdaCore supported it... Now going for 202x I'm thinking only advocating small changes that don't reduce ease of reading code...
Re:I can't keep up with idiomatic Rust by ChrisSD on Thursday April 09, 2020 @08:06AM (#22821732)
`match` ergonomics don't affect already working code.

Ok-wrapping isn't a change that's been made. At best it's a hypothetical change that one person wanted to have a calm, rational discussion about with the community. Instead we get this.

Re:I can't keep up with idiomatic Rust by sgift on Thursday April 09, 2020 @08:04AM (#22821716)
> What i find annoying about Rust's changes is that some of them are so trivial - they change the language for such small improvements. async/await is not in that category, for sure. But Ok-wrapping actually is. The need to Ok-wrap results is a minor annoyance at most. Ditto a bunch of the problems solved by match ergonomics changes.

So what? Then don't use them. The whole point of full backward compatibility is that you don't have to use new features. This perceived need to always use the newest feature is only in the head of some developers.

Neither in the blog post nor here do I see any reason to not make the experience better for people who want it. Even if it's just a "minor" (very subjective, I love the match ergonomics enhancements) annoyance that's fixed by it.

Re:I can't keep up with idiomatic Rust by karatestomp on Thursday April 09, 2020 @09:01AM (#22822091)
You still have to understand all the new stuff to read other people’s code. And the old way, so you can read older code. And if there are other ways to do something that are or have recently been in common use, those too. You end up memorizing a bunch of crap for one actual operation.
Re:I can't keep up with idiomatic Rust by jrochkind1 on Thursday April 09, 2020 @09:05AM (#22822128)
Yep.

I think ruby (which in general I still love) has become a major offender of this. "If you don't like it don't use it" is not a good answer for exactly the reasons you explain.

Re:I can't keep up with idiomatic Rust by sgift on Thursday April 09, 2020 @09:20AM (#22822244)
I sense a goalpost moving here. The point of the blog post to which I answered to was: I have to redo all my programs to follow the "idiomatic" way.

Now we are at "other programmers could use new features, so I still have to learn them". And yes, that is true. And that will always be true as long as a language has new releases. Even if all those releases were library changes and not syntax changes/additions. The only way to stop this would be to stop all language development.

Re:I can't keep up with idiomatic Rust by setr on Thursday April 09, 2020 @01:12PM (#22824780)
Even worse would be if someone pulled in a library... That requires much more cognitive load and doc-reading than something like try! -> ?

Or the worst of all possible worlds -- pulling in a macro-based framework

Re:I can't keep up with idiomatic Rust by silon42 on Thursday April 09, 2020 @10:46AM (#22823023)
But you don't have to change your code unless it's an improvement to you. Somebody else may do it if they care, and you may accept OR reject the PR with no bad feelings.
Re:I can't keep up with idiomatic Rust by MaulingMonkey on Thursday April 09, 2020 @08:15AM (#22821799)
Agreed. I know plenty of codebases still written in C++03 style and work fine. I'm still using 2015 edition Rust crates and they work fine. I won't say there's no cost to evolving idioms, but evolving idioms on this front means it's more of an affront to asthetics than it is to productivity or anything else actually important to business goals, IMO.

The one exception perhaps being async/await, in that a bunch of crates are making breaking API changes to accomidate it and bumping their major versions - because it's bloody useful and a bit more than your typical syntactic sugar - which means changing your code if you want to keep getting patches.

Re:I can't keep up with idiomatic Rust by umanwizard on Thursday April 09, 2020 @08:33AM (#22821905)
I can’t force other people not to use changes, which means I will always need the latest version of rustc installed if I want to be able to build a relatively complete selection of the corpus of Rust code, which in turn makes it very difficult if not impossible for rust software to be distributed in typical OS package managers.

I.e., imagine how Debian or Ubuntu could package things if the definition of C++ changed every six weeks, given that the compiler version should change as little as possible during a major OS version cycle? This is a major blocker holding Rust back from mainstream adoption, IMO.

Re:I can't keep up with idiomatic Rust by whatshisface on Thursday April 09, 2020 @09:21AM (#22822259)
Can't package managers distribute binaries? Besides, maybe the fact that a package can fall three years behind the stable release is a problem with package management, not the stable release.
Re:I can't keep up with idiomatic Rust by steveklabnik on Thursday April 09, 2020 @10:17AM (#22822745)
They can, but Rust doesn't have a stable ABI, so that doesn't really work this way.
Re:I can't keep up with idiomatic Rust by adrianN on Thursday April 09, 2020 @08:53AM (#22822026)
You still need to know about the feature and understand how it works or eventually you'll only understand your own code as everybody else is using stuff you haven't learned.
Re:I can't keep up with idiomatic Rust by travellingprog on Thursday April 09, 2020 @11:24AM (#22823424)
From my experience of trying to learn Rust (got almost halfway through the manual and then put it on hold), I would add that having all these ways of doing the same thing is also confusing from a beginner's perspective. As a noob, I have no idea what the timeline is of when feature A was introduced that does the same thing as feature B. Also, I kept having to dig around to see if feature A added any type of improvements (other than syntactic sugar) over feature B.
Re:I can't keep up with idiomatic Rust by pornel on Thursday April 09, 2020 @04:00PM (#22826558)
• try!() has been replaced by ?. You don't even need to know — the compiler will tell you.

• futures 0.1 has been replaced with std::futures.

This is it. This is the exhaustive list of A->B feature changes in the last 42 releases of Rust. Now you know them all.

Rust is aggressive with keeping everyone using the current stable release. In C++ you may need to keep track of feature history to know if something is too new or too old for your compiler/project. There's no such thing in Rust. If you know a feature exists, you can use it.

Re:I can't keep up with idiomatic Rust by jfkebwjsbx on Thursday April 09, 2020 @08:13AM (#22821779)
It is not fully backwards compatible between editions, though.
Re:I can't keep up with idiomatic Rust by sgift on Thursday April 09, 2020 @08:20AM (#22821833)
Editions are opt in. You don't opt in, nothing changes for your code.
Re:I can't keep up with idiomatic Rust by rubber_duck on Thursday April 09, 2020 @02:15PM (#22825536)
> I believe there is a larger group of Rust programmers

Is there ? This is a genuine question - I've tried rust back in 2013 and have been following it from the outside not using it for anything serious since I haven't had a use case. My impression is that it's still a niche language with and their user base seems to be very involved and engaged. It don't have the impression that there are a lot of companies that are "just doing their job with Rust and not making a lot of noise about it" - if a company is using Rust for something it's probably writing an engineering blogpost about it and the guy who spearheaded it is probably active within the community. I'm just basing this on the amount of Rust posts vs the amount of Rust use/job postings in those quiet, doing their thing companies.

Re:I can't keep up with idiomatic Rust by steveklabnik on Thursday April 09, 2020 @07:43PM (#22828427)
Re:I can't keep up with idiomatic Rust by rubber_duck on Friday April 10, 2020 @04:40AM (#22831136)
But that's my point - I knew about every one of those except discord just by following Rust marginally. Also Microsoft and Google etc. reported using it for various bits and peaces.

My impression is that if a company does something in Rust there's going to be blogposts about it and the engineers involved are active community members.

OP argued that there is a silent majority working along on Rust as is and getting caught unexpectedly with the changes - I'm just not seeing that.

Re:I can't keep up with idiomatic Rust by twic on Friday April 10, 2020 @09:06AM (#22832608)
It's a legitimate question. I can't be sure there is such a silent majority. I do know there are a dozen people using Rust at my company, none well-known, and we haven't blogged about it or publicised it.

> My impression is that if a company does something in Rust there's going to be blogposts about it and the engineers involved are active community members.

You must recognise that this is pure availability bias, right?

Re:I can't keep up with idiomatic Rust by rubber_duck on Friday April 10, 2020 @09:18AM (#22832691)
>You must recognise that this is pure availability bias, right?

I'm comparing to stuff I hear from local dev community and job postings - but again this is just my impression - I'd like to see some actual stats on this .

Re:I can't keep up with idiomatic Rust by jkoudys on Saturday April 11, 2020 @06:20PM (#22844659)
I _really_ felt that in JavaScript, especially es2015. So many updates came out at once, that people didn't realize many of the benefits they received from new features were now much less important because of other features that were included around the same time.

There was a huge rush to use classes, which was sugar around the prototype system, but happened when we also got spread operators, Object.assign, and property name shorthand. We could already easily express the concept of a class far more easily than we were doing before, but because it all came out at the same time it didn't really click for the community at large and a lot of what became idiomatic didn't really feel important enough for a language update.

Ditto with generators and async functions, which while merely a very specific application of a generator is far better known. Again, not sure we needed all this extra syntax so you can say `async function foo() { await bar()`, when `co(function* foo() { yield bar()` was already available (if co were simply added to the Promise object). We're also now tying the language to a very specific implementation, when the co approach is explicit about saying what's responsible for taking control from the yielded function (a Promise).

Re:I can't keep up with idiomatic Rust by ddevault on Thursday April 09, 2020 @08:55AM (#22822044)
C adds 2-3 features every 10-20 years. That's slow. Rust is not slow.
Re:I can't keep up with idiomatic Rust by mseepgood on Thursday April 09, 2020 @09:24AM (#22822273)
> C adds 2-3 features every 10-20 years.

This should be the norm for serious programming languages. Anything else is a hyperactive children's toy.

Re:I can't keep up with idiomatic Rust by whatshisface on Thursday April 09, 2020 @09:30AM (#22822325)
I don't get this perspective, are there only three good features invented every decade? Shouldn't it be the quality of the features that counts, not their rate of introduction?

Also, I think C might be the only language to get 1.5 features/decade. Fortran has seen a lot of recent editions, and so has Java. Even x86 gets new instructions every arch bump. Are there any other languages that change as slowly as C? If not it may be too elitist to claim that there is only one language in the world that's not a child's toy.

Re:I can't keep up with idiomatic Rust by stevelosh on Thursday April 09, 2020 @06:09PM (#22827725)
> Are there any other languages that change as slowly as C?

ANSI Common Lisp has had the same spec since 1994.

(This is not a problem, because Common Lisp gives you enough high and low level power to do (almost) whatever you want in user space, instead of relying on the language designers to add a particular feature.)

Re:I can't keep up with idiomatic Rust by mseepgood on Thursday April 09, 2020 @10:16AM (#22822727)
> I don't get this perspective, are there only three good features invented every decade?

To be honest, programming language design has been a solved problem since the 1950s when LISP came out.

Re:I can't keep up with idiomatic Rust by pcwalton on Thursday April 09, 2020 @04:45PM (#22826996)
1950s Lisp didn't even have lexical scope, for goodness sake. (If you don't know what dynamic scoping is, best to leave it that way—it's horrendous.)
Re:I can't keep up with idiomatic Rust by unlinked_dll on Thursday April 09, 2020 @11:52AM (#22823728)
If this were true we wouldn't have done so much research into programming languages over the last 50 years.

PL design is not a problem to solve, it's the study of the way to express problems and their solutions. As long as their are new problems and ways to solve them, we'll find new ways to improve PL designs.

Re:I can't keep up with idiomatic Rust by api on Thursday April 09, 2020 @10:29AM (#22822850)
Why does nobody use it? I've never heard a satisfactory answer from LISPers. "People are dumb" is not a satisfactory answer.
Re:I can't keep up with idiomatic Rust by jdmichal on Thursday April 09, 2020 @11:36AM (#22823563)
The best answer I've seen is the Lisp Curse. It's basically the idea that Lisp is so flexible that every project becomes its own DSL / idiomatic version of Lisp. Imagine what's being discussed here, except that every programmer actually has the power to just make the change rather than have to submit it to the central Rust team for consideration and eventual implementation.

http://winestockwebdesign.com/Essays/Lisp_Curse.html

Re:I can't keep up with idiomatic Rust by kazinator on Thursday April 09, 2020 @11:41AM (#22823603)
I had the same thought. Lisp puts an end to the bikeshedding; everyone can build their own shed and paint it whatever they want, without having to break upstream.

It also applies to the recent "Why I'm Leaving Elm" article. https://news.ycombinator.com/item?id=22821447

Part of the struggle depicted in the article is between user defined language extensions "competing" with the upstream compiler.

That's exactly a social problem that becomes a technical problem in Lisp.

Re:I can't keep up with idiomatic Rust by pcwalton on Thursday April 09, 2020 @04:50PM (#22827036)
There are a multitude of reasons, but I think the biggest ones are (1) the unfamiliar syntax; (2) the fact that Lisp runtimes tend to want all code that interacts with it to also be Lisp instead of focusing on FFI and interoperability; (3) Unix and C were free and so went viral.
Re:I can't keep up with idiomatic Rust by astrange on Thursday April 09, 2020 @08:55PM (#22828845)
Because of the rule of least power, it's actually bad for a language to be able to do anything.
Re:I can't keep up with idiomatic Rust by marcosdumay on Thursday April 09, 2020 @09:40AM (#22822420)
It is the norm for mature programming languages. You can't expect anything to improve if you apply it everywhere.
Re:I can't keep up with idiomatic Rust by k__ on Thursday April 09, 2020 @07:11AM (#22821419)
I can't comprehend what you're going at.

Are they to slow and doing too much design by comitee or are they at an okay speed of innovation?