Are you kidding? Common dude, the code is pretty clean.
Sure I can read it but it looks cluttered with all the objects needed to do a simple thing. A bit like java with all the dot extensions to call a simple thing.
Like "cortex_m::asm::delay(2000000);" when in C with your own function "delay(2000000);" is enough. But here you need to select the top class, sub class and then the function you want to use.
It's crazy! Will this code work on a board with an AVR, PIC, MIPS, RISC-V, ESP32 with XTensa?
I think no, it's got to be rewritten.
The Arduino code works on EVERYTHING, without any modification.
How many lines of code have to be changed if you want to toggle something other than pin 13? I see four. It should be one. On Arduino you don't even have to know which pin the built in LED is actually on -- there'a a macro for that.
And "safe" is just a word. Nothing is really safe. Mistakes are easily made even for experienced programmers and the "safe" flies out of the window.
Completely agree.
In the 80s I was a big fan of bondage and discipline languages such as Ada, Pascal, and here we have Rust. I'm not now.
Sure, they make it harder to make certain kinds of coding errors. But they totally fail to address the other 90%, 98%, whatever it is. Not to mention specification errors, architectural design errors, algorithm errors.
Or even something as simple as writing..
loop{
gpioc.bsrr.write(|w| w.bs13().set_bit());
cortex_m::asm::delay(2000000);
gpioc.bsrr.write(|w| w.bs13().set_bit());
cortex_m::asm::delay(2000000);
}
I'm completely converted from bondage and discipline languages as the panacea to Test Driven Incremental Development. Write a little bit, test a little bit, write a little bit more. Keep lots of tests around to detect regressions.
Once you're doing that, even a typeless language can be used reliably, though I definitely prefer a language where you can write user-defined problem domain types on things such as function arguments and class members and critical local variables, firstly as DOCUMENTATION for the human, but the compiler also checks them if you supply them. And infers the types of everything else as much as possible.