why Unix?

Christopher Wright dhasenan at gmail.com
Wed Apr 8 08:09:27 PDT 2009


Daniel Keep wrote:
> 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.

You are rarely going to write a program that uses reflection more often 
than direct calls. It's inefficient in terms of the amount of code you 
need to write. It's inefficient in terms of running time. And you need 
to have a very good idea of what you're looking for in the first place. 
So that doesn't much matter.

What *does* matter is standard interfaces. If a command will usually 
only return, say, a DataTable or an IEnumerable or a string or an 
integer, then you're down to a manageable range.

In this regard, Unix has a standard interface: text. This turns out to 
be usable >90% of the time. It has the advantage that you can write a 
program in any language that can process text. But it has disadvantages, 
too.

> 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.

That's awesome. It's an annoying and unsolvable issue with bash. That 
would remove issues where you have to escape a string multiple times -- 
which can result in hard-to-find bugs.

Of course, it only helps when you're working within powershell. But that 
would still be an improvement.



More information about the Digitalmars-d mailing list