4 ms·
Well, it can export as json, xml and I’m sure some other formats as well, so in principle it can.
by kaba0 6y ago
Well, it can export as json, xml and I’m sure some other formats as well, so in principle it can.
- rbanffy 6y agoThat sounds interesting, but either programs deal with schema transforms, or we'll have to write a lot of that kind of logic in XSLT or jq (kind of the same stuff we do with cut, sed, awk, sort and grep for unstructured streams). Not sure it's that useful a feature unless the domain of the programs is narrow.
- kaba0 6y agoTo be honest, I’ve been thinking about a shell based on the JVM. Especially now with GraalVM, you can have truly polyglot programs running on top of it, with inlinig cross-language boundaries! But of course native code execution should be “bootstrapped” into that world somehow. (Actually, it can use LLVM IR and that as well can run a C function on js objects which is phenomenal, but people do want to run native software from a shell)
- rbanffy 6y agoWhile you'll be able to invoke methods on returned objects, if you are piping stuff, you'll still need to deal with hammering the output of one program into the input of another.
- TeMPOraL 6y agoI think it could be useful - from PowerShell's perspective, all you need is to wrap your "classical" executables to somehow accept and emit .NET objects, and you can carry on from there. Importantly, no more writing parsers in the pipeline or in your scripts. I could see a whole library of such wrappers being built for common executables (and new popular OSS CLI tools could provide their own wrapper along with the tool).
- rbanffy 6y agoYou can wrap your .NET, JVM, Python, Perl or C functionality in a small program that links to the library you want, that deserializes your XML or JSON, reads your command, and acts on the incoming object stream, spitting it to stdout in a neutral, preferably human readable, format that can then be piped into the next command. Oh! Wait! This is what tools like cut, jq, grep, awk, and sed to. And they won't tie you to a certain object model.
- TeMPOraL 6y ago> Oh! Wait! This is what tools like cut, jq, grep, awk, and sed to. Yes! Except, you have to use them to write one-shot parsers that are specific to both what you're piping from and what you're piping to! For n commands you may want to arbitrarily mix, that's n² parsers to write. > And they won't tie you to a certain object model. From the point of view of a system user, tying to a certain object model is a feature. It facilitates commands interacting well with no parsers in between. But even if you don't have a common object model, just wrapping the commands to produce structured output can already be helpful, because the parsers you'll be writing to glue commands will operate on structured, higher-level concepts. It's easier to map between two different representations of what a "file" or "process" is, than it is to manually dig them out of an unstructured text stream. To use a stupid example, assuming hypothetical "kill-and-announce" that echoes a process name and sends a SIGKILL to its PID: ps aux | awk '{ ...extract columns... }' | sed 'rename columns' | xargs kill-and-announce ... Would be harder to figure out than: wrapped-ps | wrapped-kill-and-announce Or even with incompatible object models: wrapped-ps | select Target={id:$_.PID, name:$_.name} | wrapped-kill-and-announce
- fiddlerwoaroof 6y agoThis is one of those eternal debates I think: on the one hand you have OOP and certain sorts of FP advocates advocating for extremely rich data models that eliminate certain classes of errors by design. On the other hand, you have the Unix notion of using a very generic data type (see also Perlis’s “rather 100 functions on one data structure than ten functions on ten data structures”) to maximize flexibility, at the cost of a certain amount of footguns. Personally, I’m discovering more and more that CL’s REPL in SLIME is my preferred shell in part because the CL ecosystem has a rich array of operations on a small number of data-types (without forcing everything into binary streams), but also the ability to define ad-hoc datatypes as needed and a powerful system for manipulating them and integrating the custom data types into existing protocols. Also, the claim that you need n^2 encoder/decoders isn’t actually true: conventions around data formats can reduce it to O(n) in the number of conventions.