Assorted Thoughts on Zig and Rust
scattered-thoughts.net343 pointsby ikskuh296 comments
char buf[4];
float * f = buf;
*f = 32;
Seems simple, compiles, and even executes. Everyone is happy. But that code will just explode randomly on non-x86 platforms as it violates alignment rules. In Zig, this code will give you a compile error, as []u8 does have alignment 1, while a []f32 will have alignment 4. This means you have to learn about alignment before accidently writing code that will randomly crash at runtime depending on the stack position of buf.
Yes, the OS is highly opinionated, as just making another linux is incredibly boring for me!
The 32-bit only constraint is mainly due to my focus on smaller architectures, especially microcontrollers.
x86_64 and aarch64 both have much more complex initialiastion schemes, and also use much more complex page table setups.
Thus, i wanted to keep that out of the system, considering i'm targeting systems with a tiny fraction of the 4 GiB memory limit.
The co-op multitasking is a part of the OS, and the OS doesn't give you preemptive multitasking. I never said i won't implement sanity safeguards! Just killing off a hanging process that doesnt yield for more than 1-5 secs is totally i scope and increases user friendlyness. but considering the system reboots in 1.2 s on target hw right now, the user will maybe just have hit reset by then :D