Why can't things in unix be represented as objects? For example, files are sort of objects, but they are all just files. I realize that this can be useful for providing a standard interface, but does it really? What's the point of something being a file if reading a file doesn't show anything useful like a device file? I think a device file could easily be an object in a directory, instead of a file. Then instead of having to run some command like cgdisk, the device object could provide it's own way of changing itself or give information about itself, for example /dev/sda.partition1.get_size(). I think this would be nicer in theory than having a bunch of commands that do different things all in one directory (/usr/bin) and that all have different ways of passing options to them. If there's something obviously wrong with that idea i'm sorry, but I have a question that has less to do with objects in that case. Why cant commands be organized in usefully named directories? For example instead of having every command in /usr/bin, you could have something like /CMDs/devices/list or /CMDs/output/echo hello.

  • I have many comments but my main comment on your whole description is the idea to put applications in multiple different directories. How do you think these could be called? Are you perhaps thinking of creating some kind of global registry to manage those? Your different hardware elements could possibly be put in a device manager. If you don't like Unix and prefer Windows, why not use it? – Julie Pelletier Aug 27 '16 at 1:51
  • I don't know what a registry is and I don't like Windows, but I suspect you would call commands like you normally would, but the directory names would give a little more info about the command. – Vityou Aug 27 '16 at 1:56
  • 1
    That would imply having a huge PATH, making every single call slower. – Julie Pelletier Aug 27 '16 at 2:13
  • 1
    Note that your concept resembles the classic Mac design where applications were in a single file that included multiple objects. It was very nicely designed but probably the most unstable OS ever popularized. – Julie Pelletier Aug 27 '16 at 2:21
  • 1
    What I mentioned about the PATH is not related to the effort needed to organize the files, but to the effort required by the operating system to locate the command. One thing you could do to organize your programs the way you're thinking is to create the directory structure of your choice and fill it with symlinks to the actual programs, but you would get no benefit other than seeing them in that order when you look through that directory hierarchy. – Julie Pelletier Aug 27 '16 at 3:20

The Unix semantic was designed 30+ years ago and is based around 'everything is a file'. This kinda got lost a little (eg Berkeley sockets) but it still mostly holds.

The consequences of this are "here's a resource, use it how you like". It's a lot more flexible than an object oriented view of the world.. but allows you to shoot yourself in the foot if you do it wrong!

So your disk is a file (/dev/sda). Each partition is a file (/dev/sda1).

But what is a partition? It's just a data structure. Why would the "disk driver" enforce it? A Solaris SPARC disk doesn't use Microsoft DOS labelling; it's partitions are totally different.

The "everything is a file" format is a lot more flexible. You can do whatever you like without the straight-jacket of the operating system.

| improve this answer | |
  • But the straight jacket can be useful for providing structure. Is that what you're getting at? – Vityou Aug 27 '16 at 1:42
  • 2
    The Unix philosophy is that if you want to shoot yourself in the foot then we'll provide you with a wide selection of guns. There's a joke; "Unix is user friendly... but it's very careful who its friends are". An object oriented interface is antithetical to Unix semantics. – Stephen Harris Aug 27 '16 at 1:49
  • This might be off topic, but is there a good os (that runs on the hardware or a good virtual model of hardware) that provides a more standard interface, and is the kind of OO that I describe, and where the disk and partitions are on the same abstraction so my example would make sense (not really a requirement but thats sort of the idea i'm looking for). – Vityou Aug 27 '16 at 1:53
  • Powershell on Windows? It's always possible to create an OO library for Unix but Unix never enforces it. – Stephen Harris Aug 27 '16 at 1:57
  • @codersarecool Or just Windows, generally; much of the architecture is pretty object-based. – Michael Homer Aug 27 '16 at 2:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.