I enjoy writing Ken C when the occasion arises. Embedded structs, the %r verb, mk, and the header rules all make it feel nicer than standard C.
It’s also worth noting that the C compilers on Plan 9 don’t do very much optimization, and generally act in the way you would expect – most undefined behavior is treated as implementation defined instead. This means that you don’t get many of the spooky miscompilation at a distance effects that makes writing C so much more painful than it could be.
It’s interesting to me contrasting these styles and libraries with those of the OpenBSD project. As far as I can tell, Plan 9’s only doing one actual change to the C language, if you can even call it that (the #pragma lib foo.a bit), and achieves everything else just by changing libraries and the tool chain. OpenBSD also provided a lot of improvements to the C standard library, yet they ended up in very different spots. Even allowing for Plan 9 not needing the same level of backwards compatibility as OpenBSD, it’s interesting to me that none of these APIs seem to follow what I’d consider “safe” practice.
#pragma lib foo.a
Does anyone familiar with the community know whether Plan 9 forks, like 9front, are also looking at adapting OpenBSD-like security hardening? Or is that not really their focus these days?
There are multiple changes to the C language: no separate preprocessor, no #if, anonymous structs and unions (also in C11), anonymous struct embedding, struct expressions (also in C99, but different syntax), extern register storage class that implements cpu-local storage, no const, no volatile, no register.
You are right however that all these are minor changes compared to the change effected by a different C standard library.
Nobody is interested in adopting the type of security features adopted by OpenBSD at the binary interface level, but I would argue that centralised authentication, distributed authorisation, no superuser, every resource being accessed only through the filesystem with permission checking, no shared libraries, no loadable kernel modules, and pervasive cryptography make Plan 9 much more secure than the average Unix both on an architectural and practical level.
It’s worth pointing out for the sake of clarity and provenance that Plan 9 C is primarily the work of Ken Thompson.
Ken Thompson: the good parts of Unix, the good parts of the Plan 9, the good parts of Go.
There has been some casual investigation but nobody to my knowledge is seriously working on OpenBSD style security features.
s/write n bytes from fd into buf/write n bytes to fd from buf