Question for the more seasoned Mac/Linux folks on HN:
Powershell has been a gift in getting things accomplished in Windows. But one thing I've also come to enjoy using it for is quick and dirty interactions and scripting with REST APIs.
Things like Invoke-WebRequest, ConvertTo-Json/ConvertFrom-Json, Export-CSV, piping between almost everything, and the results being passed around like an object that I can use SQL-ish Select queries against, etc.
I find myself feeling like I'm missing something helpful when I'm on a Mac/Linux device. Is there a similar go to in the Mac/Linux world for this type of stuff? My current thinking is that I either have to start picking up Python or building a mental map of wget/awk/grep type commands that can be chained together for a similar effect, but I thought it best to try to learn from the wisdom of others first :-)
Zx really intends to be a scripting language (and i think it does a good job) that happens to be javascript.
Personally I feel like thenbiggest missing piece ZX would beed to be a good straight up competitor to bash or zsh would be better interactive modes. A node repl.os ok, uses libreadline & has lots.of capabilities, but zx feels biased towards scripting, not am actual shell.
I dont see why you think zx couldnt be a substitute. Particularly & especially in the context of a discussion on powershell, where we are clearly already opening the gates of heterodoxy already.
One of the other responses mentioned Nushell, which is a direct substitute for PowerShell in a meaningful sense: an interactive shell, structured pipelines, formatting as the final step of a pipeline, etc...
Anything else tends to be either a random bag of unrelated tools sticky-taped together, OR a heavyweight programming language.
The equivalent of JavaScript or Python is C#, CS-Script, or F# Interactive. Those are also full-featured programming languages.
I can process files in just a couple of lines of C#, but I still reach for PowerShell when doing this kind of thing unless I really need higher throughputs or complex processing.
I feel like ZX has these features already. Rather than choosing to believe there is a meaningful unbridgeable hard fast line, I think it's beneficial to consider case-by-case what features & capabilities are important & what enables smooth, light operation.
Node still isnt `perl -pie` level easy & hybrid, but again I think it's altogether pretty slick & simple with zx today.
The interactive repl doesnt look like a shell but it has quite advanced editing, comes out ahead in many ways (value previews). There's no ability to generate new autocompletion capabilities in the built in repl, but one could potentially yse an IDE and LSP with a repl. The potential for non-monolithic shells is interesting, that a shell might be separated into editor, engine, & plugins.
Formatting as final step Im not as familiar with but it sounds like one could easily map or swizzle their stream output pretty easily. Particularly with better ndjson I think the potential here is high.
Overall I think there are distinctions, characterizations between shell and other languages, but it's less inherent to me; we simply havent spent much effort identifying what it is that makes operating the command line easy, flexible, and have even less work trying to port those ideas & riff off them. Even an early simple thin standard library like zx achieving so much success at becoming putty or glue, alike a shell, so quickly, indicates to me that it's worth doubting our long held certainty that these things are absolutely apart & different.
Is there a similar go to in the Mac/Linux worlds? Yeah, it's called Powershell 7! Powershell was ported to cross platform dotnet a few years back. Currently running some Powershell scripts in production on a Linux box.
"You can use powershell" isnt quite the same as asking what the open source world does. Adoption of powershell on Linux/Mac is tiny. If you show up on a random system, it almost certainly will not be available.
It's good to know powershell is cross platform now. Good to know this can be an option. But I'd also say the original question still deserves more exploration & thought, that asking what the romans do in rome is good to know too.
This is the fundamental differentiation of Powershell, right? UNIX operates on text streams while Powershell operates on structured data. It is in a better position to do this kind of stuff.
That aside, a lot of contemporary cloudy CLIs will now speak json on stdin/out and JQ will make any json transformations you can imagine.
There are a few projects that take inspiration from PowerShell, but they haven't got mass adoption. I have hopes that Nushell will be a success when it gets to 1.0:
Powershell has been a gift in getting things accomplished in Windows. But one thing I've also come to enjoy using it for is quick and dirty interactions and scripting with REST APIs.
Things like Invoke-WebRequest, ConvertTo-Json/ConvertFrom-Json, Export-CSV, piping between almost everything, and the results being passed around like an object that I can use SQL-ish Select queries against, etc.
I find myself feeling like I'm missing something helpful when I'm on a Mac/Linux device. Is there a similar go to in the Mac/Linux world for this type of stuff? My current thinking is that I either have to start picking up Python or building a mental map of wget/awk/grep type commands that can be chained together for a similar effect, but I thought it best to try to learn from the wisdom of others first :-)