[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Java



> > (3) I suppose you can be offended by this if
> > you choose, but I don't see how it makes coding more difficult.
> > In fact, each File object has a current-directory, which is just
> > a convenient generalization of the cwd concept.
>
> Why couldn't "cwd" and File objects co-exist?

I don't get it.

You just don't like the fact that Java allows you to maintain any number of
current working directories, while Posix only maintains a single one with
chdir/getcwd?

If the limitation makes you happy, then you can easily roll your own
crippled FS interface.

class SingleWorkingDirectory {
  protected static Object _lock = new Object();
  protected static File _file = new File(System.getProperty("user.dir"));
  public static File chdir(String newdir) throws IOException,
SecurityException {
     synchronized (_lock) {
        File f = new File(_file, newdir);
        if (! f.isDirectory())
            throw new IOException("Invalid directory");
        return _file = f;
     }
  }
  public static File getcwd() {
     return _file;
  }
}

Jeremey mentioned some gripes that I think are much more valid: lack of
generics, broken memory model
(http://www.cs.umd.edu/~pugh/java/memoryModel/), lack of tail call
optimization. They make a much better starting point for Java flames: Even
though it's undesirable, you can always download a library that does
whatever globbing/str replacing/crippled FS interfacing/native env stuff you
want. You can't download a little library that gives you tail calls or a
reasonable memory model.

,steven.