Hacker News new | ask | show | jobs
by austinpray 2833 days ago
I use zsh daily but type `xonsh` any time I do something in the shell that would normally require a google.

“Uh ok so I have this JSON file. When I pipe this to `jq` I forget: to pivot an array of objects to an object keyed by array[x].id is it like `to_entries` then chain it to `map`? Uhh let’s look at the docs...”

However in Python I can write that function at the speed of thought. It may be a couple more lines of code but I’m also 100% confident in the output.

Like I understand some people can legitimately program in bash [0]. But I just can’t bring myself to practice. Why would anyone inflict this language on themselves?

[0] https://github.com/docker-library/python/blob/master/update....

3 comments

> Like I understand some people can legitimately program in bash [0]. But I just can’t bring myself to practice. Why would anyone inflict this language on themselves?

Bash has a lot of pitfalls, but once you learn how to deal with them, it can also be quite superb for some tasks. Piping the output of a complex set of loops into GNU parallel and watching your computer process stuff at blazing speed is a very nice experience. Doing the same in python would be many time more verbose.

> I use zsh daily but type `xonsh` any time I do something in the shell that would normally require a google.

Personally, I stopped using `jq` in favor of python oneliners, they a bit more verbose but also cross-compatible, works out of the box (not everyone has jq, but most of people have python (pre)installed on their machines) and it is easy to implement a oneliner, i.e.:

   curl -X GET "https://httpbin.org/json" -H "Accept: application/json" | python -c 'import sys, json; print(json.load(sys.stdin)["slideshow"]["author"])'
Do xonsh helps you write a tar command without googling [0] or browsing a man?

[0]: https://xkcd.com/1168/

Bash combined with utilities is like a swiss knife of scripting, you won't be doing any major woodwork with it but it sure is a heck of a useful tool.