Indeed it's absurd and I think it's the main issue here.
You are, basically, saying: banks are doing it wrong
- They are spending money on walls
- They are paying for complicated locks
- They hire these stupid security guys
- Complex procedures
Let's do better, safer:
- Put all the gold in the easy-to-access place
- Ensure that there are no guards
- Remove all the locks and demolish walls
They you would have no problems with lifetimes, no lost keys and everything would be very safe. Right?
Yet, somehow, none of banks ever follow that route. I wonder why.
The disdain for the static mutable data comes from very simple observation: there are no protections against… against anything really.
Any piece of you program can change any piece of data. No protocols (like “you can only change field which shows much much data is available only after data was actually added to some buffer”), no limitations.
Pile of gold with easy access for everyone.
No, it's not. Allocated memory may stay around forever. That's fine, Rust supports it with
unsafe, not problem. But actual valid, useful, correct data? Nope. It comes and goes. Even in the embedded app.
What part of buffer is valid? Which buffer is open for drawing and which is frozen because hardware writes data there with DMA? Can we toggle pin A before pin B or is it forbidden?
Embedded space is chock-full to the brim with filetimes.
It really sounds as if you think lifetimes only exist to allow one to use dynamic memory without GC.
Nope. Not even close. Not even remotely close. Lifetimes (or, formally, affine type system, as it's known in the academic literature) was invented to handle specifically things other than memory, to control hardware. To track validity of data, not memory allocations.
Rust developers just noticed that if you have an affine type system then you can use it to control memory, too.
But it was originally invented specifically to safely control hardware which is, kinda, why most embedded systems exist in the first place.
The goal of lifetimes is not to ensure memory safety, it's just a side-story Rust embraced. Lifetimes are a tool which is designed to prevent access to the data (or hardware resource) when it's not valid to access said hardware resource. And, once again, they were invented and implemented in languages which used GC for memory management initially.
Heck, even Rust had GC in the beginning! Lifetimes weren't added to Rust to manage memory! They were supposed to manage other things.
It was just, eventually, found out that they are flexible enough to manage memory, too. But that wasn't the motivation for them!