Live data from Hacker News

Chrome OS KVM - A component written in Rust

chromium.googlesource.com

21–30 of 109 posts

Re: Chrome OS KVM - A component written in Rust

#23
post #19
post #17

Earlier quoted context omitted.

Null is not really the most pertinent example in this context - at least you get a segfault. What is more important is that in C or C++ (even C++17), it is trivially easy to produce buffer overruns, use after frees, dangling pointers, invalidated iterators, data races etc. That is the unsafety that we are talking about here. Opt-in nullability via Option is nice to have though.

Yeah, I went with familiarity/simplicity in that example. My point was similar C/C++ don't have a safe subset.

Not a safe subset anyone would want to use at least. You could just not use pointers in your code and you'd have memory safety.

Re: Chrome OS KVM - A component written in Rust

#24

Isn't stuff like that exactly counteracting Rusts raison d'etre? > // This is safe; nothing else will use or hold onto the raw sock fd. > Ok(unsafe { net::UdpSocket::from_raw_fd(sock) }) https://chromium.googlesource.com/chromiumos/platform/crosvm...

The default is safe ownership semantics. Using unsafe blocks on occasion when it makes sense is an important feature.

The important bit to me is that the default pointer type and the standard library don't start you out on the wrong foot.

Re: Chrome OS KVM - A component written in Rust

#25

Isn't stuff like that exactly counteracting Rusts raison d'etre? > // This is safe; nothing else will use or hold onto the raw sock fd. > Ok(unsafe { net::UdpSocket::from_raw_fd(sock) }) https://chromium.googlesource.com/chromiumos/platform/crosvm...

No! Unsafe code is perfectly reasonable in rust, it’s just totally clear where it is and can be reviewed to make certain it’s safe.

Re: Chrome OS KVM - A component written in Rust

#27
post #8
post #4

Earlier quoted context omitted.

They should rewrite Go in Rust! That way we can avoid all this Go vs Rust discussions ;) Problem with your idea, is that low level kernel will use a lot of unsafe Rust, which will lose lot of benefits.

> Problem with your idea, is that low level kernel will use a lot of unsafe Rust, which will lose lot of benefits. I've actually worked on a toy kernel in Rust (using the excellent tutorial at https://os.phil-opp.com/ ), and it turns out that, yes, you obviously need to use unsafe code to talk to the actual hardware. But in most cases, you can encapsulate the low-level hardware inside a safe API: https://github.com/e…

So you could do the same in C/C++, if you use unsafe it's unsafe that it's. I can't believe people arguing over unsafe used in a safe way.

Re: Chrome OS KVM - A component written in Rust

#28
post #27
post #8

Earlier quoted context omitted.

> Problem with your idea, is that low level kernel will use a lot of unsafe Rust, which will lose lot of benefits. I've actually worked on a toy kernel in Rust (using the excellent tutorial at https://os.phil-opp.com/ ), and it turns out that, yes, you obviously need to use unsafe code to talk to the actual hardware. But in most cases, you can encapsulate the low-level hardware inside a safe API: https://github.com/e…

So you could do the same in C/C++, if you use unsafe it's unsafe that it's. I can't believe people arguing over unsafe used in a safe way.

There's unsafe hidden under an API that you know where you're using, and unsafe in every single line in your software. Just like there's changing state encapsulated in object methods, and changing state by assigning to global variables.

Theoretically it's just all the same, but in practice having reduced interfaces does wonders to reduce the complexity and being able to reason about what brings problems, and what doesn't.

Re: Chrome OS KVM - A component written in Rust

#29
post #7

Is Rust an officially sanctioned language at Google?

Since Rust is one of the most energy efficient languages and also safe, it sounds like a good fit for Google. I always wondered if they would pick it up.

Can you expand upon what makes Rust more energy efficient than C or C++? What are the language properties that enable Rust code to be more energy optimised?

Re: Chrome OS KVM - A component written in Rust

#30

Earlier quoted context omitted.

Since Rust is one of the most energy efficient languages and also safe, it sounds like a good fit for Google. I always wondered if they would pick it up.

Can you expand upon what makes Rust more energy efficient than C or C++? What are the language properties that enable Rust code to be more energy optimised?

It's not even ranked first. Rust comes a good second to third behind C & C++ on most if not all tests listed on https://sites.google.com/view/energy-efficiency-languages/re...
Post reply on HN