why Unix?

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 8 08:10:46 PDT 2009


On Wed, 08 Apr 2009 10:10:29 -0400, Daniel Keep  
<daniel.keep.lists at gmail.com> wrote:

>
>
> Steven Schveighoffer wrote:
>> [snip]
>>
>> -Steve
>
> This is getting rather inflammatory, so let me clarify a few things.
>
> What Yigal should have said was that when everything is a file, there is
> no API for the CONTENTS of files.  Yes, you can manipulate files, but
> it's a bit like Variants in D: you can't do anything useful with the
> contents unless you specifically know what they are.
>
> Powershell is designed to work with managed (.NET) objects.  It can
> dynamically introspect these objects and pull them apart, mutate them,
> convert them, etc.  Imagine if every file on a UNIX system also carried
> around a reference to its own parser, and a description of how to
> interpret the data.  THAT is what Powershell has over UNIX shells.
>
> For example, the output of the "ls" equivalent is a table of objects.
> By default, it gets toString'd and displayed as a table.  However, you
> can pipe this into a command that reorders columns.  Or sorts.  And you
> don't have to dick about with ensuring the filenames don't contain
> whitespace or newlines because the file names are carried around as
> actual strings that know their own length.
>
> Unlike UNIX, where everything is a file, to powershell everything is an
> object.  So the list command can be used on a directory or on an object
> that is an aggregate of stuff.  For example, you can use powershell to
> browse the registry as if it was just another part of the filesystem.
>

This does sound useful.  More so than was explained, sorry to Yigal for  
being so inflammatory, but what can you expect when you say Unix is a  
"stupid" design ;)  It's just a different design, one that works very well  
for script writers.

> I won't say that "everything is a file" is a failure, but powershell
> *definitely* exposes a superset of UNIX's functionality.  Anything you
> can do with a UNIX-style environment, powershell can potentially do  
> better.

This kind of thing is useful only for cases where OS objects were  
converted into strings (such as via ls), actual files still have to be  
read and parsed I'm guessing.  But having .NET at your disposal gives you  
a lot of potential parsers for things like XML files or whatever.

BTW, /proc is a lot like this.  You don't need to have a manual to  
understand what it means, since you can browse through it just like any  
other directory.  However, there are some files that have undescribed  
values in them, where you do need a manual.  But these files are built to  
be parsed for the most part, so it doesn't take a lot of work to get  
information out of it.  I think the advantage to having everything be  
represented as files is that you already have a bazillion tools to  
manipulate and parse files in unix.  The same is not for Windows, but it  
does have .NET which has a great API to OS objects.

> Microsoft really hit one out of the park with powershell, although it
> remains to be seen if anyone will actually use it.

It sounds a lot like it is geared toward .NET programmers rather than  
script writers.  Do you use it?

-Steve



More information about the Digitalmars-d mailing list