Live data from Hacker News

Awkward – A Node.js-based terminal emulator

github.com

31–40 of 64 posts

Re: Awkward – A Node.js-based terminal emulator

#31

Uh... ps | awk 'NR>1{ print $1, $4}' I'll give that the syntax of these shell programs take some work to understand but they're hard to beat for the purpose they serve. If you're parsing plenty of JSON these days I find 'jq' indispensable. It's basically awk/sed for JSON. I would just be sure to study those programs as they took quite a bit of effort to make them fast. And there are plenty of alternatives with extend…

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.

> What are the practical applications of knowing AWK over knowing JS?

That it is present on pretty much every Unix-like system, and most other platforms with a "real" OS, including platforms where finding a modern Javascript implementation is impossible.

It's also a very small language, and the default of parsing records from standard in and splitting them by a field separator and pattern matching on them makes it very well suited for compact filters without extra seremony (some other interpreters have flags to give an awk-like exerience - e.g. Ruby (MRI) - but none are remotely as likely to be installed everywhere unless you go for more cryptic tools like sed).

Re: Awkward – A Node.js-based terminal emulator

#32
post #27
post #21

The 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…

Perhaps there are features from other programming languages that should exist in shell programming? For example, I've always felt that the fact that almost everything in shell programming is a gigantic string is really bad. It would be much nicer if all commands had type signatures, and therefore piping commands into each other could throw type errors if it does not make sense. This would also allow much better feedb…

Like in PowerShell?

Re: Awkward – A Node.js-based terminal emulator

#33
post #27

Earlier quoted context omitted.

Perhaps there are features from other programming languages that should exist in shell programming? For example, I've always felt that the fact that almost everything in shell programming is a gigantic string is really bad. It would be much nicer if all commands had type signatures, and therefore piping commands into each other could throw type errors if it does not make sense. This would also allow much better feedb…

Like in PowerShell?

[deleted]

Re: Awkward – A Node.js-based terminal emulator

#34
post #21

The 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…

They're going to continue to pop up, just like JavaScript frameworks will. Because they're not popping up due to any necessity, but because someone (1) learned JavaScript, (2) learned some shell commands, (3) had the epiphany that they could abstract shell commands away using JavaScript, and (4) isn't aware of the previous thousand attempts by others to do the same thing.

That's incredibly dismissive.

AWK isn't perfect (nothing is). So that means that there are still improvements that can be made to it. One of the improvements to AWK (or something awk-like) would be to make it have a more familiar syntax to those who don't already know awk.

I'll admit, the only thing I use awk for currently is to pull out columns of the output to pass on to the next tool. I know it can do more, but I don't have time to really learn and understand the langauge.

While I don't like many things about this project, I really like some of the ideas that it's suggesting. I'd love a "awk but with javascript" where you can use a subset of javascript to work like awk where you can pipe in data and have it output "regular" lines that can be passed to the next tool on the command line.

letting me use familiar javascript functions and syntax to map/reduce/filter over lines of input and output plaintext would be amazing. This doesn't quite do that in the way I want, but it's a cool thing nonetheless.

Re: Awkward – A Node.js-based terminal emulator

#35
post #27

Earlier quoted context omitted.

Perhaps there are features from other programming languages that should exist in shell programming? For example, I've always felt that the fact that almost everything in shell programming is a gigantic string is really bad. It would be much nicer if all commands had type signatures, and therefore piping commands into each other could throw type errors if it does not make sense. This would also allow much better feedb…

Like in PowerShell?

I've not used it before and I presume it is Microsoft Windows only.

Re: Awkward – A Node.js-based terminal emulator

#38

how can you apply flags to the command? For example, I use `ps -ef` a lot, how would I do that with this system?

This seems to work, (ps -ef)().map((a)=>{return [a[0],a[7]]}).forEach((a)=>{console.log(a)})

Ah, put the whole command in parens!

It might make sense to put a note in the README about that, unless it's already there and I missed it somehow...

Re: Awkward – A Node.js-based terminal emulator

#39

Earlier quoted context omitted.

This seems to work, (ps -ef)().map((a)=>{return [a[0],a[7]]}).forEach((a)=>{console.log(a)})

Ah, put the whole command in parens! It might make sense to put a note in the README about that, unless it's already there and I missed it somehow...

I am sorry, it slipped from my mind. I will add it now.

Re: Awkward – A Node.js-based terminal emulator

#40
post #37

Earlier quoted context omitted.

Because it's a language just like any other? It's not like it's deprecated or anything.

It's irrelevant given TypeScript and ES2015+.

I'd say it's far from irrelevant.

The fact that it uses whitespace instead of braces is a big plus for people used to that, and generally you write less coffeescript compared to TS or ES. Plus it has things like switch expressions, list comprehensions, chained comparisons, the safe nav operator, and a ton of other little features that either don't show up in TypeScript or ES.

And it's very simple (no configuration needed), and compiles to very readable javascript which means converting to plain JS is very easy (hell, there's even a purpose built tool called decaffeinate which will translate it directly to ES2015)

You might not like the language, I don't really like it all that much anymore either, but it's not irrelevant, and for a small personal project like this it seems like a great choice which is easy to switch away from if needed.

Post reply on HN