1

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.

closed as primarily opinion-based by jasonwryan, Stephen Harris, Julie Pelletier, Michael Homer, jordanm Aug 27 '16 at 4:16

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
2

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.

  • But the straight jacket can be useful for providing structure. Is that what you're getting at? – Vityou Aug 27 '16 at 1:42
  • 1
    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.