News for hackers. Stuff that matters.
Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by dgb23 on Thursday June 23, 2022 @11:14AM (#31850266)
In of itself it seems like a very nice feature.

However it represents something that I don't like, which is trading language surface complexity and readability for programmer convenience. It is not something that gives you more power, just something that makes code a bit easier to write. Also there was seemingly not that much push-back against the feature which makes me a bit uneasy. Not sure why that is to be honest.

I don't want to start a discussion about the question mark operator specifically. That's not important to me. What I like to gauge is the general culture around the language itself and the community around it. Half devil's advocate, half uncertainty driven.

Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by ntoskrnl on Thursday June 23, 2022 @11:29AM (#31850497)
> trading language surface complexity and readability for programmer convenience

I would say the question mark improves readability, compared to having to check/return error codes by hand after every function call.

To your more general point, the language is pretty much established and syntax features are added very rarely. I think one more feature, let guards, is coming down the pipe soon, but other than that I wouldn't be surprised if the surface syntax never changes again.

Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by mmarq on Thursday June 23, 2022 @11:38AM (#31850641)
> I would say the question mark improves readability, compared to having to check/return error codes by hand after every function call.

Which is one of my complaints about Go.

  result, err = doSomething();
  if err != nil {
    ...
  }

  result, err = doSomething2();
  if err != nil {
    ...
  }
Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by Fiahil on Thursday June 23, 2022 @11:19AM (#31850352)
> However it represents something that I don't like, which is trading language surface complexity and readability for programmer convenience.

In this case it's a welcomed convenience. Have you used `thiserror` and `anyhow` crates ? They may alter your judgement on that point.

Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by bigbillheck on Thursday June 23, 2022 @11:29AM (#31850495)
> It is not something that gives you more power, just something that makes code a bit easier to write.

Who needs a for loop when you have while?

Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by jeffparsons on Thursday June 23, 2022 @11:55AM (#31850905)
`while`? That's just sugar on top of `loop` that automatically inserts an `if` and a `break` for you. Don't be lazy, spell it out.

(Although, in Rust, `if` is also actually just sugar over `match`, so, uh...)

Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by dgb23 on Thursday June 23, 2022 @11:51AM (#31850854)
For and while have different semantics. For is not just sugar for a while loop, it means something more specific and restricted than a general while.
Re:Linus Torvalds: Rust for the Kernel Could Possibly Be Mer... by jeffparsons on Thursday June 23, 2022 @12:03PM (#31851022)
For _is_ "just sugar for a while loop". In fact, here's the Rust documentation detailing what a `for` loop "de-sugars" down to: http://doc.rust-lang.org/nightly/std/iter/#for-loops-and-int...

> it means something more specific and restricted than a general while

Sure, but that's still sugar. That's what sugar is.

Want to know something really crazy? In Rust, the `if` keyword is also just syntactic sugar over `match`. Still finding bits of grey matter on the walls from when I learned that one.