4 ms·
I prefer the "everything is a computer" API. (Which happens to be Alan Kay's model of object oriented programming as message passing.) https://softwareengineer
by DonHopkins 8y ago
I prefer the "everything is a computer" API. (Which happens to be Alan Kay's model of object oriented programming as message passing.)
https://softwareengineering.stackexchange.com/questions/46592/so-what-did-alan-kay-really-mean-by-the-term-object-oriented https://softwareengineering.stackexchange.com/questions/4659...
>"I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful)." -Alan Kay
NeFS -- aka NFS 3.0 -- used a PostScript interpreter as the file system API.
https://news.ycombinator.com/item?id=17061967 https://news.ycombinator.com/item?id=17061967
- agumonkey 8y agoSame, I think the file 'abstraction' is only valid for data flow. But whenever you have system components represented as files, you end up with a bunch of side API bolted (kinda like ioctl in linux). Plan 9 had a different view IIRC, something like everything has a protocol.
- pjmlp 8y agoYes, but Carmack had some issues having a framebuffer as file. https://marc.info/?a=111558719100068&r=1&w=4 https://marc.info/?a=111558719100068&r=1&w=4
- theoh 8y agoPlan 9's rio window system expected most graphical clients to use the draw functions, which operate by writing to /dev/draw. /dev/draw wasn't even a framebuffer—it was a control file that you wrote messages into. It clearly wouldn't have met Carmack's requirements though as the thread you link to points out, the Plan 9 team would have been happy for him to map the framebuffer into the address space of his process.
- agumonkey 8y agothis carmack guy is really not cut for graphics programming
- nine_k 8y agoIf we invoke "OOP" here, why not invoke classes? Or rather "interfaces" in modern OOP-speak, or "traits" in other parts of the landscape. There's a common trait among many objects: you can read a sequence of bytes from it. Disk files, sockets, various input devices, random number generators, etc. There's another common trait, writing a stream of bytes. Another, even more common pair of traits, is "opening" and then "closing" something. All of them can be described using interfaces / traits to clearly communicate which sets of operations are applicable to which objects. This e.g. can be neatly used to describe the "many things are a file" idea: File passwords_file = Filesystem.make("/etc/passwd"); Readable password_readable = passwords_file.openRead(); // Could be openWrite(). Process zcat_process = Processes.make("zcat /tmp/something.gz"); Readable zcat_stdout = zcat_process.stdout.openRead(); // Can only be openRead(). ClientSocket sock = Network.makeClientSocket(host, port, options); // Unlike a file. Readable sock_readable = sock.openRead(); for (Readable r in [password_readable, zcat_stdout, sock_redable]) { byte b = r.read(); // Read one byte from each, no matter what it is. } But this would require a very different language, way more powerful than C (but also not C++ please). Unlike in 1969, now we have languages like that, e.g. Rust and ATS-lang. Likely we need another 10-15 years for a viable, somehow widely used OS kernel written in such a language to emerge.
- aidanlister 8y agoYou are a level too high in the stack - what is happening behind the scenes when you execute any of those?
- comex 8y agoIf it were my design, IPC (auto-generated) to a corresponding method in the kernel.
- nine_k 8y agoAs long as this gets type-checked at compile time, the types info can be erased during compilation and be absent at runtime. Since traits / interfaces can't have their methods overridden, you don't need the dynamic dispatch, per-instance VMT, and such; you can have fixed offsets in a method table per class, both in userland and in kernel. (Some of the indirect calls can probably be made direct if the class is exactly known at compile time.)