3 ms·
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
by topspin 10y ago
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.
- ethbro 10y agoI think you noted one of the problems Rust is going to have with adoption: its raison d'être is solving technical debt (specifically, security debt). Unfortunately, the reason that's a problem is because most management doesn't even know what it means. And that's not likely to change. So saying "We have a language that might take a bit longer but solves X" is a difficult conversation when the reply is "Wait, what is X?"