I've never done RT as a job.
Me neither, but I'm a practically omniscient super-autist and can correctly intuit what others get wrong even after doing actual research.
My lack of experience probably led to me using the wrong terminology and talking past you, but do you see what I mean?
Your terminology is no worse than mine, don't worry. I understand what you're saying.
Isn’t the problem with malloc() that allocation (and free) time is hard to bound, and fragmentation builds up until you can’t get a block even when the total free memory is there?
Well yeah, that's two of the problems but those are by far not the only one.s The main problem I see, and this doesn't only apply to RT, is that it is very easy to fuck up using malloc/free and you can't prove that you're doing it correctly in the general case with static analysis and the like. The idea in Rust is to constrain this shitfuckery in such a way that the compiler can statically prove that you're not fucking it up, not only malloc/free directly but memory access in general. That doesn't solve memory leaks though for example.
I'm increasingly just going WHY ARE WE DOING HEAP VOMIT AND REFERENCE TWIDDLING and I can't see why.
I'd say because we apparently can't special case allocations and other things regarding MM automatically. Every malloc that the compiler can't optimize out entirely goes the the same function, which does know nothing about the future lifetime of the allocation, weather or not it might need to grow later and a bunch of other things that the compiler knows(or at least can make a reasonably optimized guess). Simple example just to illustrate the point: Let's say we get a large number of small allocation requests of varying sizes. If we're the malloc implementation we have no idea when which of these live how long so best we can do is to try and put allocs of the same size together to avoid gaps and make management easier. If we where the complier we could know that a specific subset of these allocations will remain valid until some time later when all of the subset will be freed at the same time. The compiler could in theroy use a special arena stategy for this specific subset instead of putting it all on the general heap and have malloc deal with the random fragmentation.
I don't actually know if anyone has tried implementing something like this somehow but from my POV i'd say the software stack is pretty much deadlocked. Compilers can't fix this because the compiler doesn't control the malloc impl, they are allowed to optimize out malloc calls in some cases but I don't think they can replace malloc calls with thier own special cased smart malloc. The malloc implementors can't fix this because malloc doesn't have the info available they need to make such decisions . A new language could maybe fix this but I think it wouldn't really be a systems programming language anymore since you'd loose a lot of control over your datastructures. Maybe there is a way but I don't see it as of now.
The reason we're twiddling around so much with pointers/references is that they are an extremly simple, low level and redicoulously powerful primitive. From the hardware POV they are literally just an interger that fits into a register and from a programmers POV you can do anything with just scalars, structs and pointers. The complexity vs usefulness tradeoff for the pointer concept is so rediculously good that everything just goes to shit if you try to get rid of it. You can constrain and auto-manage them if you want(smart pointers, GC, rust's &/&mut types, etc.) but they're still there. There are some execptions for domain specific stuff like prolog or SQL but these don't really do what what you'd do with a "normal" language like C. I don't know how functional languages do references, so maybe someone more "pure" than me can chime in on that.
My son, be not led astray by the worldly fascination with containers on containers. The Lord has brought us raw hardware, rcctl, and jails, and that is all that a true sysadmin needs.
I belive that the reason containers are popular in the first place are that
- pretty much all id/name allocations(think network ports, file/dir paths, unix socket parths) are descretionary. Ports are not assigend by the OS to the daemon, the daemon tries to claim a port. This is problematic for security, so people put daemons in containers so they can assign ids/names in a way that's not controlled by the daemon itself.
- software distribution is a mess and people don't want to deal with library version incompabilities between various distros/versions thereof and other distro specific low level nusences, so they pick a base image and package their software as a container and call it a day.
It's perfectly reasonable that most people who run actual services use them AND it's perfectly reasonable that autists who care about systems hate them.