Why do people start new projects in CoffeeScript?!
Awkward – A Node.js-based terminal emulator
51–60 of 64 posts
Re: Awkward – A Node.js-based terminal emulator
#52Re: Awkward – A Node.js-based terminal emulator
#53Normally I have a severe allergic reaction to anyone trying to do anything serious with Javascript, but this looks like a legitimately good idea and a decent innovation on how shells work. I'm beginning to think that it isn't Javascript that I hate, it's the way people use it (i.e. to build bloated, slow, terrible webapps). But this is actually pretty cool. JS is shockingly decent at text processing so repurposing it…
Re: Awkward – A Node.js-based terminal emulator
#54Earlier quoted context omitted.
I'm sorry but that seems to be some of the least intuitive code I have ever seen. What are the practical applications of knowing AWK over knowing JS? (Besides the shell voodoo). I'm not trying to start a language war, I just want to understand why learning a completely new set of grammars with a very limited domain would be worth the effort.
Awk is actually very intuitive once you learn the basics (should take about an hour). Awk is essentially a line-oriented pattern matching language, that is, a collection of patterns -> actions that are applied to every line of input. Syntax is very similar to C, but feels much more lightweight. To decompose the example above: NR > 1 { print $1, $4 } There are two parts to this, the pattern (the part outside the brack…
$NR stores the number of records (or the current record number) not the number of fields (that's $NF). In the example the "NR > 1" is meant to exclude the header line from the output.
Re: Awkward – A Node.js-based terminal emulator
#55How Herculean of a task is this?
Re: Awkward – A Node.js-based terminal emulator
#56This is good, but the data structures - eg arrays of arrays - don't really match the underlying data. Imagine what 'ip addr' or 'ifconfig' would look like - they output paragraphs rather than lines, so scraping lines wouldn't produce good output. It'd be better - and FAR more work - to make an object pipeline based powershell equivalent for Nix, based on JSON. You could write cmdlets in any language that outputs JSON…
That sounds so good and better. Thank you, I will work on it.
wrapPs( "ps -ef" ) => [ {pid: 1234, name: "foo.sh" }, ... ]
wrapLs( "ls -al" ) => [ ... ]
(not the syntax but the idea). You want to allow interested individuals to write the wrappers "forcefully" against uncooperative maintainers (separate people, separate ideas, separate motivations, separate release cycle, etc).
Eventually, some enlightened shell-command owners might add "ls -al --json" or "ps -ef --json", "git stat --json" which removes the need for a wrapper script, but the wrapper script allows innovation peripheral to the core without affecting the core until finally due to overwhelming support the core is extended with something "good" and agreed upon via consensus usage.
For the short term, perhaps if "ps" and "ps.wrap" exist in your path, your awkward shell can inject the "* .wrap" automatically around the given command in a way that doesn't require a lot of typing, either automatically, or via shortened syntax.
(ps -ef).map(...)
!(ps -ef).map(...)
{{ ps -ef }}.map(...)
I don't know but eventually you'd want to get to a point where you're bridging between the interactive use case (ps -ef printing a nice text table) and the pipeline use case (ps -ef --json letting you easily access different fields), maybe {{ ps -ef }} either calls * .wrap if it exists or if it doesn't exist calls it with --json (this assumes the command supports --json directly)
Regardless, this idea has some legs and I look forward to seeing how much traction it gets.
Re: Awkward – A Node.js-based terminal emulator
#57Like. But PowerShell still rules. Wish it was oss and x-plat
Microsoft seems to be working on porting PowerShell to Linux already [0] and there's a partial port using Mono [1]! [0]: https://windowsserver.uservoice.com/forums/301869-powershell... [1]: https://pash-project.github.io/
Re: Awkward – A Node.js-based terminal emulator
#58The following comment could apply to hundreds of similar submissions to HN in recent years. Many people -- many of them young people I suspect -- have invested a lot of time learning Javascript. It has become a very popular language. But it remains to be seen whether Javascript will be as long lasting as the UNIX shell and standard utilties. Historically speaking, computer languages have been known to fall into and o…
Even Cobol, Fortran and Lisp are still active.
Javascript as this moment probably has the highest number of programmers using it. It is standardized and has several competing state-of-the-art OSS implementations. It's going go be with us, at least as legacy code, for decades :)
Re: Awkward – A Node.js-based terminal emulator
#59Earlier quoted context omitted.
Awk is actually very intuitive once you learn the basics (should take about an hour). Awk is essentially a line-oriented pattern matching language, that is, a collection of patterns -> actions that are applied to every line of input. Syntax is very similar to C, but feels much more lightweight. To decompose the example above: NR > 1 { print $1, $4 } There are two parts to this, the pattern (the part outside the brack…
Not intuitive enough apparently ;) $NR stores the number of records (or the current record number) not the number of fields (that's $NF). In the example the "NR > 1" is meant to exclude the header line from the output.
NR is initialized to 1 on the first line, and is incremented for every subsequent line read. So, in this case, the above pattern will match any line after the first.
Re: Awkward – A Node.js-based terminal emulator
#60I'm imagining a world where coreutils and built-ins all respect an environment variable, say STDOUT_JSON=1 , and would output JSON. That would be a great start. Especially if the JSON-Schema could be output with a new built-in, manj . How Herculean of a task is this?