News for hackers. Stuff that matters.
Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by winter_blue on Wednesday June 21, 2023 @08:23AM (#36417562)
An attempt is being made to reduce everything to:

    interface UniversalInterface {
        fun open(…)
        fun read(…)
        fun write(…)
        fun close(…)
    }
If you went to a software engineering design review meeting, proposing that several different kinds of objects representing everything from files, network sockets, to arbitrary devices should all use the interface above, you’d be laughed out of the room.

Ultimately, when someone does end up implementing something like the above as the sole interface for some major component, it’ll result in libraries that return a wrapping object with a more useable and pleasing interface that abstracts away the ugliness of using UniversalInterface to interact with said component.

I see two ways forward with this. Either: (a) present the option of using UniversalInterface to interact with X object, in addition to interface that’s much more idiomatic and closer to how X object actually behaves.

Or, (b) come up with an alternative universal (or flexible) object interaction interface that’s much more flexible than UniversalInterface.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by Someone on Wednesday June 21, 2023 @08:45AM (#36417753)
> Either: (a) present the option of using UniversalInterface to interact with X object, in addition to interface that’s much more idiomatic and closer to how X object actually behaves.

> Or, (b) come up with an alternative universal (or flexible) object interaction interface that’s much more flexible than UniversalInterface.

That’s, basically, what COM/Corba/… are. There, UniversalInterface has an additional call “If you are a Foo, give me your Foo interface”, with Foo as an argument to that call.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by Spivak on Wednesday June 21, 2023 @08:58AM (#36417873)
And dbus as well on Linux. I think that that style is much better than everything is a file. Everything is a typed object.
Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by winter_blue on Thursday June 22, 2023 @02:48PM (#36436905)
> Everything is a typed object.

That's really good. The fact that the file interface just gives you a string of bytes, with no concept of structure or type safety in the interface itself is a major flow of it. Type safety is immensely valuable.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by 3cats-in-a-coat on Wednesday June 21, 2023 @09:14AM (#36418044)
> If you went to a software engineering design review meeting, proposing that several different kinds of objects representing everything from files, network sockets, to arbitrary devices should all use the interface above, you’d be laughed out of the room.

You're describing a meeting in which people seem unaware of the purpose of uniform interfaces. Not sure we could call such a meeting "engineering design" meeting, because engineers tend to know better.

If I went up and proposed the same interface for all cables, displays, mice, keyboards, speakers, hard drives, phones... and called it USB, would I also be laughed out of the room?

There's no benefit to reinventing open/close/read/write in 50 different ways. The goal is to do it once, and then build more complex interfaces on top of it. That is, unless you're paid by the number of lines of code you write.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by codedokode on Thursday June 22, 2023 @06:13PM (#36439858)
> The goal is to do it once

There is an universal interface, it is called "system call". Rather than build unnecessary layer on top of it, improve the syscalls if you don't like them, and get rid of ioctls, /proc, /sys and other pseudo-syscall abstractions.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by gpderetta on Wednesday June 21, 2023 @09:16AM (#36418057)
A file descriptor is equivalent to the Object universal base class in many OO language [1] and represents an handle to an OS resource. Now in UNIX you can have anonymous [2] resources, but in the Plan9 model most resources have a name and you can get an handle to it via open(<resource-name>).

Hence open is not part of your UniversalInterface, but it is a way to obtain a reference to it. It seems reasonable to have a generic way to dispose of an UniversalInterface (hence close). read/write are simply a generic ways to send and receive messages from UniversalInterface, not unlike a dynamically typed object. Ideally you would do a checked down cast to your actual interface [3], but this was designed to work with C so you have to make do.

[1] I don't subscribe to the Everything is an Object in the OO sense, but having a common base class for most OS resources seem a reasonable solution.

[2] or at the very least there isn't always a cross-resource-type namespace.

[3] Not unlike COM QueryInterface, and in fact UniversalInterface is equivalent to IUnknown

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by packetlost on Wednesday June 21, 2023 @09:18AM (#36418084)
That is quite literally how Kubernetes works at large, which Plan 9 is to Unix as Kubernetes is to Linux, sort of. When the system is built from the ground up to be distributed across heterogeneous systems, you basically must build higher order protocols on top of really really simple ones. It's not that opening a byte-stream socket is the best interface for everything, it's that it's the lowest common denominator that everything can agree on no matter what.
Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by barrkel on Wednesday June 21, 2023 @10:20AM (#36418793)
That's not far from the CRUD of a database, or POST/GET/PUT/DELETE of HTTP. It's also not far from what you'd expect at the transport layer of an RPC / IPC mechanism.

The metadata around files - ownership, permissions, creation time - apply to a lot more than files.

I don't really see it being laughed out of the room.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by naasking on Wednesday June 21, 2023 @06:35PM (#36425641)
> you’d be laughed out of the room

Doubtful. Why are the main paradigms?

Everything is an object

Everything is a function

Everything is a resource (REST)

Uniform interfaces are common for good reason: you gain a lot of flexibility for redirection, introspection and policy control.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by GoblinSlayer on Thursday June 22, 2023 @05:34AM (#36429790)
>Ultimately, when someone does end up implementing something like the above as the sole interface for some major component, it’ll result in libraries that return a wrapping object with a more useable and pleasing interface that abstracts away the ugliness of using UniversalInterface to interact with said component.

Yes? All interfaces do that, especially system interfaces. It's the whole purpose of interface - to provide implementation logic in a usable form. Try to call the kernel by hand and see the difference.