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

Re: Scriptometer: measuring the ease of SOP (Script Oriented Programming) of programming languages



Ken Anderson <kanderson@bbn.com> writes:

[...]

> >IMO libraries are an important component of a language. Not having a
> >default standardized leads to many pb.
> >
> >So I don't agree with assuming "a comparable library exist" is right.
> >If a language doesn't "system", it *is* a bad scripting language.
> 
> Sure, but in a language like Java, which doesn't "system" one could write a
> library that provided "system" and the language would become more useful.

sure it would become more useful, but that's not default Java anymore.
Not having it in default library cause people to re-invent square
wheels :-(


for example 

% false || echo "false failed" 1>&2

is
    if (Runtime.getRuntime().exec("false").waitFor() != 0)
      System.err.println("false failed");

where "exec" is something like popen(3)

but this doesn't scale to functions writing on stdout or stderr, or at
least it works until the output is big enough for the pipe to be full.

I found a version at http://www.rgagnon.com/javadetails/java-0014.html
Which gives something like:

    BufferedReader input = new BufferedReader(new InputStreamReader(
        Runtime.getRuntime().exec("echo done").getInputStream()
    ));
    String line;
    while ((line = input.readLine()) != null)
      System.out.println(line);

but this doesn't work for commands writing too many things on stderr
(at least on gcj)