Live data from Hacker News

Ask HN: Will Rust ever become a mainstream systems programming language?

news.ycombinator.com

121–130 of 291 posts

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#121

Earlier quoted context omitted.

Just curious, have you ever used any other modern languages that do not use exceptions for error handling? Most people who complain are just used to the exception way, but once you embrace returning errors out of functions, it really does feel like a massive improvement in terms of the paradigm.

How do you return failure for a bus error in Rust?

You can use signal handlers if you need to, but it's not like there's a good way to handle most bus errors in userspace to begin with. Anyway neither standard C nor standard C++ even spec out interrupt handling, and SIGBUS isn't a standard signal :P

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#122

Earlier quoted context omitted.

>> The error handling is too weird. >What would you rather see? Exceptions

Just curious, have you ever used any other modern languages that do not use exceptions for error handling? Most people who complain are just used to the exception way, but once you embrace returning errors out of functions, it really does feel like a massive improvement in terms of the paradigm.

Haskell is the last language i used without exceptions

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#123

Earlier quoted context omitted.

>> The error handling is too weird. >What would you rather see? Exceptions

I would be downright appalled if Rust were to start promoting exceptions. It's an anti-feature.

Being this emotionally invested in a feature, really is unprofessional...

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#124

Earlier quoted context omitted.

Just curious, have you ever used any other modern languages that do not use exceptions for error handling? Most people who complain are just used to the exception way, but once you embrace returning errors out of functions, it really does feel like a massive improvement in terms of the paradigm.

Haskell is the last language i used without exceptions

Haskell has exceptions. So does Rust. People just prefer to use Either / Result (with good reason).

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#125
I want to believe. I love Rust. I feel like Rust is the language I've waited for all my life.

Yesterday there was a story about Rust here on HN: "Programming ARM Cortex-M Microcontrollers with Rust." Among the replies was a complaint; someone couldn't figure out how to write a static buffer and was discouraged. Someone else provided an example of how to do this. Finally, another person noted how unfortunate the solution was. Here is the code, reworked by me just a little:

    use std::io::Write;
    use std::str::from_utf8_unchecked;

    static mut S1: [u8; 17] = [0; 17];

    fn main() {
        unsafe {
            write!(&mut S1[..], "Hi: {}", 5).unwrap();
            println!("string: {}", from_utf8_unchecked(&S1[..5]));
        }
    }
There are three distinct reasons why everything has to be "unsafe." Unless you have a lot of experience with Rust you are NOT going to figure that out until you've banged your head against the compiler for some time doing your level best to minimize the lines of code you've wrapped in unsafe, and then finally surrender.

That is a lot of friction. I know (as in I understand with precision) the reasons for this and they're entirely legitimate. But damn... the pain is just more than the bulk of the world is ever going to tolerate. You can do the same task with zero friction in C/C++ and go fast/be small, or you can do it with a "managed" language with zero friction and handwave at the bloat and cycle eating cache killing GC, or you can don the hair shirt, focus on your breathing to keep the panic at bay and use Rust.

It is inescapable human nature that the "mainstream" will avoid the latter.

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#126

Earlier quoted context omitted.

How do you return failure for a bus error in Rust?

You can use signal handlers if you need to, but it's not like there's a good way to handle most bus errors in userspace to begin with. Anyway neither standard C nor standard C++ even spec out interrupt handling, and SIGBUS isn't a standard signal :P

A signal handler (signal!(sig::ffi::Sig::BUS, test_bus);) will catch the bus error in userspace. You now need to communicate that caught exception to the offending fn. For that, you'll need setjmp() and longjmp(), something else that Rust lacks.

If Rust is going to bill itself as a systems programming language, it needs these. I added them for my app:

  extern {
    #[link_name = "llvm.setjmp"]
    pub fn setjmp(a: *mut i8) -> i32;
    #[link_name = "llvm.longjmp"]
    pub fn longjmp(a: *mut i8, b: i32) -> ();
  }
It took me awhile to figure this out (and it barely works). There's a cleaner way (adding a wrapper) that is even more work.

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#127

Earlier quoted context omitted.

And thereby prevent people from writing code that needs to catch errors but can't use exceptions. Won't work.

I don't understand what that sentence means...

Some people don't want to use exceptions because of runtime overhead costs.

If exceptions are just "an option" that a library can choose when designing its interface, then you'll get a split ecosystem: a bunch of libraries that do use exceptions for error-handling, and then a separate bunch of libraries that do the same thing, but don't use exceptions for error handling, which is wasted, redundant effort.

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#128

Earlier quoted context omitted.

You can use signal handlers if you need to, but it's not like there's a good way to handle most bus errors in userspace to begin with. Anyway neither standard C nor standard C++ even spec out interrupt handling, and SIGBUS isn't a standard signal :P

A signal handler ( signal!(sig::ffi::Sig::BUS, test_bus); ) will catch the bus error in userspace. You now need to communicate that caught exception to the offending fn. For that, you'll need setjmp() and longjmp() , something else that Rust lacks. If Rust is going to bill itself as a systems programming language , it needs these. I added them for my app: extern { #[link_name = "llvm.setjmp"] pub fn setjmp(a: *mut i8…

> A signal handler will catch the bus error in userspace.

Sure, but what I meant is that most of the time userspace programs have nothing interesting they can do with the bus error (and, as I noted, standard C does not actually provide this option anyway). Regardless there are existing signal handling libraries that aren't that hard to use in Rust (you now describe one in your post), so I'm not sure why you're pointing to that as "something... that Rust lacks."

There's no way I'm aware of that setjmp / longjmp could possibly be integrated with safe Rust, but I agree that they should be available to unsafe code (in a way that doesn't require invoking llvm intrinsics).

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#129
post #6
post #2

I would say so far, yes. I would say it's pretty "mainstream" already with many companies using it in production, including Mozilla. As big as C++/C? Too early to tell for that.

Also anyone big besides mozilla, who created it?

Google and Microsoft are using it.

Re: Ask HN: Will Rust ever become a mainstream systems programming language?

#130

Earlier quoted context omitted.

Haskell is the last language i used without exceptions

Haskell has exceptions. So does Rust. People just prefer to use Either / Result (with good reason).

Exception in Haskell ?
Post reply on HN