4 ms·
Actually I've been considering/dreaming about a thing like this for a long while now (ever since I got started with jQuery and discovered how smooth I could sai
by anvandare 14y ago
Actually I've been considering/dreaming about a thing like this for a long while now (ever since I got started with jQuery and discovered how smooth I could sail through the DOM with it). The idea I came up with (I'm most likely not the first to think of it, so tell me if someone already implemented it) is a sort of JavaScript shell for *nix that'd work similar to jQuery: passing along (collections of) JavaScript objects with properties and functions.
e.g.:
var sum = 0;
$("~").ls({"type": "file", "size": ">1M"}).each(function () {sum += $(this).size("mb");});
$.echo("total size of home directory: %d MB", sum);
- stcredzero 14y agoOr, one could write a library of standard parsers and serializers for the Unix tools that would parse and produce known JSON representations of data that could be passed between scripts.
- zem 14y agoi did something like that at my last job - the cluster manager was designed as a set of command line tools, and every program had a -j flag that would make it parse stdin as json and write json to stdout. we then wrote wrappers around all the linux utilities we were using, to enable the same behaviour. once the basic system was in place it let us experiment with new features very rapidly indeed because everything could be tested in isolation from the command line using automated test scripts. what was especially nice was that we could use the same test framework to chain several utilities together and test the combination, because it was all a black box with json going in and coming out.
- Evbn 14y agoThat's recordstream
- stcredzero 14y agorecordstream seems to concentrate on lots of formats. Really, it should concentrate on lots of tools, with a shared repository of parsers for tools. EDIT: Actually, they concentrate on JSON, but they also try to provide a generic set of tools for reading any format. I think this could be better structured to "just work."
- noblethrasher 14y agoPowershell on Windows does something like what you want: PS C:\Some Directory $sum = 0 PS C:\Some Directory dir | where { $_Length -gt 1MB } | %{ $sum += $_.Length }
- mey 14y agoFirst thing I looked for when I checked the comments, was there a mention of Powershell. Powershell has the concept of passing objects (via .net clr) instead of passing strings. It sucks when trying to deal with streams of data, but fantastic for acting as script glue between various systems. One of the things I feel Microsoft really got right.
- e12e 14y agoFirst thing I checked for too. Second thing I looked for was someone pointing out that this is asking for object oriented systems (such as Smalltalk or Self). But the third thing, no one mentioned: SNOBOL. Reportedly (because I haven't used it myself) it is better than AWK for complex matching.
- ori_b 14y agoI played with SNOBOL. It may have a more powerful matching engine, but power doesn't equate to usability. Having each line followed by 3 gotos does not good UX make.
- jejones3141 14y agoIcon or its descendant Unicon might be worth a look, then.
- ori_b 14y agoMaybe. I don't think I've ever really been constrained by the power of Awk's pattern matching. I wish I could do it recursively, but that's not so much a power issue as a composability issue.